Merge from Chromium at DEPS revision r213371

This commit was generated by merge_to_master.py.

Change-Id: I03fae1c1dae6e5de12e56e0a6c3780252291bfae
diff --git a/Source/core/OWNERS b/Source/core/OWNERS
index b98c2fb..409b33b 100644
--- a/Source/core/OWNERS
+++ b/Source/core/OWNERS
@@ -16,6 +16,7 @@
 enne@chromium.org
 eseidel@chromium.org
 esprehn@chromium.org
+fmalita@chromium.org
 hamaji@chromium.org
 haraken@chromium.org
 hayato@chromium.org
diff --git a/Source/core/accessibility/AccessibilityNodeObject.cpp b/Source/core/accessibility/AccessibilityNodeObject.cpp
index ec36ae7..4eaa667 100644
--- a/Source/core/accessibility/AccessibilityNodeObject.cpp
+++ b/Source/core/accessibility/AccessibilityNodeObject.cpp
@@ -866,7 +866,7 @@
         return;
 
     // HTMLInputElement::value always returns a string parseable by Color().
-    Color color(input->value());
+    StyleColor color(input->value());
     r = color.red();
     g = color.green();
     b = color.blue();
diff --git a/Source/core/accessibility/AccessibilityRenderObject.cpp b/Source/core/accessibility/AccessibilityRenderObject.cpp
index 22e5779..c51a957 100644
--- a/Source/core/accessibility/AccessibilityRenderObject.cpp
+++ b/Source/core/accessibility/AccessibilityRenderObject.cpp
@@ -301,7 +301,7 @@
     if (!box->canBeScrolledAndHasScrollableArea())
         return 0;
 
-    return box->layer();
+    return box->layer() ? box->layer()->scrollableArea() : 0;
 }
 
 AccessibilityRole AccessibilityRenderObject::determineAccessibilityRole()
@@ -1322,7 +1322,7 @@
         dirty = true;
 
     if (box->canBeScrolledAndHasScrollableArea()) {
-        ScrollableArea* scrollableArea = box->layer();
+        ScrollableArea* scrollableArea = box->layer() ? box->layer()->scrollableArea() : 0;
         if (scrollableArea && scrollableArea->scrollPosition() != m_cachedScrollPosition)
             dirty = true;
     }
@@ -1346,7 +1346,7 @@
     m_cachedFrameRect = box->frameRect();
 
     if (box->canBeScrolledAndHasScrollableArea()) {
-        ScrollableArea* scrollableArea = box->layer();
+        ScrollableArea* scrollableArea = box->layer() ? box->layer()->scrollableArea() : 0;
         if (scrollableArea)
             m_cachedScrollPosition = scrollableArea->scrollPosition();
     }
diff --git a/Source/core/accessibility/AccessibilityTable.cpp b/Source/core/accessibility/AccessibilityTable.cpp
index 8720001..d49bb35 100644
--- a/Source/core/accessibility/AccessibilityTable.cpp
+++ b/Source/core/accessibility/AccessibilityTable.cpp
@@ -146,7 +146,7 @@
     RenderStyle* tableStyle = table->style();
     if (!tableStyle)
         return false;
-    Color tableBGColor = tableStyle->visitedDependentColor(CSSPropertyBackgroundColor);
+    StyleColor tableBGColor = tableStyle->visitedDependentColor(CSSPropertyBackgroundColor);
     
     // check enough of the cells to find if the table matches our criteria
     // Criteria: 
@@ -161,7 +161,7 @@
     unsigned cellsWithLeftBorder = 0;
     unsigned cellsWithRightBorder = 0;
     
-    Color alternatingRowColors[5];
+    StyleColor alternatingRowColors[5];
     int alternatingRowColorCount = 0;
     
     int headersInFirstColumnCount = 0;
@@ -223,7 +223,7 @@
             
             // If the cell has a different color from the table and there is cell spacing,
             // then it is probably a data table cell (spacing and colors take the place of borders).
-            Color cellColor = renderStyle->visitedDependentColor(CSSPropertyBackgroundColor);
+            StyleColor cellColor = renderStyle->visitedDependentColor(CSSPropertyBackgroundColor);
             if (table->hBorderSpacing() > 0 && table->vBorderSpacing() > 0
                 && tableBGColor != cellColor && cellColor.alpha() != 1)
                 backgroundDifferenceCellCount++;
@@ -240,7 +240,7 @@
                 RenderStyle* rowRenderStyle = renderRow->style();
                 if (!rowRenderStyle)
                     continue;
-                Color rowColor = rowRenderStyle->visitedDependentColor(CSSPropertyBackgroundColor);
+                StyleColor rowColor = rowRenderStyle->visitedDependentColor(CSSPropertyBackgroundColor);
                 alternatingRowColors[alternatingRowColorCount] = rowColor;
                 alternatingRowColorCount++;
             }
@@ -272,7 +272,7 @@
 
     // Check if there is an alternating row background color indicating a zebra striped style pattern.
     if (alternatingRowColorCount > 2) {
-        Color firstColor = alternatingRowColors[0];
+        StyleColor firstColor = alternatingRowColors[0];
         for (int k = 1; k < alternatingRowColorCount; k++) {
             // If an odd row was the same color as the first row, its not alternating.
             if (k % 2 == 1 && alternatingRowColors[k] == firstColor)
diff --git a/Source/core/platform/graphics/chromium/IconChromium.cpp b/Source/core/animation/ActiveAnimations.h
similarity index 72%
copy from Source/core/platform/graphics/chromium/IconChromium.cpp
copy to Source/core/animation/ActiveAnimations.h
index ab3f829..e4c748c 100644
--- a/Source/core/platform/graphics/chromium/IconChromium.cpp
+++ b/Source/core/animation/ActiveAnimations.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Google Inc. All rights reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -28,26 +28,28 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
-#include "core/platform/graphics/Icon.h"
+#ifndef ActiveAnimations_h
+#define ActiveAnimations_h
 
-#include "core/platform/graphics/GraphicsContext.h"
-#include "wtf/text/WTFString.h"
+#include "core/animation/AnimationStack.h"
+#include "wtf/HashMap.h"
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
-Icon::Icon(PassRefPtr<PlatformIcon> icon)
-    : m_icon(icon)
-{
-}
+class AnimationStack;
 
-Icon::~Icon()
-{
-}
-
-void Icon::paint(GraphicsContext* context, const IntRect& rect)
-{
-    context->drawImage(m_icon.get(), rect);
-}
+class ActiveAnimations {
+public:
+    AnimationStack* defaultStack() { return &m_defaultStack; }
+    bool isEmpty() const { return !m_defaultStack.hasActiveAnimations(); }
+private:
+    AnimationStack m_defaultStack;
+    // FIXME: Add AnimationStack for CSS Transitions
+    // FIXME: Add tracking data for CSS Animations
+};
 
 } // namespace WebCore
+
+#endif
diff --git a/Source/core/animation/Animation.cpp b/Source/core/animation/Animation.cpp
index e2b5673..3c833dd 100644
--- a/Source/core/animation/Animation.cpp
+++ b/Source/core/animation/Animation.cpp
@@ -31,6 +31,8 @@
 #include "config.h"
 #include "core/animation/Animation.h"
 
+#include "core/animation/DocumentTimeline.h"
+#include "core/animation/Player.h"
 #include "core/dom/Element.h"
 
 namespace WebCore {
@@ -44,21 +46,27 @@
     : TimedItem(timing)
     , m_target(target)
     , m_effect(effect)
-    , m_isInTargetActiveAnimationsList(false)
+    , m_activeInAnimationStack(false)
 {
 }
 
-Animation::~Animation()
+void Animation::willDetach()
 {
-    if (m_isInTargetActiveAnimationsList)
-        m_target->removeActiveAnimation(this);
+    if (m_activeInAnimationStack)
+        clearEffects();
 }
 
-void Animation::applyEffects(bool previouslyActiveOrInEffect)
+static AnimationStack* ensureAnimationStack(Element* element)
 {
-    if (!previouslyActiveOrInEffect) {
-        m_target->addActiveAnimation(this);
-        m_isInTargetActiveAnimationsList = true;
+    return element->ensureActiveAnimations()->defaultStack();
+}
+
+void Animation::applyEffects(bool previouslyInEffect)
+{
+    ASSERT(player());
+    if (!previouslyInEffect) {
+        ensureAnimationStack(m_target.get())->add(this);
+        m_activeInAnimationStack = true;
     }
     m_compositableValues = m_effect->sample(currentIteration(), timeFraction());
     m_target->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer);
@@ -66,19 +74,20 @@
 
 void Animation::clearEffects()
 {
-    m_target->removeActiveAnimation(this);
-    m_isInTargetActiveAnimationsList = false;
+    ASSERT(player());
+    ASSERT(m_activeInAnimationStack);
+    ensureAnimationStack(m_target.get())->remove(this);
+    m_activeInAnimationStack = false;
     m_compositableValues.clear();
 }
 
-void Animation::updateChildrenAndEffects(bool wasActiveOrInEffect) const
+void Animation::updateChildrenAndEffects(bool wasInEffect) const
 {
-    const bool isActiveOrInEffect = isActive() || isInEffect();
-    ASSERT(m_isInTargetActiveAnimationsList == wasActiveOrInEffect);
-    if (wasActiveOrInEffect && !isActiveOrInEffect)
+    ASSERT(m_activeInAnimationStack == wasInEffect);
+    if (isInEffect())
+        const_cast<Animation*>(this)->applyEffects(wasInEffect);
+    else if (wasInEffect)
         const_cast<Animation*>(this)->clearEffects();
-    else if (isActiveOrInEffect)
-        const_cast<Animation*>(this)->applyEffects(wasActiveOrInEffect);
 }
 
 } // namespace WebCore
diff --git a/Source/core/animation/Animation.h b/Source/core/animation/Animation.h
index f72d57a..7f5d7a8 100644
--- a/Source/core/animation/Animation.h
+++ b/Source/core/animation/Animation.h
@@ -43,7 +43,6 @@
 
 public:
     static PassRefPtr<Animation> create(PassRefPtr<Element>, PassRefPtr<AnimationEffect>, const Timing&);
-    virtual ~Animation();
 
     const AnimationEffect::CompositableValueMap* compositableValues() const
     {
@@ -52,16 +51,18 @@
     }
 
 protected:
-    virtual void applyEffects(bool previouslyActiveOrInEffect);
+    virtual void applyEffects(bool previouslyInEffect);
     virtual void clearEffects();
     virtual void updateChildrenAndEffects(bool) const OVERRIDE FINAL;
+    virtual void willDetach() OVERRIDE FINAL;
 
 private:
     Animation(PassRefPtr<Element>, PassRefPtr<AnimationEffect>, const Timing&);
 
     RefPtr<Element> m_target;
     RefPtr<AnimationEffect> m_effect;
-    bool m_isInTargetActiveAnimationsList;
+
+    bool m_activeInAnimationStack;
     OwnPtr<AnimationEffect::CompositableValueMap> m_compositableValues;
 };
 
diff --git a/Source/core/platform/graphics/chromium/IconChromium.cpp b/Source/core/animation/AnimationStack.h
similarity index 63%
copy from Source/core/platform/graphics/chromium/IconChromium.cpp
copy to Source/core/animation/AnimationStack.h
index ab3f829..3bbf488 100644
--- a/Source/core/platform/graphics/chromium/IconChromium.cpp
+++ b/Source/core/animation/AnimationStack.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Google Inc. All rights reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -28,26 +28,36 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
-#include "core/platform/graphics/Icon.h"
+#ifndef AnimationStack_h
+#define AnimationStack_h
 
-#include "core/platform/graphics/GraphicsContext.h"
-#include "wtf/text/WTFString.h"
+#include "wtf/HashMap.h"
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
-Icon::Icon(PassRefPtr<PlatformIcon> icon)
-    : m_icon(icon)
-{
-}
+class Element;
+class Animation;
 
-Icon::~Icon()
-{
-}
+class AnimationStack {
 
-void Icon::paint(GraphicsContext* context, const IntRect& rect)
-{
-    context->drawImage(m_icon.get(), rect);
-}
+public:
+    void add(Animation* animation) { m_activeAnimations.append(animation); }
+    void remove(Animation* animation)
+    {
+        size_t position = m_activeAnimations.find(animation);
+        ASSERT(position != notFound);
+        m_activeAnimations.remove(position);
+    }
+    bool hasActiveAnimations() const { return !m_activeAnimations.isEmpty(); }
+    // FIXME: This should be PassRefPtr<CompositableValue> composite(Element*, CSSPropertyId)
+    const Vector<Animation*>& activeAnimations(const Element* element) const { return m_activeAnimations; }
+
+private:
+    Vector<Animation*> m_activeAnimations;
+};
 
 } // namespace WebCore
+
+#endif
diff --git a/Source/core/animation/DocumentTimeline.h b/Source/core/animation/DocumentTimeline.h
index a2bd963..4f0d7f1 100644
--- a/Source/core/animation/DocumentTimeline.h
+++ b/Source/core/animation/DocumentTimeline.h
@@ -31,7 +31,9 @@
 #ifndef DocumentTimeline_h
 #define DocumentTimeline_h
 
+#include "core/animation/ActiveAnimations.h"
 #include "core/animation/Player.h"
+#include "core/dom/Element.h"
 #include "wtf/RefCounted.h"
 #include "wtf/RefPtr.h"
 #include "wtf/Vector.h"
@@ -50,6 +52,12 @@
     PassRefPtr<Player> play(TimedItem*);
     double currentTime() { return m_currentTime; }
     void pauseAnimationsForTesting(double);
+    AnimationStack* animationStack(const Element* element) const
+    {
+        if (ActiveAnimations* animations = element->activeAnimations())
+            return animations->defaultStack();
+        return 0;
+    }
 
 private:
     DocumentTimeline(Document*);
diff --git a/Source/core/animation/Player.cpp b/Source/core/animation/Player.cpp
index 2cdefe0..abb23f9 100644
--- a/Source/core/animation/Player.cpp
+++ b/Source/core/animation/Player.cpp
@@ -52,9 +52,17 @@
     , m_timeline(timeline)
 {
     ASSERT(m_startTime >= 0);
+    if (m_content)
+        m_content->attach(this);
     update();
 }
 
+Player::~Player()
+{
+    if (m_content)
+        m_content->detach();
+}
+
 double Player::currentTimeBeforeDrift() const
 {
     return (effectiveTime(m_timeline->currentTime()) - m_startTime) * m_playbackRate;
diff --git a/Source/core/animation/Player.h b/Source/core/animation/Player.h
index c0a8a8b..3b4e480 100644
--- a/Source/core/animation/Player.h
+++ b/Source/core/animation/Player.h
@@ -41,6 +41,7 @@
 class Player FINAL : public RefCounted<Player> {
 
 public:
+    ~Player();
     static PassRefPtr<Player> create(DocumentTimeline*, TimedItem*);
 
     // Returns whether this player is still current or in effect.
@@ -53,6 +54,7 @@
     void setPlaybackRate(double);
     double startTime() const { return m_startTime; }
     double timeDrift() const;
+    DocumentTimeline* timeline() { return m_timeline; }
 
 private:
     Player(DocumentTimeline*, TimedItem*);
diff --git a/Source/core/animation/TimedItem.cpp b/Source/core/animation/TimedItem.cpp
index 9a0e71e..98121b8 100644
--- a/Source/core/animation/TimedItem.cpp
+++ b/Source/core/animation/TimedItem.cpp
@@ -36,6 +36,7 @@
 
 TimedItem::TimedItem(const Timing& timing)
     : m_parent(0)
+    , m_player(0)
     , m_startTime(0)
     , m_specified(timing)
     , m_calculated()
@@ -55,7 +56,10 @@
         ? repeatedDuration / abs(m_specified.playbackRate)
         : std::numeric_limits<double>::infinity();
 
-    const double activeTime = calculateActiveTime(activeDuration, localTime, m_startTime, m_specified);
+    const TimedItem::Phase phase = calculatePhase(activeDuration, localTime, m_specified);
+    // FIXME: parentPhase depends on groups being implemented.
+    const TimedItem::Phase parentPhase = TimedItem::PhaseActive;
+    const double activeTime = calculateActiveTime(activeDuration, localTime, parentPhase, phase, m_specified);
 
     double currentIteration = nullValue();
     double timeFraction = nullValue();
@@ -71,8 +75,9 @@
         const double iterationDuration = 1;
         const double repeatedDuration = iterationDuration * m_specified.iterationCount;
         const double activeDuration = m_specified.playbackRate ? repeatedDuration / abs(m_specified.playbackRate) : std::numeric_limits<double>::infinity();
-        const double newLocalTime = localTime < m_specified.startDelay ? m_specified.startDelay - 1 : activeDuration;
-        const double activeTime = calculateActiveTime(activeDuration, newLocalTime, m_startTime, m_specified);
+        const double newLocalTime = localTime < m_specified.startDelay ? m_specified.startDelay - 1 : activeDuration + m_specified.startDelay;
+        const TimedItem::Phase phase = calculatePhase(activeDuration, newLocalTime, m_specified);
+        const double activeTime = calculateActiveTime(activeDuration, newLocalTime, parentPhase, phase, m_specified);
         const double startOffset = m_specified.iterationStart * iterationDuration;
         const double scaledActiveTime = calculateScaledActiveTime(activeDuration, activeTime, startOffset, m_specified);
         const double iterationTime = calculateIterationTime(iterationDuration, repeatedDuration, scaledActiveTime, startOffset, m_specified);
@@ -85,24 +90,22 @@
     m_calculated.activeDuration = activeDuration;
     m_calculated.timeFraction = timeFraction;
 
-    const bool wasActiveOrInEffect = isActive() || isInEffect();
-    m_calculated.isScheduled = (!isNull(localTime) && localTime < m_specified.startDelay) || (m_parent && m_parent->isScheduled());
-    m_calculated.isActive = !isNull(localTime) && localTime >= m_specified.startDelay && localTime < m_specified.startDelay + activeDuration;
-    m_calculated.isCurrent = isScheduled() || isActive() || (m_parent && m_parent->isCurrent());
+    const bool wasInEffect = isInEffect();
     m_calculated.isInEffect = !isNull(activeTime);
+    m_calculated.isInPlay = phase == PhaseActive && (!m_parent || m_parent->isInPlay());
+    m_calculated.isCurrent = phase == PhaseBefore || isInPlay() || (m_parent && m_parent->isCurrent());
 
     // FIXME: This probably shouldn't be recursive.
-    updateChildrenAndEffects(wasActiveOrInEffect);
+    updateChildrenAndEffects(wasInEffect);
 }
 
 TimedItem::CalculatedTiming::CalculatedTiming()
     : activeDuration(nullValue())
     , currentIteration(nullValue())
     , timeFraction(nullValue())
-    , isScheduled(false)
-    , isActive(false)
     , isCurrent(false)
     , isInEffect(false)
+    , isInPlay(false)
 {
 }
 
diff --git a/Source/core/animation/TimedItem.h b/Source/core/animation/TimedItem.h
index 9e32eb7..58ca314 100644
--- a/Source/core/animation/TimedItem.h
+++ b/Source/core/animation/TimedItem.h
@@ -36,6 +36,8 @@
 
 namespace WebCore {
 
+class Player;
+
 static inline bool isNull(double value)
 {
     return std::isnan(value);
@@ -47,19 +49,27 @@
 }
 
 class TimedItem : public RefCounted<TimedItem> {
+    friend class Player; // Calls attach/detach, updateInheritedTime.
 public:
     virtual ~TimedItem() { }
 
-    bool isScheduled() const { return ensureCalculated().isScheduled; }
-    bool isActive() const { return ensureCalculated().isActive; }
     bool isCurrent() const { return ensureCalculated().isCurrent; }
     bool isInEffect() const { return ensureCalculated().isInEffect; }
+    bool isInPlay() const { return ensureCalculated().isInPlay; }
 
     double startTime() const { return m_startTime; }
 
     double currentIteration() const { return ensureCalculated().currentIteration; }
     double activeDuration() const { return ensureCalculated().activeDuration; }
     double timeFraction() const { return ensureCalculated().timeFraction; }
+    Player* player() const { return m_player; }
+
+    enum Phase {
+        PhaseBefore,
+        PhaseActive,
+        PhaseAfter,
+        PhaseNone,
+    };
 
 protected:
     TimedItem(const Timing&);
@@ -68,16 +78,23 @@
     // it will (if necessary) recalculate timings and (if necessary) call
     // updateChildrenAndEffects.
     void updateInheritedTime(double inheritedTime) const;
-    virtual void updateChildrenAndEffects(bool wasActiveOrInEffect) const = 0;
+    virtual void updateChildrenAndEffects(bool wasInEffect) const = 0;
     virtual double intrinsicIterationDuration() const { return 0; };
-
-    friend class Player; // Calls updateInheritedTime.
+    virtual void willDetach() = 0;
 
 private:
+    void attach(Player* player) { m_player = player; };
+    void detach()
+    {
+        ASSERT(m_player);
+        willDetach();
+        m_player = 0;
+    };
+
     // FIXME: m_parent and m_startTime are placeholders, they depend on timing groups.
     TimedItem* const m_parent;
     const double m_startTime;
-
+    Player* m_player;
     Timing m_specified;
 
     // FIXME: Should be versioned by monotonic value on player.
@@ -86,10 +103,9 @@
         double activeDuration;
         double currentIteration;
         double timeFraction;
-        bool isScheduled;
-        bool isActive;
         bool isCurrent;
         bool isInEffect;
+        bool isInPlay;
     } m_calculated;
 
     // FIXME: Should check the version and reinherit time if inconsistent.
diff --git a/Source/core/animation/TimedItemCalculations.h b/Source/core/animation/TimedItemCalculations.h
index 3603b04..ef6d5eb 100644
--- a/Source/core/animation/TimedItemCalculations.h
+++ b/Source/core/animation/TimedItemCalculations.h
@@ -38,27 +38,58 @@
 
 namespace WebCore {
 
-static inline double calculateActiveTime(double activeDuration, double localTime, double startTime, const Timing& specified)
+static inline TimedItem::Phase calculatePhase(double activeDuration, double localTime, const Timing& specified)
 {
     ASSERT(activeDuration >= 0);
-    ASSERT(std::isfinite(startTime));
-
     if (isNull(localTime))
-        return nullValue();
+        return TimedItem::PhaseNone;
+    if (localTime < specified.startDelay)
+        return TimedItem::PhaseBefore;
+    if (localTime >= specified.startDelay + activeDuration)
+        return TimedItem::PhaseAfter;
+    return TimedItem::PhaseActive;
+}
 
-    if (localTime < specified.startDelay) {
+static inline bool isActiveInParentPhase(TimedItem::Phase parentPhase, Timing::FillMode fillMode)
+{
+    switch (parentPhase) {
+    case TimedItem::PhaseBefore:
+        return fillMode == Timing::FillModeBackwards || fillMode == Timing::FillModeBoth;
+    case TimedItem::PhaseActive:
+        return true;
+    case TimedItem::PhaseAfter:
+        return fillMode == Timing::FillModeForwards || fillMode == Timing::FillModeBoth;
+    default:
+        ASSERT_NOT_REACHED();
+        return false;
+    }
+}
+
+static inline double calculateActiveTime(double activeDuration, double localTime, TimedItem::Phase parentPhase, TimedItem::Phase phase, const Timing& specified)
+{
+    ASSERT(activeDuration >= 0);
+    ASSERT(phase == calculatePhase(activeDuration, localTime, specified));
+
+    switch (phase) {
+    case TimedItem::PhaseBefore:
         if (specified.fillMode == Timing::FillModeBackwards || specified.fillMode == Timing::FillModeBoth)
             return 0;
         return nullValue();
+    case TimedItem::PhaseActive:
+        if (isActiveInParentPhase(parentPhase, specified.fillMode))
+            return localTime - specified.startDelay;
+        return nullValue();
+    case TimedItem::PhaseAfter:
+        if (specified.fillMode == Timing::FillModeForwards || specified.fillMode == Timing::FillModeBoth)
+            return activeDuration;
+        return nullValue();
+    case TimedItem::PhaseNone:
+        ASSERT(isNull(localTime));
+        return nullValue();
+    default:
+        ASSERT_NOT_REACHED();
+        return nullValue();
     }
-
-    if (localTime < startTime + activeDuration)
-        return localTime - specified.startDelay;
-
-    if (specified.fillMode == Timing::FillModeForwards || specified.fillMode == Timing::FillModeBoth)
-        return activeDuration;
-
-    return nullValue();
 }
 
 static inline double calculateScaledActiveTime(double activeDuration, double activeTime, double startOffset, const Timing& specified)
diff --git a/Source/core/animation/TimedItemCalculationsTest.cpp b/Source/core/animation/TimedItemCalculationsTest.cpp
index 9565b95..734dd7e 100644
--- a/Source/core/animation/TimedItemCalculationsTest.cpp
+++ b/Source/core/animation/TimedItemCalculationsTest.cpp
@@ -43,37 +43,46 @@
 
     // calculateActiveTime(activeDuration, localTime, startTime)
 
-    // if the local time is null
-    ASSERT_TRUE(isNull(calculateActiveTime(32, nullValue(), 17, timing)));
-
-    // local time < start delay
-    timing.fillMode = Timing::FillModeForwards;
+    // Before Phase
     timing.startDelay = 10;
-    ASSERT_TRUE(isNull(calculateActiveTime(20, 0, 20, timing)));
+    timing.fillMode = Timing::FillModeForwards;
+    ASSERT_TRUE(isNull(calculateActiveTime(20, 0, TimedItem::PhaseActive, TimedItem::PhaseBefore, timing)));
     timing.fillMode = Timing::FillModeNone;
-    ASSERT_TRUE(isNull(calculateActiveTime(20, 0, 20, timing)));
+    ASSERT_TRUE(isNull(calculateActiveTime(20, 0, TimedItem::PhaseActive, TimedItem::PhaseBefore, timing)));
     timing.fillMode = Timing::FillModeBackwards;
-    ASSERT_EQ(0, calculateActiveTime(20, 0, 20, timing));
+    ASSERT_EQ(0, calculateActiveTime(20, 0, TimedItem::PhaseActive, TimedItem::PhaseBefore, timing));
     timing.fillMode = Timing::FillModeBoth;
-    ASSERT_EQ(0, calculateActiveTime(20, 0, 20, timing));
+    ASSERT_EQ(0, calculateActiveTime(20, 0, TimedItem::PhaseActive, TimedItem::PhaseBefore, timing));
 
-    // local time < start time + active duration
-    timing.fillMode = Timing::FillModeForwards;
+    // Active Phase
     timing.startDelay = 10;
-    ASSERT_EQ(5, calculateActiveTime(20, 15, 20, timing));
-
-    // otherwise, forwards / both
-    timing.fillMode = Timing::FillModeForwards;
-    timing.startDelay = 10;
-    ASSERT_EQ(21, calculateActiveTime(21, 45, 20, timing));
-    timing.fillMode = Timing::FillModeBoth;
-    ASSERT_EQ(21, calculateActiveTime(21, 45, 20, timing));
-
-    // otherwise
-    timing.fillMode = Timing::FillModeBackwards;
-    ASSERT_TRUE(isNull(calculateActiveTime(21, 45, 20, timing)));
+    // Active, and parent Before
     timing.fillMode = Timing::FillModeNone;
-    ASSERT_TRUE(isNull(calculateActiveTime(21, 45, 20, timing)));
+    ASSERT_TRUE(isNull(calculateActiveTime(20, 15, TimedItem::PhaseBefore, TimedItem::PhaseActive, timing)));
+    timing.fillMode = Timing::FillModeForwards;
+    ASSERT_TRUE(isNull(calculateActiveTime(20, 15, TimedItem::PhaseBefore, TimedItem::PhaseActive, timing)));
+    // Active, and parent After
+    timing.fillMode = Timing::FillModeNone;
+    ASSERT_TRUE(isNull(calculateActiveTime(20, 15, TimedItem::PhaseAfter, TimedItem::PhaseActive, timing)));
+    timing.fillMode = Timing::FillModeBackwards;
+    ASSERT_TRUE(isNull(calculateActiveTime(20, 15, TimedItem::PhaseAfter, TimedItem::PhaseActive, timing)));
+    // Active, and parent Active
+    timing.fillMode = Timing::FillModeForwards;
+    ASSERT_EQ(5, calculateActiveTime(20, 15, TimedItem::PhaseActive, TimedItem::PhaseActive, timing));
+
+    // After Phase
+    timing.startDelay = 10;
+    timing.fillMode = Timing::FillModeForwards;
+    ASSERT_EQ(21, calculateActiveTime(21, 45, TimedItem::PhaseActive, TimedItem::PhaseAfter, timing));
+    timing.fillMode = Timing::FillModeBoth;
+    ASSERT_EQ(21, calculateActiveTime(21, 45, TimedItem::PhaseActive, TimedItem::PhaseAfter, timing));
+    timing.fillMode = Timing::FillModeBackwards;
+    ASSERT_TRUE(isNull(calculateActiveTime(21, 45, TimedItem::PhaseActive, TimedItem::PhaseAfter, timing)));
+    timing.fillMode = Timing::FillModeNone;
+    ASSERT_TRUE(isNull(calculateActiveTime(21, 45, TimedItem::PhaseActive, TimedItem::PhaseAfter, timing)));
+
+    // None
+    ASSERT_TRUE(isNull(calculateActiveTime(32, nullValue(), TimedItem::PhaseNone, TimedItem::PhaseNone, timing)));
 }
 
 TEST(TimedItemCalculations, ScaledActiveTime)
diff --git a/Source/core/animation/TimedItemTest.cpp b/Source/core/animation/TimedItemTest.cpp
index 71fc25e..2fccfff 100644
--- a/Source/core/animation/TimedItemTest.cpp
+++ b/Source/core/animation/TimedItemTest.cpp
@@ -52,6 +52,8 @@
     void updateChildrenAndEffects(bool wasActiveOrInEffect) const FINAL OVERRIDE {
     }
 
+    void willDetach() { }
+
 private:
     TestTimedItem(const Timing& specified)
         : TimedItem(specified)
@@ -66,10 +68,9 @@
     timing.iterationDuration = 2;
     RefPtr<TestTimedItem> timedItem = TestTimedItem::create(timing);
 
-    ASSERT_FALSE(timedItem->isScheduled());
-    ASSERT_FALSE(timedItem->isActive());
     ASSERT_FALSE(timedItem->isCurrent());
     ASSERT_FALSE(timedItem->isInEffect());
+    ASSERT_FALSE(timedItem->isInPlay());
     ASSERT_TRUE(isNull(timedItem->currentIteration()));
     ASSERT_EQ(0, timedItem->startTime());
     ASSERT_TRUE(isNull(timedItem->activeDuration()));
@@ -77,8 +78,7 @@
 
     timedItem->updateInheritedTime(0);
 
-    ASSERT_FALSE(timedItem->isScheduled());
-    ASSERT_TRUE(timedItem->isActive());
+    ASSERT_TRUE(timedItem->isInPlay());
     ASSERT_TRUE(timedItem->isCurrent());
     ASSERT_TRUE(timedItem->isInEffect());
     ASSERT_EQ(0, timedItem->currentIteration());
@@ -88,8 +88,7 @@
 
     timedItem->updateInheritedTime(1);
 
-    ASSERT_FALSE(timedItem->isScheduled());
-    ASSERT_TRUE(timedItem->isActive());
+    ASSERT_TRUE(timedItem->isInPlay());
     ASSERT_TRUE(timedItem->isCurrent());
     ASSERT_TRUE(timedItem->isInEffect());
     ASSERT_EQ(0, timedItem->currentIteration());
@@ -99,8 +98,7 @@
 
     timedItem->updateInheritedTime(2);
 
-    ASSERT_FALSE(timedItem->isScheduled());
-    ASSERT_FALSE(timedItem->isActive());
+    ASSERT_FALSE(timedItem->isInPlay());
     ASSERT_FALSE(timedItem->isCurrent());
     ASSERT_TRUE(timedItem->isInEffect());
     ASSERT_EQ(0, timedItem->currentIteration());
@@ -110,8 +108,7 @@
 
     timedItem->updateInheritedTime(3);
 
-    ASSERT_FALSE(timedItem->isScheduled());
-    ASSERT_FALSE(timedItem->isActive());
+    ASSERT_FALSE(timedItem->isInPlay());
     ASSERT_FALSE(timedItem->isCurrent());
     ASSERT_TRUE(timedItem->isInEffect());
     ASSERT_EQ(0, timedItem->currentIteration());
@@ -302,8 +299,7 @@
     Timing timing;
     RefPtr<TestTimedItem> timedItem = TestTimedItem::create(timing);
 
-    ASSERT_FALSE(timedItem->isScheduled());
-    ASSERT_FALSE(timedItem->isActive());
+    ASSERT_FALSE(timedItem->isInPlay());
     ASSERT_FALSE(timedItem->isCurrent());
     ASSERT_FALSE(timedItem->isInEffect());
     ASSERT_TRUE(isNull(timedItem->currentIteration()));
@@ -313,8 +309,7 @@
 
     timedItem->updateInheritedTime(0);
 
-    ASSERT_FALSE(timedItem->isScheduled());
-    ASSERT_FALSE(timedItem->isActive());
+    ASSERT_FALSE(timedItem->isInPlay());
     ASSERT_FALSE(timedItem->isCurrent());
     ASSERT_TRUE(timedItem->isInEffect());
     ASSERT_EQ(0, timedItem->currentIteration());
@@ -324,8 +319,7 @@
 
     timedItem->updateInheritedTime(1);
 
-    ASSERT_FALSE(timedItem->isScheduled());
-    ASSERT_FALSE(timedItem->isActive());
+    ASSERT_FALSE(timedItem->isInPlay());
     ASSERT_FALSE(timedItem->isCurrent());
     ASSERT_TRUE(timedItem->isInEffect());
     ASSERT_EQ(0, timedItem->currentIteration());
@@ -397,6 +391,25 @@
     ASSERT_EQ(1, timedItem->timeFraction());
 }
 
+TEST(TimedItem, ZeroDurationIterationStartAndCount)
+{
+    Timing timing;
+    timing.iterationStart = 0.1;
+    timing.iterationCount = 0.2;
+    timing.fillMode = Timing::FillModeBoth;
+    timing.startDelay = 0.3;
+    RefPtr<TestTimedItem> timedItem = TestTimedItem::create(timing);
+
+    timedItem->updateInheritedTime(0);
+    ASSERT_EQ(0.1, timedItem->timeFraction());
+
+    timedItem->updateInheritedTime(0.3);
+    ASSERT_DOUBLE_EQ(0.3, timedItem->timeFraction());
+
+    timedItem->updateInheritedTime(1);
+    ASSERT_DOUBLE_EQ(0.3, timedItem->timeFraction());
+}
+
 // FIXME: Needs specification work -- ASSERTION FAILED: activeDuration >= 0
 TEST(TimedItem, DISABLED_ZeroDurationInfiniteIteration)
 {
diff --git a/Source/core/core.gyp b/Source/core/core.gyp
index 37a6211..45ca9f2 100644
--- a/Source/core/core.gyp
+++ b/Source/core/core.gyp
@@ -840,7 +840,6 @@
             ['include', 'platform/chromium/ClipboardChromiumLinux\\.cpp$'],
             ['include', 'platform/chromium/FileSystemChromiumLinux\\.cpp$'],
             ['include', 'platform/graphics/chromium/GlyphPageTreeNodeLinux\\.cpp$'],
-            ['exclude', 'platform/graphics/chromium/IconChromium\\.cpp$'],
             ['include', 'platform/graphics/chromium/VDMXParser\\.cpp$'],
             ['exclude', 'platform/graphics/skia/FontCacheSkia\\.cpp$'],
           ],
diff --git a/Source/core/core.gypi b/Source/core/core.gypi
index 9df421c..6e8312c 100644
--- a/Source/core/core.gypi
+++ b/Source/core/core.gypi
@@ -533,6 +533,7 @@
             'accessibility/AccessibilityTableHeaderContainer.h',
             'accessibility/AccessibilityTableRow.cpp',
             'accessibility/AccessibilityTableRow.h',
+            'animation/ActiveAnimations.h',
             'animation/AnimatableNeutral.h',
             'animation/AnimatableNumber.cpp',
             'animation/AnimatableNumber.h',
@@ -542,6 +543,7 @@
             'animation/Animation.cpp',
             'animation/Animation.h',
             'animation/AnimationEffect.h',
+            'animation/AnimationStack.h',
             'animation/DocumentTimeline.cpp',
             'animation/DocumentTimeline.h',
             'animation/KeyframeAnimationEffect.cpp',
@@ -727,6 +729,7 @@
             'css/ShadowValue.cpp',
             'css/ShadowValue.h',
             'css/SiblingTraversalStrategies.h',
+            'css/StyleColor.cpp',
             'css/StyleColor.h',
             'css/StyleInvalidationAnalysis.cpp',
             'css/StyleInvalidationAnalysis.h',
@@ -1213,6 +1216,7 @@
             'page/PointerLockController.h',
             'page/PopupOpeningObserver.h',
             'page/PrintContext.cpp',
+            'page/ResourceTimingInfo.h',
             'page/RuntimeCSSEnabled.cpp',
             'page/RuntimeCSSEnabled.h',
             'page/RuntimeEnabledFeaturesCustom.cpp',
@@ -1364,6 +1368,7 @@
             'rendering/RenderLayerCompositor.h',
             'rendering/RenderLayerFilterInfo.cpp',
             'rendering/RenderLayerFilterInfo.h',
+            'rendering/RenderLayerScrollableArea.cpp',
             'rendering/RenderLayerModelObject.cpp',
             'rendering/RenderLazyBlock.cpp',
             'rendering/RenderLazyBlock.h',
@@ -1730,6 +1735,8 @@
             'dom/ContextLifecycleNotifier.cpp',
             'dom/ContextLifecycleNotifier.h',
             'dom/CrossThreadTask.h',
+            'dom/CustomElement.cpp',
+            'dom/CustomElement.h',
             'dom/CustomElementCallbackDispatcher.cpp',
             'dom/CustomElementCallbackDispatcher.h',
             'dom/CustomElementCallbackInvocation.cpp',
@@ -2525,8 +2532,6 @@
             'platform/DragImage.cpp',
             'platform/EventTracer.cpp',
             'platform/FileChooser.cpp',
-            'platform/FileIconLoader.cpp',
-            'platform/FileIconLoader.h',
             'platform/FileMetadata.h',
             'platform/FloatConversion.h',
             'platform/HashTools.h',
@@ -2837,8 +2842,6 @@
             'platform/graphics/chromium/FontUtilsChromiumWin.cpp',
             'platform/graphics/chromium/FontUtilsChromiumWin.h',
             'platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp',
-            'platform/graphics/chromium/IconChromium.cpp',
-            'platform/graphics/chromium/IconChromiumAndroid.cpp',
             'platform/graphics/chromium/ImageChromium.cpp',
             'platform/graphics/chromium/ImageDecodingStore.cpp',
             'platform/graphics/chromium/ImageDecodingStore.h',
@@ -2848,7 +2851,6 @@
             'platform/graphics/chromium/LazyDecodingPixelRef.h',
             'platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp',
             'platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h',
-            'platform/graphics/chromium/PlatformIcon.h',
             'platform/graphics/chromium/ScaledImageFragment.cpp',
             'platform/graphics/chromium/ScaledImageFragment.h',
             'platform/graphics/chromium/SimpleFontDataChromiumWin.cpp',
@@ -3118,9 +3120,6 @@
             'platform/network/ProxyServer.cpp',
             'platform/network/ResourceError.cpp',
             'platform/network/ResourceError.h',
-            'platform/network/ResourceHandle.cpp',
-            'platform/network/ResourceHandleClient.cpp',
-            'platform/network/ResourceHandleInternal.h',
             'platform/network/ResourceRequest.cpp',
             'platform/network/ResourceRequest.h',
             'platform/network/ResourceResponse.cpp',
@@ -3692,6 +3691,7 @@
             'platform/chromium/support/WebCursorInfo.cpp',
             'platform/chromium/support/WebData.cpp',
             'platform/chromium/support/WebDeviceMotionData.cpp',
+            'platform/chromium/support/WebDeviceOrientationData.cpp',
             'platform/chromium/support/WebFloatQuad.cpp',
             'platform/chromium/support/WebHTTPBody.cpp',
             'platform/chromium/support/WebHTTPLoadInfo.cpp',
@@ -3747,6 +3747,7 @@
             'platform/SharedBufferTest.cpp',
             'platform/chromium/ClipboardChromiumTest.cpp',
             'platform/graphics/FontTest.cpp',
+            'platform/graphics/GraphicsContextTest.cpp',
             'platform/graphics/UnitBezierTest.cpp',
             'platform/graphics/chromium/AnimationTranslationUtilTest.cpp',
             'platform/graphics/chromium/Canvas2DLayerBridgeTest.cpp',
diff --git a/Source/core/core_derived_sources.gyp b/Source/core/core_derived_sources.gyp
index 69ec6ed..accc669 100644
--- a/Source/core/core_derived_sources.gyp
+++ b/Source/core/core_derived_sources.gyp
@@ -450,7 +450,6 @@
               'css/themeWin.css',
               'css/themeWinQuirks.css',
               'css/svg.css',
-              'css/mathml.css',
               'css/mediaControls.css',
               'css/mediaControlsAndroid.css',
               'css/fullscreen.css',
@@ -642,10 +641,6 @@
             'css/makegrammar.pl',
             '--outputDir',
             '<(SHARED_INTERMEDIATE_DIR)/webkit/',
-            '--extraDefines',
-            '<(feature_defines)',
-            '--preprocessOnly',
-            '<@(preprocessor)',
             '<@(_inputs)',
           ],
         },
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
diff --git a/Source/core/dom/CheckedRadioButtons.cpp b/Source/core/dom/CheckedRadioButtons.cpp
index a628b43..d8d7a46 100644
--- a/Source/core/dom/CheckedRadioButtons.cpp
+++ b/Source/core/dom/CheckedRadioButtons.cpp
@@ -260,7 +260,7 @@
     if (it->value->isEmpty()) {
         // FIXME: We may skip deallocating the empty RadioButtonGroup for
         // performance improvement. If we do so, we need to change the key type
-        // of m_nameToGroupMap from AtomicStringImpl* to RefPtr<AtomicStringImpl>.
+        // of m_nameToGroupMap from StringImpl* to AtomicString.
         m_nameToGroupMap->remove(it);
         if (m_nameToGroupMap->isEmpty())
             m_nameToGroupMap.clear();
diff --git a/Source/core/dom/CheckedRadioButtons.h b/Source/core/dom/CheckedRadioButtons.h
index 32bb5fe..6a1585b 100644
--- a/Source/core/dom/CheckedRadioButtons.h
+++ b/Source/core/dom/CheckedRadioButtons.h
@@ -24,6 +24,7 @@
 #include "wtf/Forward.h"
 #include "wtf/HashMap.h"
 #include "wtf/OwnPtr.h"
+#include "wtf/text/StringHash.h"
 
 namespace WebCore {
 
@@ -44,7 +45,7 @@
     bool isInRequiredGroup(HTMLInputElement*) const;
 
 private:
-    typedef HashMap<AtomicStringImpl*, OwnPtr<RadioButtonGroup> > NameToGroupMap;
+    typedef HashMap<StringImpl*, OwnPtr<RadioButtonGroup> > NameToGroupMap;
     OwnPtr<NameToGroupMap> m_nameToGroupMap;
 };
 
diff --git a/Source/core/dom/CustomElement.cpp b/Source/core/dom/CustomElement.cpp
new file mode 100644
index 0000000..de0b688
--- /dev/null
+++ b/Source/core/dom/CustomElement.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2013 Google 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.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ *    may be used to endorse or promote products derived from this
+ *    software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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/dom/CustomElement.h"
+
+#include "core/dom/CustomElementCallbackScheduler.h"
+#include "core/dom/CustomElementRegistrationContext.h"
+#include "core/dom/Element.h"
+
+namespace WebCore {
+
+void CustomElement::define(Element* element, PassRefPtr<CustomElementDefinition> passDefinition)
+{
+    RefPtr<CustomElementDefinition> definition(passDefinition);
+    element->setCustomElementState(Element::Defined);
+    definitions().add(element, definition);
+    CustomElementCallbackScheduler::scheduleCreatedCallback(definition->callbacks(), element);
+}
+
+void CustomElement::attributeDidChange(Element* element, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue)
+{
+    ASSERT(element->customElementState() == Element::Upgraded);
+    CustomElementCallbackScheduler::scheduleAttributeChangedCallback(definitions().get(element)->callbacks(), element, name, oldValue, newValue);
+}
+
+void CustomElement::didEnterDocument(Element* element)
+{
+    ASSERT(element->customElementState() == Element::Upgraded);
+    CustomElementCallbackScheduler::scheduleEnteredDocumentCallback(definitions().get(element)->callbacks(), element);
+}
+
+void CustomElement::didLeaveDocument(Element* element)
+{
+    ASSERT(element->customElementState() == Element::Upgraded);
+    CustomElementCallbackScheduler::scheduleLeftDocumentCallback(definitions().get(element)->callbacks(), element);
+}
+
+void CustomElement::wasDestroyed(Element* element)
+{
+    definitions().remove(element);
+
+    // FIXME: Elements should only depend on their document's
+    // registration context at creation; maintain a mapping to
+    // registration context for upgrade candidates.
+    if (element->document() && element->document()->registrationContext())
+        element->document()->registrationContext()->customElementWasDestroyed(element);
+}
+
+void CustomElement::DefinitionMap::add(Element* element, PassRefPtr<CustomElementDefinition> definition)
+{
+    ASSERT(definition.get());
+    DefinitionMap::ElementDefinitionHashMap::AddResult result = m_definitions.add(element, definition);
+    ASSERT(result.isNewEntry);
+}
+
+void CustomElement::DefinitionMap::remove(Element* element)
+{
+    m_definitions.remove(element);
+}
+
+CustomElementDefinition* CustomElement::DefinitionMap::get(Element* element)
+{
+    DefinitionMap::ElementDefinitionHashMap::const_iterator it = m_definitions.find(element);
+    ASSERT(it != m_definitions.end());
+    return it->value.get();
+}
+
+CustomElement::DefinitionMap& CustomElement::definitions()
+{
+    DEFINE_STATIC_LOCAL(DefinitionMap, definitionMap, ());
+    return definitionMap;
+}
+
+} // namespace WebCore
diff --git a/Source/core/dom/CustomElement.h b/Source/core/dom/CustomElement.h
new file mode 100644
index 0000000..21bc28c
--- /dev/null
+++ b/Source/core/dom/CustomElement.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2013 Google 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.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ *    may be used to endorse or promote products derived from this
+ *    software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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.
+ */
+
+#ifndef CustomElement_h
+#define CustomElement_h
+
+#include "core/dom/CustomElementDefinition.h"
+#include "wtf/HashMap.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
+#include "wtf/text/AtomicString.h"
+
+namespace WebCore {
+
+class Element;
+
+class CustomElement {
+public:
+    static void define(Element*, PassRefPtr<CustomElementDefinition>);
+    static void attributeDidChange(Element*, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue);
+    static void didEnterDocument(Element*);
+    static void didLeaveDocument(Element*);
+    static void wasDestroyed(Element*);
+
+private:
+    CustomElement();
+
+    class DefinitionMap {
+        WTF_MAKE_NONCOPYABLE(DefinitionMap);
+    public:
+        DefinitionMap() { }
+        ~DefinitionMap() { }
+
+        void add(Element*, PassRefPtr<CustomElementDefinition>);
+        void remove(Element*);
+        CustomElementDefinition* get(Element*);
+
+    private:
+        typedef HashMap<Element*, RefPtr<CustomElementDefinition> > ElementDefinitionHashMap;
+        ElementDefinitionHashMap m_definitions;
+    };
+
+    static DefinitionMap& definitions();
+};
+
+}
+
+#endif // CustomElement_h
diff --git a/Source/core/dom/CustomElementRegistrationContext.cpp b/Source/core/dom/CustomElementRegistrationContext.cpp
index 4ed6abf..c3a0cad 100644
--- a/Source/core/dom/CustomElementRegistrationContext.cpp
+++ b/Source/core/dom/CustomElementRegistrationContext.cpp
@@ -34,7 +34,7 @@
 #include "HTMLNames.h"
 #include "MathMLNames.h"
 #include "SVGNames.h"
-#include "core/dom/CustomElementCallbackScheduler.h"
+#include "core/dom/CustomElement.h"
 #include "core/dom/CustomElementDefinition.h"
 #include "core/dom/CustomElementRegistry.h"
 #include "core/dom/CustomElementUpgradeCandidateMap.h"
@@ -56,10 +56,6 @@
 
     virtual PassRefPtr<Element> createCustomTagElement(Document*, const QualifiedName&) OVERRIDE;
     virtual void didGiveTypeExtension(Element*) OVERRIDE { }
-
-    virtual void customElementAttributeDidChange(Element*, const AtomicString&, const AtomicString&, const AtomicString&) OVERRIDE { }
-    virtual void customElementDidEnterDocument(Element*) OVERRIDE { }
-    virtual void customElementDidLeaveDocument(Element*) OVERRIDE { }
 };
 
 PassRefPtr<Element> NullRegistrationContext::createCustomTagElement(Document* document, const QualifiedName& tagName)
@@ -96,18 +92,13 @@
     virtual PassRefPtr<Element> createCustomTagElement(Document*, const QualifiedName&) OVERRIDE;
     virtual void didGiveTypeExtension(Element*) OVERRIDE;
 
-    virtual void customElementAttributeDidChange(Element*, const AtomicString&, const AtomicString&, const AtomicString&) OVERRIDE;
-    virtual void customElementDidEnterDocument(Element*) OVERRIDE;
-    virtual void customElementDidLeaveDocument(Element*) OVERRIDE;
-    virtual void customElementIsBeingDestroyed(Element*) OVERRIDE;
+    virtual void customElementWasDestroyed(Element*) OVERRIDE;
 
 private:
     void resolve(Element*);
     void didResolveElement(CustomElementDefinition*, Element*);
     void didCreateUnresolvedElement(const CustomElementDescriptor&, Element*);
 
-    CustomElementDefinition* definitionFor(Element*) const;
-
     CustomElementRegistry m_registry;
 
     // Element creation
@@ -166,8 +157,7 @@
 
 void ActiveRegistrationContext::didResolveElement(CustomElementDefinition* definition, Element* element)
 {
-    element->setCustomElementState(Element::Defined);
-    CustomElementCallbackScheduler::scheduleCreatedCallback(definition->callbacks(), element);
+    CustomElement::define(element, definition);
 }
 
 void ActiveRegistrationContext::didCreateUnresolvedElement(const CustomElementDescriptor& descriptor, Element* element)
@@ -176,39 +166,10 @@
     m_candidates.add(descriptor, element);
 }
 
-CustomElementDefinition* ActiveRegistrationContext::definitionFor(Element* element) const
-{
-    ASSERT(element->customElementState() == Element::Defined || element->customElementState() == Element::Upgraded);
-    ASSERT(element->document()->registrationContext() == this);
-    const CustomElementDescriptor& descriptor = describe(element);
-    return m_registry.find(descriptor);
-}
-
-void ActiveRegistrationContext::customElementAttributeDidChange(Element* element, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue)
-{
-    ASSERT(element->customElementState() == Element::Upgraded);
-    CustomElementDefinition* definition = definitionFor(element);
-    CustomElementCallbackScheduler::scheduleAttributeChangedCallback(definition->callbacks(), element, name, oldValue, newValue);
-}
-
-void ActiveRegistrationContext::customElementDidEnterDocument(Element* element)
-{
-    ASSERT(element->customElementState() == Element::Upgraded);
-    CustomElementDefinition* definition = definitionFor(element);
-    CustomElementCallbackScheduler::scheduleEnteredDocumentCallback(definition->callbacks(), element);
-}
-
-void ActiveRegistrationContext::customElementDidLeaveDocument(Element* element)
-{
-    ASSERT(element->customElementState() == Element::Upgraded);
-    CustomElementDefinition* definition = definitionFor(element);
-    CustomElementCallbackScheduler::scheduleLeftDocumentCallback(definition->callbacks(), element);
-}
-
-void ActiveRegistrationContext::customElementIsBeingDestroyed(Element* element)
+void ActiveRegistrationContext::customElementWasDestroyed(Element* element)
 {
     m_candidates.remove(element);
-    CustomElementRegistrationContext::customElementIsBeingDestroyed(element);
+    CustomElementRegistrationContext::customElementWasDestroyed(element);
 }
 
 PassRefPtr<CustomElementRegistrationContext> CustomElementRegistrationContext::create()
@@ -276,7 +237,7 @@
     element->document()->registrationContext()->didGiveTypeExtension(element);
 }
 
-void CustomElementRegistrationContext::customElementIsBeingDestroyed(Element* element)
+void CustomElementRegistrationContext::customElementWasDestroyed(Element* element)
 {
     ASSERT(element->isCustomElement());
     typeExtensionMap()->remove(element);
diff --git a/Source/core/dom/CustomElementRegistrationContext.h b/Source/core/dom/CustomElementRegistrationContext.h
index e909255..c0c89da 100644
--- a/Source/core/dom/CustomElementRegistrationContext.h
+++ b/Source/core/dom/CustomElementRegistrationContext.h
@@ -54,8 +54,11 @@
     virtual ~CustomElementRegistrationContext() { }
 
     // Model
+    // FIXME: Move this to CustomElementRegistry
     static bool isValidTypeName(const AtomicString& type);
+    // FIXME: Move this to CustomElement
     static bool isCustomTagName(const AtomicString& localName);
+    // FIXME: Privatize this when CustomElementWrapper uses the definition map.
     static CustomElementDescriptor describe(Element*);
 
     // Definitions
@@ -67,10 +70,7 @@
     static void setTypeExtension(Element*, const AtomicString& type);
 
     // Instance lifecycle
-    virtual void customElementAttributeDidChange(Element*, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue) = 0;
-    virtual void customElementDidEnterDocument(Element*) = 0;
-    virtual void customElementDidLeaveDocument(Element*) = 0;
-    virtual void customElementIsBeingDestroyed(Element*);
+    virtual void customElementWasDestroyed(Element*);
 
 protected:
     CustomElementRegistrationContext() { }
diff --git a/Source/core/dom/DecodedDataDocumentParser.cpp b/Source/core/dom/DecodedDataDocumentParser.cpp
index 2f76a28..610d44e 100644
--- a/Source/core/dom/DecodedDataDocumentParser.cpp
+++ b/Source/core/dom/DecodedDataDocumentParser.cpp
@@ -27,10 +27,58 @@
 #include "core/dom/DecodedDataDocumentParser.h"
 
 #include "core/dom/Document.h"
+#include "core/dom/Element.h"
 #include "core/loader/TextResourceDecoder.h"
+#include "wtf/text/TextEncodingRegistry.h"
 
 namespace WebCore {
 
+namespace {
+
+class TitleEncodingFixer {
+public:
+    explicit TitleEncodingFixer(Document* document)
+        : m_document(document)
+        , m_firstEncoding(document->decoder()->encoding())
+    {
+    }
+
+    // It's possible for the encoding of the document to change while we're decoding
+    // data. That can only occur while we're processing the <head> portion of the
+    // document. There isn't much user-visible content in the <head>, but there is
+    // the <title> element. This function detects that situation and re-decodes the
+    // document's title so that the user doesn't see an incorrectly decoded title
+    // in the title bar.
+    inline void fixTitleEncodingIfNeeded()
+    {
+        if (m_firstEncoding == m_document->decoder()->encoding())
+            return; // In the common case, the encoding doesn't change and there isn't any work to do.
+        fixTitleEncoding();
+    }
+
+private:
+    void fixTitleEncoding();
+
+    Document* m_document;
+    WTF::TextEncoding m_firstEncoding;
+};
+
+void TitleEncodingFixer::fixTitleEncoding()
+{
+    RefPtr<Element> titleElement = m_document->titleElement();
+    if (!titleElement
+        || titleElement->firstElementChild()
+        || m_firstEncoding != Latin1Encoding()
+        || !titleElement->textContent().containsOnlyLatin1())
+        return; // Either we don't have a title yet or something bizzare as happened and we give up.
+    CString originalBytes = titleElement->textContent().latin1();
+    OwnPtr<TextCodec> codec = newTextCodec(m_document->decoder()->encoding());
+    String correctlyDecodedTitle = codec->decode(originalBytes.data(), originalBytes.length(), true);
+    titleElement->setTextContent(correctlyDecodedTitle, IGNORE_EXCEPTION);
+}
+
+}
+
 DecodedDataDocumentParser::DecodedDataDocumentParser(Document* document)
     : DocumentParser(document)
 {
@@ -41,7 +89,12 @@
     if (!length)
         return 0;
 
+    TitleEncodingFixer encodingFixer(document());
+
     String decoded = document()->decoder()->decode(data, length);
+
+    encodingFixer.fixTitleEncodingIfNeeded();
+
     if (decoded.isEmpty())
         return 0;
 
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index d4b4fc7..42aaace 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -398,7 +398,6 @@
     , m_inStyleRecalc(false)
     , m_closeAfterStyleRecalc(false)
     , m_gotoAnchorNeededAfterStylesheetsLoad(false)
-    , m_pendingStyleRecalcShouldForce(false)
     , m_containsValidityStyleRules(false)
     , m_updateFocusAppearanceRestoresSelection(false)
     , m_ignoreDestructiveWriteCount(0)
@@ -1133,7 +1132,7 @@
     m_contentLanguage = language;
 
     // Document's style depends on the content language.
-    scheduleForcedStyleRecalc();
+    setNeedsStyleRecalc();
 }
 
 void Document::setXMLVersion(const String& version, ExceptionCode& ec)
@@ -1317,7 +1316,7 @@
     else if (!m_titleElement) {
         if (HTMLElement* headElement = head()) {
             m_titleElement = createElement(titleTag, false);
-            headElement->appendChild(m_titleElement, ASSERT_NO_EXCEPTION);
+            headElement->appendChild(m_titleElement, ASSERT_NO_EXCEPTION, AttachLazily);
         }
     }
 
@@ -1529,12 +1528,6 @@
     return TreeWalker::create(root, whatToShow, filter);
 }
 
-void Document::scheduleForcedStyleRecalc()
-{
-    m_pendingStyleRecalcShouldForce = true;
-    scheduleStyleRecalc();
-}
-
 void Document::scheduleStyleRecalc()
 {
     if (shouldDisplaySeamlesslyWithParent()) {
@@ -1547,7 +1540,7 @@
     if (m_styleRecalcTimer.isActive())
         return;
 
-    ASSERT(childNeedsStyleRecalc() || m_pendingStyleRecalcShouldForce);
+    ASSERT(needsStyleRecalc() || childNeedsStyleRecalc());
 
     m_styleRecalcTimer.startOneShot(0);
 
@@ -1556,10 +1549,8 @@
 
 void Document::unscheduleStyleRecalc()
 {
-    ASSERT(!childNeedsStyleRecalc());
-
+    ASSERT(!attached() || (!needsStyleRecalc() && !childNeedsStyleRecalc()));
     m_styleRecalcTimer.stop();
-    m_pendingStyleRecalcShouldForce = false;
 }
 
 bool Document::hasPendingStyleRecalc() const
@@ -1569,7 +1560,7 @@
 
 bool Document::hasPendingForcedStyleRecalc() const
 {
-    return m_styleRecalcTimer.isActive() && m_pendingStyleRecalcShouldForce;
+    return hasPendingStyleRecalc() && styleChangeType() == SubtreeStyleChange;
 }
 
 void Document::styleRecalcTimerFired(Timer<Document>*)
@@ -1577,11 +1568,6 @@
     updateStyleIfNeeded();
 }
 
-bool Document::childNeedsAndNotInStyleRecalc()
-{
-    return childNeedsStyleRecalc() && !m_inStyleRecalc;
-}
-
 void Document::recalcStyle(StyleChange change)
 {
     // we should not enter style recalc while painting
@@ -1625,7 +1611,7 @@
         if (!renderer() || !renderArena())
             goto bailOut;
 
-        if (m_pendingStyleRecalcShouldForce)
+        if (styleChangeType() == SubtreeStyleChange)
             change = Force;
 
         // Recalculating the root style (on the document) is not needed in the common case.
@@ -1655,6 +1641,11 @@
         clearChildNeedsStyleRecalc();
         unscheduleStyleRecalc();
 
+        // FIXME: SVG <use> element can schedule a recalc in the middle of an already running one.
+        // See DocumentStyleSheetCollection::updateActiveStyleSheets.
+        if (m_styleSheetCollection->needsUpdateActiveStylesheetsOnStyleRecalc())
+            setNeedsStyleRecalc();
+
         m_inStyleRecalc = false;
 
         // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc.
@@ -1690,7 +1681,7 @@
     ASSERT(isMainThread());
     ASSERT(!view() || (!view()->isInLayout() && !view()->isPainting()));
 
-    if (!m_pendingStyleRecalcShouldForce && !childNeedsStyleRecalc())
+    if (!needsStyleRecalc() && !childNeedsStyleRecalc())
         return;
 
     AnimationUpdateBlock animationUpdateBlock(m_frame ? m_frame->animation() : 0);
@@ -2012,7 +2003,7 @@
     // FIXME: How is possible to not have a renderer here?
     if (renderer())
         renderer()->style()->setRTLOrdering(VisualOrder);
-    scheduleForcedStyleRecalc();
+    setNeedsStyleRecalc();
 }
 
 PassRefPtr<DocumentParser> Document::createParser()
@@ -2044,6 +2035,7 @@
         setURL(ownerDocument->url());
         m_cookieURL = ownerDocument->cookieURL();
         setSecurityOrigin(ownerDocument->securityOrigin());
+        InspectorInstrumentation::childDocumentOpened(this);
     }
 
     if (m_frame) {
@@ -2637,7 +2629,16 @@
         parseDNSPrefetchControlHeader(content);
     else if (equalIgnoringCase(equiv, "x-frame-options"))
         processHttpEquivXFrameOptions(content);
-    else if (equalIgnoringCase(equiv, "content-security-policy"))
+    else if (equalIgnoringCase(equiv, "content-security-policy")
+        || equalIgnoringCase(equiv, "content-security-policy-report-only")
+        || equalIgnoringCase(equiv, "x-webkit-csp")
+        || equalIgnoringCase(equiv, "x-webkit-csp-report-only"))
+        processHttpEquivContentSecurityPolicy(equiv, content);
+}
+
+void Document::processHttpEquivContentSecurityPolicy(const String& equiv, const String& content)
+{
+    if (equalIgnoringCase(equiv, "content-security-policy"))
         contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy::Enforce);
     else if (equalIgnoringCase(equiv, "content-security-policy-report-only"))
         contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy::Report);
@@ -2645,6 +2646,8 @@
         contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy::PrefixedEnforce);
     else if (equalIgnoringCase(equiv, "x-webkit-csp-report-only"))
         contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy::PrefixedReport);
+    else
+        ASSERT_NOT_REACHED();
 }
 
 void Document::processHttpEquivDefaultStyle(const String& content)
@@ -2995,7 +2998,7 @@
     bool needsRecalc = m_styleSheetCollection->updateActiveStyleSheets(updateMode);
 
     if (updateType >= DeferRecalcStyle) {
-        scheduleForcedStyleRecalc();
+        setNeedsStyleRecalc();
         return;
     }
 
@@ -3924,7 +3927,7 @@
 {
     m_designMode = value;
     for (Frame* frame = m_frame; frame && frame->document(); frame = frame->tree()->traverseNext(m_frame))
-        frame->document()->scheduleForcedStyleRecalc();
+        frame->document()->setNeedsStyleRecalc();
 }
 
 Document::InheritedBool Document::getDesignMode() const
@@ -4077,6 +4080,11 @@
     if (!m_documentTiming.domContentLoadedEventEnd)
         m_documentTiming.domContentLoadedEventEnd = monotonicallyIncreasingTime();
 
+    // The loader's finishedParsing() method may invoke script that causes this object to
+    // be dereferenced (when this document is in an iframe and the onload causes the iframe's src to change).
+    // Keep it alive until we are done.
+    RefPtr<Document> protect(this);
+
     if (RefPtr<Frame> f = frame()) {
         // FrameLoader::finishedParsing() might end up calling Document::implicitClose() if all
         // resource loads are complete. HTMLObjectElements can start loading their resources from
diff --git a/Source/core/dom/Document.h b/Source/core/dom/Document.h
index cfd2f8f..3c47aa6 100644
--- a/Source/core/dom/Document.h
+++ b/Source/core/dom/Document.h
@@ -482,7 +482,6 @@
     PassRefPtr<Text> createEditingTextNode(const String&);
 
     void recalcStyle(StyleChange = NoChange);
-    bool childNeedsAndNotInStyleRecalc();
     void updateStyleIfNeeded();
     void updateStyleForNodeIfNeeded(Node*);
     void updateLayout();
@@ -654,8 +653,7 @@
     // Updates for :target (CSS3 selector).
     void setCSSTarget(Element*);
     Element* cssTarget() const { return m_cssTarget; }
-    
-    void scheduleForcedStyleRecalc();
+
     void scheduleStyleRecalc();
     void unscheduleStyleRecalc();
     bool hasPendingStyleRecalc() const;
@@ -754,6 +752,7 @@
     String title() const { return m_title.string(); }
     void setTitle(const String&);
 
+    Element* titleElement() const { return m_titleElement.get(); }
     void setTitleElement(const StringWithDirection&, Element* titleElement);
     void removeTitle(Element* titleElement);
 
@@ -1112,6 +1111,7 @@
     void processHttpEquivRefresh(const String& content);
     void processHttpEquivSetCookie(const String& content);
     void processHttpEquivXFrameOptions(const String& content);
+    void processHttpEquivContentSecurityPolicy(const String& equiv, const String& content);
 
     Timer<Document> m_styleResolverThrowawayTimer;
     double m_lastStyleResolverAccessTime;
@@ -1198,9 +1198,8 @@
     bool m_visuallyOrdered;
     ReadyState m_readyState;
     bool m_bParsing;
-    
+
     Timer<Document> m_styleRecalcTimer;
-    bool m_pendingStyleRecalcShouldForce;
     bool m_inStyleRecalc;
     bool m_closeAfterStyleRecalc;
 
diff --git a/Source/core/dom/DocumentOrderedMap.cpp b/Source/core/dom/DocumentOrderedMap.cpp
index 9f62cdb..76f236a 100644
--- a/Source/core/dom/DocumentOrderedMap.cpp
+++ b/Source/core/dom/DocumentOrderedMap.cpp
@@ -42,22 +42,22 @@
 
 using namespace HTMLNames;
 
-inline bool keyMatchesId(AtomicStringImpl* key, Element* element)
+inline bool keyMatchesId(StringImpl* key, Element* element)
 {
     return element->getIdAttribute().impl() == key;
 }
 
-inline bool keyMatchesMapName(AtomicStringImpl* key, Element* element)
+inline bool keyMatchesMapName(StringImpl* key, Element* element)
 {
     return element->hasTagName(mapTag) && toHTMLMapElement(element)->getName().impl() == key;
 }
 
-inline bool keyMatchesLowercasedMapName(AtomicStringImpl* key, Element* element)
+inline bool keyMatchesLowercasedMapName(StringImpl* key, Element* element)
 {
     return element->hasTagName(mapTag) && toHTMLMapElement(element)->getName().lower().impl() == key;
 }
 
-inline bool keyMatchesLabelForAttribute(AtomicStringImpl* key, Element* element)
+inline bool keyMatchesLabelForAttribute(StringImpl* key, Element* element)
 {
     return isHTMLLabelElement(element) && element->getAttribute(forAttr).impl() == key;
 }
@@ -68,7 +68,7 @@
     m_duplicateCounts.clear();
 }
 
-void DocumentOrderedMap::add(AtomicStringImpl* key, Element* element)
+void DocumentOrderedMap::add(StringImpl* key, Element* element)
 {
     ASSERT(key);
     ASSERT(element);
@@ -98,7 +98,7 @@
     m_duplicateCounts.add(key);
 }
 
-void DocumentOrderedMap::remove(AtomicStringImpl* key, Element* element)
+void DocumentOrderedMap::remove(StringImpl* key, Element* element)
 {
     ASSERT(key);
     ASSERT(element);
@@ -111,8 +111,8 @@
         m_duplicateCounts.remove(key);
 }
 
-template<bool keyMatches(AtomicStringImpl*, Element*)>
-inline Element* DocumentOrderedMap::get(AtomicStringImpl* key, const TreeScope* scope) const
+template<bool keyMatches(StringImpl*, Element*)>
+inline Element* DocumentOrderedMap::get(StringImpl* key, const TreeScope* scope) const
 {
     ASSERT(key);
     ASSERT(scope);
@@ -138,22 +138,22 @@
     return 0;
 }
 
-Element* DocumentOrderedMap::getElementById(AtomicStringImpl* key, const TreeScope* scope) const
+Element* DocumentOrderedMap::getElementById(StringImpl* key, const TreeScope* scope) const
 {
     return get<keyMatchesId>(key, scope);
 }
 
-Element* DocumentOrderedMap::getElementByMapName(AtomicStringImpl* key, const TreeScope* scope) const
+Element* DocumentOrderedMap::getElementByMapName(StringImpl* key, const TreeScope* scope) const
 {
     return get<keyMatchesMapName>(key, scope);
 }
 
-Element* DocumentOrderedMap::getElementByLowercasedMapName(AtomicStringImpl* key, const TreeScope* scope) const
+Element* DocumentOrderedMap::getElementByLowercasedMapName(StringImpl* key, const TreeScope* scope) const
 {
     return get<keyMatchesLowercasedMapName>(key, scope);
 }
 
-Element* DocumentOrderedMap::getElementByLabelForAttribute(AtomicStringImpl* key, const TreeScope* scope) const
+Element* DocumentOrderedMap::getElementByLabelForAttribute(StringImpl* key, const TreeScope* scope) const
 {
     return get<keyMatchesLabelForAttribute>(key, scope);
 }
diff --git a/Source/core/dom/DocumentOrderedMap.h b/Source/core/dom/DocumentOrderedMap.h
index 9fe076a..b6fc8e0 100644
--- a/Source/core/dom/DocumentOrderedMap.h
+++ b/Source/core/dom/DocumentOrderedMap.h
@@ -33,7 +33,7 @@
 
 #include "wtf/HashCountedSet.h"
 #include "wtf/HashMap.h"
-#include "wtf/text/AtomicStringImpl.h"
+#include "wtf/text/StringImpl.h"
 
 namespace WebCore {
 
@@ -42,38 +42,38 @@
 
 class DocumentOrderedMap {
 public:
-    void add(AtomicStringImpl*, Element*);
-    void remove(AtomicStringImpl*, Element*);
+    void add(StringImpl*, Element*);
+    void remove(StringImpl*, Element*);
     void clear();
 
-    bool contains(AtomicStringImpl*) const;
-    bool containsMultiple(AtomicStringImpl*) const;
+    bool contains(StringImpl*) const;
+    bool containsMultiple(StringImpl*) const;
     // concrete instantiations of the get<>() method template
-    Element* getElementById(AtomicStringImpl*, const TreeScope*) const;
-    Element* getElementByMapName(AtomicStringImpl*, const TreeScope*) const;
-    Element* getElementByLowercasedMapName(AtomicStringImpl*, const TreeScope*) const;
-    Element* getElementByLabelForAttribute(AtomicStringImpl*, const TreeScope*) const;
+    Element* getElementById(StringImpl*, const TreeScope*) const;
+    Element* getElementByMapName(StringImpl*, const TreeScope*) const;
+    Element* getElementByLowercasedMapName(StringImpl*, const TreeScope*) const;
+    Element* getElementByLabelForAttribute(StringImpl*, const TreeScope*) const;
 
     void checkConsistency() const;
 
 private:
-    template<bool keyMatches(AtomicStringImpl*, Element*)> Element* get(AtomicStringImpl*, const TreeScope*) const;
+    template<bool keyMatches(StringImpl*, Element*)> Element* get(StringImpl*, const TreeScope*) const;
 
-    typedef HashMap<AtomicStringImpl*, Element*> Map;
+    typedef HashMap<StringImpl*, Element*> Map;
 
     // We maintain the invariant that m_duplicateCounts is the count of all elements with a given key
     // excluding the one referenced in m_map, if any. This means it one less than the total count
     // when the first node with a given key is cached, otherwise the same as the total count.
     mutable Map m_map;
-    mutable HashCountedSet<AtomicStringImpl*> m_duplicateCounts;
+    mutable HashCountedSet<StringImpl*> m_duplicateCounts;
 };
 
-inline bool DocumentOrderedMap::contains(AtomicStringImpl* id) const
+inline bool DocumentOrderedMap::contains(StringImpl* id) const
 {
     return m_map.contains(id) || m_duplicateCounts.contains(id);
 }
 
-inline bool DocumentOrderedMap::containsMultiple(AtomicStringImpl* id) const
+inline bool DocumentOrderedMap::containsMultiple(StringImpl* id) const
 {
     return m_duplicateCounts.contains(id);
 }
diff --git a/Source/core/dom/DocumentStyleSheetCollection.cpp b/Source/core/dom/DocumentStyleSheetCollection.cpp
index e2088d8..d45931c 100644
--- a/Source/core/dom/DocumentStyleSheetCollection.cpp
+++ b/Source/core/dom/DocumentStyleSheetCollection.cpp
@@ -254,7 +254,6 @@
         // https://bugs.webkit.org/show_bug.cgi?id=54344
         // FIXME: This should be fixed in SVG and the call site replaced by ASSERT(!m_inStyleRecalc).
         m_needsUpdateActiveStylesheetsOnStyleRecalc = true;
-        m_document->scheduleForcedStyleRecalc();
         return false;
 
     }
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 7affb64..dc64b8d 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -33,6 +33,7 @@
 #include "SVGNames.h"
 #include "XMLNames.h"
 #include "core/accessibility/AXObjectCache.h"
+#include "core/animation/DocumentTimeline.h"
 #include "core/css/CSSParser.h"
 #include "core/css/CSSStyleSheet.h"
 #include "core/css/CSSValuePool.h"
@@ -43,6 +44,7 @@
 #include "core/dom/Attribute.h"
 #include "core/dom/ClientRect.h"
 #include "core/dom/ClientRectList.h"
+#include "core/dom/CustomElement.h"
 #include "core/dom/CustomElementRegistrationContext.h"
 #include "core/dom/DatasetDOMStringMap.h"
 #include "core/dom/Document.h"
@@ -208,8 +210,8 @@
         data->clearShadow();
     }
 
-    if (isCustomElement() && document() && document()->registrationContext())
-        document()->registrationContext()->customElementIsBeingDestroyed(this);
+    if (isCustomElement())
+        CustomElement::wasDestroyed(this);
 
     if (hasSyntheticAttrChildNodes())
         detachAllAttrNodesFromElement();
@@ -373,34 +375,31 @@
     return rareData->attributeMap();
 }
 
-void Element::addActiveAnimation(Animation* animation)
+ActiveAnimations* Element::activeAnimations() const
 {
-    ElementRareData* rareData = ensureElementRareData();
-    if (!rareData->activeAnimations())
-        rareData->setActiveAnimations(adoptPtr(new Vector<Animation*>));
-    rareData->activeAnimations()->append(animation);
+    if (hasActiveAnimations())
+        return elementRareData()->activeAnimations();
+    return 0;
 }
 
-void Element::removeActiveAnimation(Animation* animation)
+ActiveAnimations* Element::ensureActiveAnimations()
 {
-    ElementRareData* rareData = elementRareData();
-    ASSERT(rareData);
-    size_t position = rareData->activeAnimations()->find(animation);
-    ASSERT(position != notFound);
-    rareData->activeAnimations()->remove(position);
+    ElementRareData* rareData = ensureElementRareData();
+    if (!elementRareData()->activeAnimations())
+        rareData->setActiveAnimations(adoptPtr(new ActiveAnimations()));
+    return rareData->activeAnimations();
 }
 
 bool Element::hasActiveAnimations() const
 {
-    return hasRareData() && elementRareData()->activeAnimations()
-        && elementRareData()->activeAnimations()->size();
-}
+    if (!RuntimeEnabledFeatures::webAnimationsEnabled())
+        return false;
 
-Vector<Animation*>* Element::activeAnimations() const
-{
-    if (!elementRareData())
-        return 0;
-    return elementRareData()->activeAnimations();
+    if (!hasRareData())
+        return false;
+
+    ActiveAnimations* activeAnimations = elementRareData()->activeAnimations();
+    return activeAnimations && !activeAnimations->isEmpty();
 }
 
 Node::NodeType Element::nodeType() const
@@ -1200,37 +1199,6 @@
     return RenderObject::createObject(this, style);
 }
 
-#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
-bool Element::isDateTimeEditElement() const
-{
-    return false;
-}
-
-bool Element::isDateTimeFieldElement() const
-{
-    return false;
-}
-
-bool Element::isPickerIndicatorElement() const
-{
-    return false;
-}
-#endif
-
-bool Element::isClearButtonElement() const
-{
-    return false;
-}
-
-bool Element::wasChangedSinceLastFormControlChangeEvent() const
-{
-    return false;
-}
-
-void Element::setChangedSinceLastFormControlChangeEvent(bool)
-{
-}
-
 bool Element::isInert() const
 {
     const Element* dialog = document()->activeModalDialog();
@@ -1265,7 +1233,7 @@
         return InsertionDone;
 
     if (isUpgradedCustomElement())
-        document()->registrationContext()->customElementDidEnterDocument(this);
+        CustomElement::didEnterDocument(this);
 
     const AtomicString& idValue = getIdAttribute();
     if (!idValue.isNull())
@@ -1326,14 +1294,14 @@
         if (hasPendingResources())
             document()->accessSVGExtensions()->removeElementFromPendingResources(this);
 
-        if (isUpgradedCustomElement() && document()->registrationContext())
-            document()->registrationContext()->customElementDidLeaveDocument(this);
+        if (isUpgradedCustomElement())
+            CustomElement::didLeaveDocument(this);
     }
 }
 
 void Element::createRendererIfNeeded(const AttachContext& context)
 {
-    NodeRenderingContext(this, context).createRendererForElementIfNeeded();
+    NodeRenderingContext(this, context.resolvedStyle).createRendererForElementIfNeeded();
 }
 
 void Element::attach(const AttachContext& context)
@@ -1464,12 +1432,12 @@
         willRecalcStyle(change);
 
     // Ref currentStyle in case it would otherwise be deleted when setting the new style in the renderer.
-    RefPtr<RenderStyle> currentStyle(renderStyle());
-    bool hasParentStyle = parentNodeForRenderingAndStyle() ? static_cast<bool>(parentNodeForRenderingAndStyle()->renderStyle()) : false;
+    RefPtr<RenderStyle> currentStyle = renderStyle();
+    bool hasParentStyle = static_cast<bool>(parentRenderStyle());
     bool hasDirectAdjacentRules = childrenAffectedByDirectAdjacentRules();
     bool hasIndirectAdjacentRules = childrenAffectedByForwardPositionalRules();
 
-    if ((change > NoChange || needsStyleRecalc())) {
+    if (change > NoChange || needsStyleRecalc()) {
         if (hasRareData())
             elementRareData()->resetComputedStyle();
     }
@@ -1528,11 +1496,12 @@
     }
     StyleResolverParentPusher parentPusher(this);
 
-    // FIXME: This does not care about sibling combinators. Will be necessary in XBL2 world.
     if (ElementShadow* shadow = this->shadow()) {
-        if (shouldRecalcStyle(change, shadow)) {
-            parentPusher.push();
-            shadow->recalcStyle(change);
+        for (ShadowRoot* root = shadow->youngestShadowRoot(); root; root = root->olderShadowRoot()) {
+            if (shouldRecalcStyle(change, root)) {
+                parentPusher.push();
+                root->recalcStyle(change);
+            }
         }
     }
 
@@ -1673,7 +1642,7 @@
     return false;
 }
 
-static void checkForEmptyStyleChange(Element* element, RenderStyle* style)
+static void inline checkForEmptyStyleChange(Element* element, RenderStyle* style)
 {
     if (!style && !element->styleAffectedByEmpty())
         return;
@@ -1685,80 +1654,74 @@
 static void checkForSiblingStyleChanges(Element* e, RenderStyle* style, bool finishedParsingCallback,
                                         Node* beforeChange, Node* afterChange, int childCountDelta)
 {
+    if (!e->attached() || e->document()->hasPendingForcedStyleRecalc() || e->styleChangeType() == SubtreeStyleChange)
+        return;
+
     // :empty selector.
     checkForEmptyStyleChange(e, style);
 
     if (!style || (e->needsStyleRecalc() && e->childrenAffectedByPositionalRules()))
         return;
 
-    // :first-child.  In the parser callback case, we don't have to check anything, since we were right the first time.
-    // In the DOM case, we only need to do something if |afterChange| is not 0.
-    // |afterChange| is 0 in the parser case, so it works out that we'll skip this block.
-    if (e->childrenAffectedByFirstChildRules() && afterChange) {
-        // Find our new first child.
-        Node* newFirstChild = 0;
-        for (newFirstChild = e->firstChild(); newFirstChild && !newFirstChild->isElementNode(); newFirstChild = newFirstChild->nextSibling()) {};
-
-        // Find the first element node following |afterChange|
-        Node* firstElementAfterInsertion = 0;
-        for (firstElementAfterInsertion = afterChange;
-             firstElementAfterInsertion && !firstElementAfterInsertion->isElementNode();
-             firstElementAfterInsertion = firstElementAfterInsertion->nextSibling()) {};
-
-        // This is the insert/append case.
-        if (newFirstChild != firstElementAfterInsertion && firstElementAfterInsertion && firstElementAfterInsertion->attached() &&
-            firstElementAfterInsertion->renderStyle() && firstElementAfterInsertion->renderStyle()->firstChildState())
-            firstElementAfterInsertion->setNeedsStyleRecalc();
-
-        // We also have to handle node removal.
-        if (childCountDelta < 0 && newFirstChild == firstElementAfterInsertion && newFirstChild && (!newFirstChild->renderStyle() || !newFirstChild->renderStyle()->firstChildState()))
-            newFirstChild->setNeedsStyleRecalc();
-    }
-
-    // :last-child.  In the parser callback case, we don't have to check anything, since we were right the first time.
-    // In the DOM case, we only need to do something if |afterChange| is not 0.
-    if (e->childrenAffectedByLastChildRules() && beforeChange) {
-        // Find our new last child.
-        Node* newLastChild = 0;
-        for (newLastChild = e->lastChild(); newLastChild && !newLastChild->isElementNode(); newLastChild = newLastChild->previousSibling()) {};
-
-        // Find the last element node going backwards from |beforeChange|
-        Node* lastElementBeforeInsertion = 0;
-        for (lastElementBeforeInsertion = beforeChange;
-             lastElementBeforeInsertion && !lastElementBeforeInsertion->isElementNode();
-             lastElementBeforeInsertion = lastElementBeforeInsertion->previousSibling()) {};
-
-        if (newLastChild != lastElementBeforeInsertion && lastElementBeforeInsertion && lastElementBeforeInsertion->attached() &&
-            lastElementBeforeInsertion->renderStyle() && lastElementBeforeInsertion->renderStyle()->lastChildState())
-            lastElementBeforeInsertion->setNeedsStyleRecalc();
-
-        // We also have to handle node removal.  The parser callback case is similar to node removal as well in that we need to change the last child
-        // to match now.
-        if ((childCountDelta < 0 || finishedParsingCallback) && newLastChild == lastElementBeforeInsertion && newLastChild && (!newLastChild->renderStyle() || !newLastChild->renderStyle()->lastChildState()))
-            newLastChild->setNeedsStyleRecalc();
-    }
-
-    // The + selector.  We need to invalidate the first element following the insertion point.  It is the only possible element
-    // that could be affected by this DOM change.
-    if (e->childrenAffectedByDirectAdjacentRules() && afterChange) {
-        Node* firstElementAfterInsertion = 0;
-        for (firstElementAfterInsertion = afterChange;
-             firstElementAfterInsertion && !firstElementAfterInsertion->isElementNode();
-             firstElementAfterInsertion = firstElementAfterInsertion->nextSibling()) {};
-        if (firstElementAfterInsertion && firstElementAfterInsertion->attached())
-            firstElementAfterInsertion->setNeedsStyleRecalc();
-    }
-
     // Forward positional selectors include the ~ selector, nth-child, nth-of-type, first-of-type and only-of-type.
     // Backward positional selectors include nth-last-child, nth-last-of-type, last-of-type and only-of-type.
     // We have to invalidate everything following the insertion point in the forward case, and everything before the insertion point in the
     // backward case.
     // |afterChange| is 0 in the parser callback case, so we won't do any work for the forward case if we don't have to.
     // For performance reasons we just mark the parent node as changed, since we don't want to make childrenChanged O(n^2) by crawling all our kids
-    // here.  recalcStyle will then force a walk of the children when it sees that this has happened.
-    if ((e->childrenAffectedByForwardPositionalRules() && afterChange)
-        || (e->childrenAffectedByBackwardPositionalRules() && beforeChange))
+    // here. recalcStyle will then force a walk of the children when it sees that this has happened.
+    if ((e->childrenAffectedByForwardPositionalRules() && afterChange) || (e->childrenAffectedByBackwardPositionalRules() && beforeChange)) {
         e->setNeedsStyleRecalc();
+        return;
+    }
+
+    // :first-child.  In the parser callback case, we don't have to check anything, since we were right the first time.
+    // In the DOM case, we only need to do something if |afterChange| is not 0.
+    // |afterChange| is 0 in the parser case, so it works out that we'll skip this block.
+    if (e->childrenAffectedByFirstChildRules() && afterChange) {
+        // Find our new first child.
+        Node* newFirstChild = e->firstElementChild();
+        RenderStyle* newFirstChildStyle = newFirstChild ? newFirstChild->renderStyle() : 0;
+
+        // Find the first element node following |afterChange|
+        Node* firstElementAfterInsertion = afterChange->isElementNode() ? afterChange : afterChange->nextElementSibling();
+        RenderStyle* firstElementAfterInsertionStyle = firstElementAfterInsertion ? firstElementAfterInsertion->renderStyle() : 0;
+
+        // This is the insert/append case.
+        if (newFirstChild != firstElementAfterInsertion && firstElementAfterInsertionStyle && firstElementAfterInsertionStyle->firstChildState())
+            firstElementAfterInsertion->setNeedsStyleRecalc();
+
+        // We also have to handle node removal.
+        if (childCountDelta < 0 && newFirstChild == firstElementAfterInsertion && newFirstChild && (!newFirstChildStyle || !newFirstChildStyle->firstChildState()))
+            newFirstChild->setNeedsStyleRecalc();
+    }
+
+    // :last-child.  In the parser callback case, we don't have to check anything, since we were right the first time.
+    // In the DOM case, we only need to do something if |afterChange| is not 0.
+    if (e->childrenAffectedByLastChildRules() && beforeChange) {
+        // Find our new last child.
+        Node* newLastChild = e->lastElementChild();
+        RenderStyle* newLastChildStyle = newLastChild ? newLastChild->renderStyle() : 0;
+
+        // Find the last element node going backwards from |beforeChange|
+        Node* lastElementBeforeInsertion = beforeChange->isElementNode() ? beforeChange : beforeChange->previousElementSibling();
+        RenderStyle* lastElementBeforeInsertionStyle = lastElementBeforeInsertion ? lastElementBeforeInsertion->renderStyle() : 0;
+
+        if (newLastChild != lastElementBeforeInsertion && lastElementBeforeInsertionStyle && lastElementBeforeInsertionStyle->lastChildState())
+            lastElementBeforeInsertion->setNeedsStyleRecalc();
+
+        // We also have to handle node removal.  The parser callback case is similar to node removal as well in that we need to change the last child
+        // to match now.
+        if ((childCountDelta < 0 || finishedParsingCallback) && newLastChild == lastElementBeforeInsertion && newLastChild && (!newLastChildStyle || !newLastChildStyle->lastChildState()))
+            newLastChild->setNeedsStyleRecalc();
+    }
+
+    // The + selector.  We need to invalidate the first element following the insertion point.  It is the only possible element
+    // that could be affected by this DOM change.
+    if (e->childrenAffectedByDirectAdjacentRules() && afterChange) {
+        if (Node* firstElementAfterInsertion = afterChange->nextElementSibling())
+            firstElementAfterInsertion->setNeedsStyleRecalc();
+    }
 }
 
 void Element::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
@@ -1769,7 +1732,7 @@
     else
         checkForSiblingStyleChanges(this, renderStyle(), false, beforeChange, afterChange, childCountDelta);
 
-    if (ElementShadow * shadow = this->shadow())
+    if (ElementShadow* shadow = this->shadow())
         shadow->invalidateDistribution();
 }
 
@@ -2157,11 +2120,6 @@
     return content.toString();
 }
 
-String Element::title() const
-{
-    return String();
-}
-
 const AtomicString& Element::pseudo() const
 {
     return getAttribute(pseudoAttr);
@@ -2475,16 +2433,6 @@
     return 0;
 }
 
-bool Element::matchesReadOnlyPseudoClass() const
-{
-    return false;
-}
-
-bool Element::matchesReadWritePseudoClass() const
-{
-    return false;
-}
-
 bool Element::webkitMatchesSelector(const String& selector, ExceptionCode& ec)
 {
     if (selector.isEmpty()) {
@@ -2498,11 +2446,6 @@
     return selectorQuery->matches(this);
 }
 
-bool Element::shouldAppearIndeterminate() const
-{
-    return false;
-}
-
 DOMTokenList* Element::classList()
 {
     ElementRareData* data = ensureElementRareData();
@@ -2822,7 +2765,7 @@
            setNeedsStyleRecalc();
 
         if (isUpgradedCustomElement())
-            document()->registrationContext()->customElementAttributeDidChange(this, name.localName(), oldValue, newValue);
+            CustomElement::attributeDidChange(this, name.localName(), oldValue, newValue);
     }
 
     if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInterestGroup::createForAttributesMutation(this, name))
@@ -3096,9 +3039,9 @@
 
 struct PresentationAttributeCacheKey {
     PresentationAttributeCacheKey() : tagName(0) { }
-    AtomicStringImpl* tagName;
+    StringImpl* tagName;
     // Only the values need refcounting.
-    Vector<pair<AtomicStringImpl*, AtomicString>, 3> attributesAndValues;
+    Vector<pair<StringImpl*, AtomicString>, 3> attributesAndValues;
 };
 
 struct PresentationAttributeCacheEntry {
@@ -3318,7 +3261,7 @@
         inlineStyle->addSubresourceStyleURLs(urls, document()->elementSheet()->contents());
 }
 
-static inline bool attributeNameSort(const pair<AtomicStringImpl*, AtomicString>& p1, const pair<AtomicStringImpl*, AtomicString>& p2)
+static inline bool attributeNameSort(const pair<StringImpl*, AtomicString>& p1, const pair<StringImpl*, AtomicString>& p2)
 {
     // Sort based on the attribute name pointers. It doesn't matter what the order is as long as it is always the same.
     return p1.first < p2.first;
diff --git a/Source/core/dom/Element.h b/Source/core/dom/Element.h
index 35f6e17..989019c 100644
--- a/Source/core/dom/Element.h
+++ b/Source/core/dom/Element.h
@@ -37,7 +37,7 @@
 
 namespace WebCore {
 
-class Animation;
+class ActiveAnimations;
 class Attr;
 class Attribute;
 class ClientRect;
@@ -513,7 +513,7 @@
  
     String textFromChildren();
 
-    virtual String title() const;
+    virtual String title() const { return String(); }
 
     const AtomicString& pseudo() const;
     void setPseudo(const AtomicString&);
@@ -531,10 +531,10 @@
     PseudoElement* pseudoElement(PseudoId) const;
     RenderObject* pseudoElementRenderer(PseudoId) const;
 
-    virtual bool matchesReadOnlyPseudoClass() const;
-    virtual bool matchesReadWritePseudoClass() const;
+    virtual bool matchesReadOnlyPseudoClass() const { return false; }
+    virtual bool matchesReadWritePseudoClass() const { return false; }
     bool webkitMatchesSelector(const String& selectors, ExceptionCode&);
-    virtual bool shouldAppearIndeterminate() const;
+    virtual bool shouldAppearIndeterminate() const { return false; }
 
     DOMTokenList* classList();
 
@@ -547,9 +547,9 @@
     virtual bool isInputFieldSpeechButtonElement() const { return false; }
 #endif
 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
-    virtual bool isDateTimeEditElement() const;
-    virtual bool isDateTimeFieldElement() const;
-    virtual bool isPickerIndicatorElement() const;
+    virtual bool isDateTimeEditElement() const { return false; }
+    virtual bool isDateTimeFieldElement() const { return false; }
+    virtual bool isPickerIndicatorElement() const { return false; }
 #endif
 
     virtual bool isFormControlElement() const { return false; }
@@ -564,14 +564,15 @@
     virtual bool isOutOfRange() const { return false; }
     virtual bool isFrameElementBase() const { return false; }
     virtual bool isPasswordGeneratorButtonElement() const { return false; }
-    virtual bool isClearButtonElement() const;
+    virtual bool isClearButtonElement() const { return false; }
 
     virtual bool canContainRangeEndPoint() const { return true; }
 
     virtual const AtomicString& formControlType() const { return nullAtom; }
 
-    virtual bool wasChangedSinceLastFormControlChangeEvent() const;
-    virtual void setChangedSinceLastFormControlChangeEvent(bool);
+    // FIXME: Only HTMLInputElement uses these, they don't need to be virtual.
+    virtual bool wasChangedSinceLastFormControlChangeEvent() const { return false; }
+    virtual void setChangedSinceLastFormControlChangeEvent(bool) { }
     virtual void dispatchFormControlChangeEvent() { }
 
     // Used for disabled form elements; if true, prevents mouse events from being dispatched
@@ -622,10 +623,9 @@
     IntSize savedLayerScrollOffset() const;
     void setSavedLayerScrollOffset(const IntSize&);
 
-    void addActiveAnimation(Animation*);
-    void removeActiveAnimation(Animation*);
+    ActiveAnimations* activeAnimations() const;
+    ActiveAnimations* ensureActiveAnimations();
     bool hasActiveAnimations() const;
-    Vector<Animation*>* activeAnimations() const;
 
     InputMethodContext* getInputContext();
 
diff --git a/Source/core/dom/ElementRareData.h b/Source/core/dom/ElementRareData.h
index 4b86859..117e93a 100644
--- a/Source/core/dom/ElementRareData.h
+++ b/Source/core/dom/ElementRareData.h
@@ -22,6 +22,7 @@
 #ifndef ElementRareData_h
 #define ElementRareData_h
 
+#include "core/animation/ActiveAnimations.h"
 #include "core/dom/DatasetDOMStringMap.h"
 #include "core/dom/NamedNodeMap.h"
 #include "core/dom/NodeRareData.h"
@@ -34,7 +35,6 @@
 
 namespace WebCore {
 
-class Animation;
 class HTMLElement;
 
 class ElementRareData : public NodeRareData {
@@ -128,10 +128,10 @@
     IntSize savedLayerScrollOffset() const { return m_savedLayerScrollOffset; }
     void setSavedLayerScrollOffset(IntSize size) { m_savedLayerScrollOffset = size; }
 
-    Vector<Animation*>* activeAnimations() { return m_activeAnimations.get(); }
-    void setActiveAnimations(PassOwnPtr<Vector<Animation*> > animations)
+    ActiveAnimations* activeAnimations() { return m_activeAnimations.get(); }
+    void setActiveAnimations(PassOwnPtr<ActiveAnimations> activeAnimations)
     {
-        m_activeAnimations = animations;
+        m_activeAnimations = activeAnimations;
     }
 
     bool hasPendingResources() const { return m_hasPendingResources; }
@@ -178,8 +178,7 @@
     OwnPtr<ElementShadow> m_shadow;
     OwnPtr<NamedNodeMap> m_attributeMap;
     OwnPtr<InputMethodContext> m_inputMethodContext;
-
-    OwnPtr<Vector<Animation*> > m_activeAnimations;
+    OwnPtr<ActiveAnimations> m_activeAnimations;
 
     RefPtr<PseudoElement> m_generatedBefore;
     RefPtr<PseudoElement> m_generatedAfter;
diff --git a/Source/core/dom/EventPathWalker.cpp b/Source/core/dom/EventPathWalker.cpp
index a3b9760..4c28e19 100644
--- a/Source/core/dom/EventPathWalker.cpp
+++ b/Source/core/dom/EventPathWalker.cpp
@@ -62,14 +62,14 @@
     }
     if (!m_node->isShadowRoot()) {
         m_node = m_node->parentNode();
-        if (!(m_node && m_node->isShadowRoot() && ScopeContentDistribution::assignedTo(toShadowRoot(m_node))))
+        if (!(m_node && m_node->isShadowRoot() && toShadowRoot(m_node)->insertionPoint()))
             m_distributedNode = m_node;
         m_isVisitingInsertionPointInReprojection = false;
         return;
     }
 
     const ShadowRoot* shadowRoot = toShadowRoot(m_node);
-    if (InsertionPoint* insertionPoint = ScopeContentDistribution::assignedTo(shadowRoot)) {
+    if (InsertionPoint* insertionPoint = shadowRoot->insertionPoint()) {
         m_node = insertionPoint;
         m_isVisitingInsertionPointInReprojection = true;
         return;
diff --git a/Source/core/dom/FullscreenController.cpp b/Source/core/dom/FullscreenController.cpp
index ed63fee..c365872 100644
--- a/Source/core/dom/FullscreenController.cpp
+++ b/Source/core/dom/FullscreenController.cpp
@@ -431,7 +431,7 @@
         m_fullScreenRenderer->unwrapRenderer();
 
     m_fullScreenElement = 0;
-    document()->scheduleForcedStyleRecalc();
+    document()->setNeedsStyleRecalc();
 
     // When webkitCancelFullScreen is called, we call webkitExitFullScreen on the topDocument(). That
     // means that the events will be queued there. So if we have no events here, start the timer on
diff --git a/Source/core/dom/IdTargetObserverRegistry.h b/Source/core/dom/IdTargetObserverRegistry.h
index fb04ff5..4af563a 100644
--- a/Source/core/dom/IdTargetObserverRegistry.h
+++ b/Source/core/dom/IdTargetObserverRegistry.h
@@ -30,7 +30,7 @@
 #include "wtf/HashMap.h"
 #include "wtf/HashSet.h"
 #include "wtf/PassOwnPtr.h"
-#include "wtf/text/AtomicString.h"
+#include "wtf/text/StringHash.h"
 
 namespace WebCore {
 
@@ -50,7 +50,7 @@
     void notifyObserversInternal(const AtomicString& id);
 
     typedef HashSet<IdTargetObserver*> ObserverSet;
-    typedef HashMap<AtomicStringImpl*, OwnPtr<ObserverSet> > IdToObserverSetMap;
+    typedef HashMap<StringImpl*, OwnPtr<ObserverSet> > IdToObserverSetMap;
     IdToObserverSetMap m_registry;
     ObserverSet* m_notifyingObserversInSet;
 };
diff --git a/Source/core/dom/MessagePort.cpp b/Source/core/dom/MessagePort.cpp
index 07b4eb1..be7ab66 100644
--- a/Source/core/dom/MessagePort.cpp
+++ b/Source/core/dom/MessagePort.cpp
@@ -68,7 +68,7 @@
         for (unsigned int i = 0; i < ports->size(); ++i) {
             MessagePort* dataPort = (*ports)[i].get();
             if (dataPort == this || m_entangledChannel->isConnectedTo(dataPort)) {
-                es.throwDOMException(InvalidStateError);
+                es.throwDOMException(DataCloneError);
                 return;
             }
         }
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp
index 8f63f06..4cdd942 100644
--- a/Source/core/dom/Node.cpp
+++ b/Source/core/dom/Node.cpp
@@ -55,7 +55,7 @@
 #include "core/dom/MutationEvent.h"
 #include "core/dom/NameNodeList.h"
 #include "core/dom/NodeRareData.h"
-#include "core/dom/NodeRenderingContext.h"
+#include "core/dom/NodeRenderingTraversal.h"
 #include "core/dom/NodeTraversal.h"
 #include "core/dom/ProcessingInstruction.h"
 #include "core/dom/SelectorQuery.h"
@@ -650,10 +650,14 @@
 
     for (const Node* node = this; node; node = node->parentNode()) {
         if ((node->isHTMLElement() || node->isDocumentNode()) && node->renderer()) {
+#if ENABLE(USERSELECT_ALL)
             // Elements with user-select: all style are considered atomic
             // therefore non editable.
             if (node->renderer()->style()->userSelect() == SELECT_ALL && treatment == UserSelectAllIsAlwaysNonEditable)
                 return false;
+#else
+            UNUSED_PARAM(treatment);
+#endif
             switch (node->renderer()->style()->userModify()) {
             case READ_ONLY:
                 return false;
@@ -770,7 +774,7 @@
     for (ContainerNode* p = parentOrShadowHostNode(); p && !p->childNeedsStyleRecalc(); p = p->parentOrShadowHostNode())
         p->setChildNeedsStyleRecalc();
 
-    if (document()->childNeedsStyleRecalc())
+    if (document()->needsStyleRecalc() || document()->childNeedsStyleRecalc())
         document()->scheduleStyleRecalc();
 }
 
@@ -1140,11 +1144,6 @@
     return 0;
 }
 
-ContainerNode* Node::parentNodeForRenderingAndStyle()
-{
-    return NodeRenderingContext(this).parentNodeForRenderingAndStyle();
-}
-
 RenderStyle* Node::virtualComputedStyle(PseudoId pseudoElementSpecifier)
 {
     return parentOrShadowHostNode() ? parentOrShadowHostNode()->computedStyle(pseudoElementSpecifier) : 0;
@@ -1656,7 +1655,7 @@
             ChildListMutationScope mutation(this);
             container->removeChildren();
             if (!text.isEmpty())
-                container->appendChild(document()->createTextNode(text), ec);
+                container->appendChild(document()->createTextNode(text), ec, AttachLazily);
             return;
         }
         case DOCUMENT_NODE:
diff --git a/Source/core/dom/Node.h b/Source/core/dom/Node.h
index f71a14a..45db9bc 100644
--- a/Source/core/dom/Node.h
+++ b/Source/core/dom/Node.h
@@ -570,10 +570,10 @@
 
     void reattach(const AttachContext& = AttachContext());
     void lazyReattachIfAttached();
-    ContainerNode* parentNodeForRenderingAndStyle();
 
     // Wrapper for nodes that don't have a renderer, but still cache the style (like HTMLOptionElement).
     RenderStyle* renderStyle() const;
+    RenderStyle* parentRenderStyle() const;
 
     RenderStyle* computedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO) { return virtualComputedStyle(pseudoElementSpecifier); }
 
@@ -931,9 +931,7 @@
     lazyAttach(shouldSetAttached);
 }
 
-// Need a template since ElementShadow is not a Node, but has the style recalc methods.
-template<class T>
-inline bool shouldRecalcStyle(Node::StyleChange change, const T* node)
+inline bool shouldRecalcStyle(Node::StyleChange change, const Node* node)
 {
     return change >= Node::Inherit || node->childNeedsStyleRecalc() || node->needsStyleRecalc();
 }
diff --git a/Source/core/dom/NodeRenderStyle.h b/Source/core/dom/NodeRenderStyle.h
index 2ab78c3..a9487ab 100644
--- a/Source/core/dom/NodeRenderStyle.h
+++ b/Source/core/dom/NodeRenderStyle.h
@@ -26,6 +26,7 @@
 #define NodeRenderStyle_h
 
 #include "core/dom/Node.h"
+#include "core/dom/NodeRenderingTraversal.h"
 #include "core/rendering/RenderObject.h"
 #include "core/rendering/style/RenderStyle.h"
 
@@ -40,5 +41,11 @@
     return nonRendererStyle();
 }
 
+inline RenderStyle* Node::parentRenderStyle() const
+{
+    ContainerNode* parent = NodeRenderingTraversal::parent(this);
+    return parent ? parent->renderStyle() : 0;
+}
+
 }
 #endif
diff --git a/Source/core/dom/NodeRenderingContext.cpp b/Source/core/dom/NodeRenderingContext.cpp
index f403465..2677c13 100644
--- a/Source/core/dom/NodeRenderingContext.cpp
+++ b/Source/core/dom/NodeRenderingContext.cpp
@@ -27,13 +27,12 @@
 #include "core/dom/NodeRenderingContext.h"
 
 #include "RuntimeEnabledFeatures.h"
-#include "SVGNames.h"
 #include "core/css/resolver/StyleResolver.h"
 #include "core/dom/ContainerNode.h"
 #include "core/dom/FullscreenController.h"
 #include "core/dom/Node.h"
 #include "core/dom/Text.h"
-#include "core/html/shadow/HTMLShadowElement.h"
+#include "core/dom/shadow/InsertionPoint.h"
 #include "core/rendering/FlowThreadController.h"
 #include "core/rendering/RenderFullScreen.h"
 #include "core/rendering/RenderNamedFlowThread.h"
@@ -43,33 +42,15 @@
 
 namespace WebCore {
 
-NodeRenderingContext::NodeRenderingContext(Node* node)
-    : m_node(node)
-    , m_parentFlowRenderer(0)
-{
-    m_renderingParent = NodeRenderingTraversal::parent(node, &m_parentDetails);
-}
-
 NodeRenderingContext::NodeRenderingContext(Node* node, RenderStyle* style)
     : m_node(node)
     , m_renderingParent(0)
     , m_style(style)
     , m_parentFlowRenderer(0)
 {
-}
-
-NodeRenderingContext::NodeRenderingContext(Node* node, const Node::AttachContext& context)
-: m_node(node)
-, m_style(context.resolvedStyle)
-, m_parentFlowRenderer(0)
-{
     m_renderingParent = NodeRenderingTraversal::parent(node, &m_parentDetails);
 }
 
-NodeRenderingContext::~NodeRenderingContext()
-{
-}
-
 static bool isRendererReparented(const RenderObject* renderer)
 {
     if (!renderer->node()->isElementNode())
@@ -175,7 +156,6 @@
 {
     if (!m_renderingParent)
         return false;
-
     RenderObject* parentRenderer = this->parentRenderer();
     if (!parentRenderer)
         return false;
@@ -224,16 +204,6 @@
     flowThreadController->registerNamedFlowContentNode(m_node, m_parentFlowRenderer);
 }
 
-bool NodeRenderingContext::isOnEncapsulationBoundary() const
-{
-    return isOnUpperEncapsulationBoundary() || isLowerEncapsulationBoundary(m_parentDetails.insertionPoint()) || isLowerEncapsulationBoundary(m_node->parentNode());
-}
-
-bool NodeRenderingContext::isOnUpperEncapsulationBoundary() const
-{
-    return m_node->parentNode() && m_node->parentNode()->isShadowRoot();
-}
-
 void NodeRenderingContext::createRendererForElementIfNeeded()
 {
     ASSERT(!m_node->renderer());
@@ -254,14 +224,12 @@
     if (!element->rendererIsNeeded(*this))
         return;
 
-    RenderObject* parentRenderer = this->parentRenderer();
-    RenderObject* nextRenderer = this->nextRenderer();
-
-    Document* document = element->document();
     RenderObject* newRenderer = element->createRenderer(m_style.get());
     if (!newRenderer)
         return;
 
+    RenderObject* parentRenderer = this->parentRenderer();
+
     if (!parentRenderer->isChildAllowed(newRenderer, m_style.get())) {
         newRenderer->destroy();
         return;
@@ -271,11 +239,12 @@
     // for the first time. Otherwise code using inRenderFlowThread() in the styleWillChange and styleDidChange will fail.
     newRenderer->setFlowThreadState(parentRenderer->flowThreadState());
 
+    RenderObject* nextRenderer = this->nextRenderer();
     element->setRenderer(newRenderer);
     newRenderer->setAnimatableStyle(m_style.release()); // setAnimatableStyle() can depend on renderer() already being set.
 
     if (FullscreenController::isActiveFullScreenElement(element)) {
-        newRenderer = RenderFullScreen::wrapRenderer(newRenderer, parentRenderer, document);
+        newRenderer = RenderFullScreen::wrapRenderer(newRenderer, parentRenderer, element->document());
         if (!newRenderer)
             return;
     }
@@ -294,19 +263,16 @@
         return;
 
     RenderObject* parentRenderer = this->parentRenderer();
-    ASSERT(parentRenderer);
-    Document* document = textNode->document();
 
     if (resetStyleInheritance())
-        m_style = document->styleResolver()->defaultStyleForElement();
+        m_style = textNode->document()->styleResolver()->defaultStyleForElement();
     else
         m_style = parentRenderer->style();
 
     if (!textNode->textRendererIsNeeded(*this))
         return;
+
     RenderText* newRenderer = textNode->createTextRenderer(m_style.get());
-    if (!newRenderer)
-        return;
     if (!parentRenderer->isChildAllowed(newRenderer, m_style.get())) {
         newRenderer->destroy();
         return;
diff --git a/Source/core/dom/NodeRenderingContext.h b/Source/core/dom/NodeRenderingContext.h
index 3bacbf4..9e448a8 100644
--- a/Source/core/dom/NodeRenderingContext.h
+++ b/Source/core/dom/NodeRenderingContext.h
@@ -44,10 +44,7 @@
 
 class NodeRenderingContext {
 public:
-    explicit NodeRenderingContext(Node*);
-    NodeRenderingContext(Node*, RenderStyle*);
-    NodeRenderingContext(Node*, const Node::AttachContext&);
-    ~NodeRenderingContext();
+    NodeRenderingContext(Node*, RenderStyle* = 0);
 
     void createRendererForTextIfNeeded();
     void createRendererForElementIfNeeded();
@@ -62,9 +59,6 @@
 
     const RenderStyle* style() const;
 
-    bool isOnUpperEncapsulationBoundary() const;
-    bool isOnEncapsulationBoundary() const;
-
 private:
     bool shouldCreateRenderer() const;
     void moveToFlowThreadIfNeeded();
diff --git a/Source/core/dom/Position.cpp b/Source/core/dom/Position.cpp
index b1d7f07..c917fb5 100644
--- a/Source/core/dom/Position.cpp
+++ b/Source/core/dom/Position.cpp
@@ -852,6 +852,7 @@
     return node->parentNode();
 }
 
+#if ENABLE(USERSELECT_ALL)
 bool Position::nodeIsUserSelectAll(const Node* node)
 {
     return node && node->renderer() && node->renderer()->style()->userSelect() == SELECT_ALL;
@@ -878,6 +879,7 @@
     }
     return candidateRoot;
 }
+#endif
 
 bool Position::isCandidate() const
 {
diff --git a/Source/core/dom/Position.h b/Source/core/dom/Position.h
index 5d4fd32..c3ad406 100644
--- a/Source/core/dom/Position.h
+++ b/Source/core/dom/Position.h
@@ -189,8 +189,10 @@
 
     static bool hasRenderedNonAnonymousDescendantsWithHeight(RenderObject*);
     static bool nodeIsUserSelectNone(Node*);
+#if ENABLE(USERSELECT_ALL)
     static bool nodeIsUserSelectAll(const Node*);
     static Node* rootUserSelectAllForNode(Node*);
+#endif
     static ContainerNode* findParent(const Node*);
     
     void debugPosition(const char* msg = "") const;
diff --git a/Source/core/dom/Text.cpp b/Source/core/dom/Text.cpp
index 9886613..826f282 100644
--- a/Source/core/dom/Text.cpp
+++ b/Source/core/dom/Text.cpp
@@ -207,13 +207,11 @@
     if (context.style()->display() == NONE)
         return false;
 
-    bool onlyWS = containsOnlyWhitespace();
-    if (!onlyWS)
+    if (!containsOnlyWhitespace())
         return true;
 
     RenderObject* parent = context.parentRenderer();
-    if (parent->isTable() || parent->isTableRow() || parent->isTableSection() || parent->isRenderTableCol() || parent->isFrameSet()
-        || parent->isFlexibleBox() || parent->isRenderGrid())
+    if (!parent->canHaveWhitespaceChildren())
         return false;
     
     if (context.style()->preserveNewline()) // pre/pre-wrap/pre-line always make renderers.
@@ -230,17 +228,19 @@
     } else {
         if (parent->isRenderBlock() && !parent->childrenInline() && (!prev || !prev->isInline()))
             return false;
-        
+
+        // Avoiding creation of a Renderer for the text node is a non-essential memory optimization.
+        // So to avoid blowing up on very wide DOMs, we limit the number of siblings to visit.
+        unsigned maxSiblingsToVisit = 50;
+
         RenderObject* first = parent->firstChild();
-        while (first && first->isFloatingOrOutOfFlowPositioned())
+        while (first && first->isFloatingOrOutOfFlowPositioned() && maxSiblingsToVisit--)
             first = first->nextSibling();
-        RenderObject* next = context.nextRenderer();
-        if (!first || next == first)
+        if (!first || context.nextRenderer() == first)
             // Whitespace at the start of a block just goes away.  Don't even
             // make a render object for this text.
             return false;
     }
-    
     return true;
 }
 
@@ -298,10 +298,7 @@
 bool Text::needsWhitespaceRenderer()
 {
     ASSERT(!renderer());
-    ContainerNode* parent = parentNodeForRenderingAndStyle();
-    if (!parent)
-        return false;
-    if (RenderStyle* style = parent->renderStyle())
+    if (RenderStyle* style = parentRenderStyle())
         return style->preserveNewline();
     return false;
 }
diff --git a/Source/core/dom/TextLinkColors.cpp b/Source/core/dom/TextLinkColors.cpp
index f6e1fd8..59589a5 100644
--- a/Source/core/dom/TextLinkColors.cpp
+++ b/Source/core/dom/TextLinkColors.cpp
@@ -44,17 +44,17 @@
 
 void TextLinkColors::resetLinkColor()
 {
-    m_linkColor = Color(0, 0, 238);
+    m_linkColor = StyleColor(0, 0, 238);
 }
 
 void TextLinkColors::resetVisitedLinkColor()
 {
-    m_visitedLinkColor = Color(85, 26, 139);
+    m_visitedLinkColor = StyleColor(85, 26, 139);
 }
 
 void TextLinkColors::resetActiveLinkColor()
 {
-    m_activeLinkColor.setNamedColor("red");
+    m_activeLinkColor = StyleColor(255, 0, 0);
 }
 
 static Color colorForCSSValue(CSSValueID cssValueId)
@@ -94,10 +94,10 @@
     return RenderTheme::defaultTheme()->systemColor(cssValueId);
 }
 
-Color TextLinkColors::colorFromPrimitiveValue(const CSSPrimitiveValue* value, Color currentColor, bool forVisitedLink) const
+StyleColor TextLinkColors::colorFromPrimitiveValue(const CSSPrimitiveValue* value, bool forVisitedLink) const
 {
     if (value->isRGBColor())
-        return Color(value->getRGBA32Value());
+        return StyleColor(value->getRGBA32Value());
 
     CSSValueID valueID = value->getValueID();
     switch (valueID) {
@@ -112,7 +112,7 @@
     case CSSValueWebkitFocusRingColor:
         return RenderTheme::focusRingColor();
     case CSSValueCurrentcolor:
-        return currentColor;
+        return StyleColor::currentColor();
     default:
         return colorForCSSValue(valueID);
     }
diff --git a/Source/core/dom/TextLinkColors.h b/Source/core/dom/TextLinkColors.h
index 6d2728c..fb223e8 100644
--- a/Source/core/dom/TextLinkColors.h
+++ b/Source/core/dom/TextLinkColors.h
@@ -28,7 +28,7 @@
 #ifndef TextLinkColors_h
 #define TextLinkColors_h
 
-#include "core/platform/graphics/Color.h"
+#include "core/css/StyleColor.h"
 #include "wtf/Noncopyable.h"
 
 namespace WebCore {
@@ -41,25 +41,25 @@
 public:
     TextLinkColors();
 
-    void setTextColor(const Color& color) { m_textColor = color; }
-    Color textColor() const { return m_textColor; }
+    void setTextColor(const StyleColor& color) { m_textColor = color; }
+    StyleColor textColor() const { return m_textColor; }
 
-    const Color& linkColor() const { return m_linkColor; }
-    const Color& visitedLinkColor() const { return m_visitedLinkColor; }
-    const Color& activeLinkColor() const { return m_activeLinkColor; }
+    const StyleColor& linkColor() const { return m_linkColor; }
+    const StyleColor& visitedLinkColor() const { return m_visitedLinkColor; }
+    const StyleColor& activeLinkColor() const { return m_activeLinkColor; }
     void setLinkColor(const Color& color) { m_linkColor = color; }
     void setVisitedLinkColor(const Color& color) { m_visitedLinkColor = color; }
     void setActiveLinkColor(const Color& color) { m_activeLinkColor = color; }
     void resetLinkColor();
     void resetVisitedLinkColor();
     void resetActiveLinkColor();
-    Color colorFromPrimitiveValue(const CSSPrimitiveValue*, Color currentColor, bool forVisitedLink = false) const;
+    StyleColor colorFromPrimitiveValue(const CSSPrimitiveValue*, bool forVisitedLink = false) const;
 private:
 
-    Color m_textColor;
-    Color m_linkColor;
-    Color m_visitedLinkColor;
-    Color m_activeLinkColor;
+    StyleColor m_textColor;
+    StyleColor m_linkColor;
+    StyleColor m_visitedLinkColor;
+    StyleColor m_activeLinkColor;
 };
 
 }
diff --git a/Source/core/dom/TouchEvent.idl b/Source/core/dom/TouchEvent.idl
index b054441..c3b7a81 100644
--- a/Source/core/dom/TouchEvent.idl
+++ b/Source/core/dom/TouchEvent.idl
@@ -22,9 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-[
-    AllowJSCreationOnlyIfFeatureEnabled
-] interface TouchEvent : UIEvent {
+interface TouchEvent : UIEvent {
     readonly attribute TouchList touches;
     readonly attribute TouchList targetTouches;
     readonly attribute TouchList changedTouches;
diff --git a/Source/core/dom/TreeScope.cpp b/Source/core/dom/TreeScope.cpp
index a5f47dd..6afde25 100644
--- a/Source/core/dom/TreeScope.cpp
+++ b/Source/core/dom/TreeScope.cpp
@@ -178,7 +178,7 @@
 
 void TreeScope::addImageMap(HTMLMapElement* imageMap)
 {
-    AtomicStringImpl* name = imageMap->getName().impl();
+    StringImpl* name = imageMap->getName().impl();
     if (!name)
         return;
     if (!m_imageMapsByName)
@@ -190,7 +190,7 @@
 {
     if (!m_imageMapsByName)
         return;
-    AtomicStringImpl* name = imageMap->getName().impl();
+    StringImpl* name = imageMap->getName().impl();
     if (!name)
         return;
     m_imageMapsByName->remove(name, imageMap);
diff --git a/Source/core/dom/TreeScope.h b/Source/core/dom/TreeScope.h
index 6f4b3ee..54144ab 100644
--- a/Source/core/dom/TreeScope.h
+++ b/Source/core/dom/TreeScope.h
@@ -56,7 +56,7 @@
 
     Element* adjustedFocusedElement();
     Element* getElementById(const AtomicString&) const;
-    bool hasElementWithId(AtomicStringImpl* id) const;
+    bool hasElementWithId(StringImpl* id) const;
     bool containsMultipleElementsWithId(const AtomicString& id) const;
     void addElementById(const AtomicString& elementId, Element*);
     void removeElementById(const AtomicString& elementId, Element*);
@@ -174,7 +174,7 @@
     mutable RefPtr<DOMSelection> m_selection;
 };
 
-inline bool TreeScope::hasElementWithId(AtomicStringImpl* id) const
+inline bool TreeScope::hasElementWithId(StringImpl* id) const
 {
     ASSERT(id);
     return m_elementsById && m_elementsById->contains(id);
diff --git a/Source/core/dom/shadow/ComposedShadowTreeWalker.cpp b/Source/core/dom/shadow/ComposedShadowTreeWalker.cpp
index e647b33..84b2fd2 100644
--- a/Source/core/dom/shadow/ComposedShadowTreeWalker.cpp
+++ b/Source/core/dom/shadow/ComposedShadowTreeWalker.cpp
@@ -50,7 +50,7 @@
         return false;
 
     if (ShadowRoot* shadowRoot = parent->isShadowRoot() ? toShadowRoot(parent) : 0)
-        return ScopeContentDistribution::assignedTo(shadowRoot);
+        return shadowRoot->insertionPoint();
 
     if (parent->isElementNode() && toElement(parent)->shadow())
         return true;
@@ -185,7 +185,7 @@
     if (node->parentNode() && node->parentNode()->isShadowRoot()) {
         ShadowRoot* parentShadowRoot = toShadowRoot(node->parentNode());
         if (!parentShadowRoot->isYoungest()) {
-            InsertionPoint* assignedInsertionPoint = ScopeContentDistribution::assignedTo(parentShadowRoot);
+            InsertionPoint* assignedInsertionPoint = parentShadowRoot->insertionPoint();
             ASSERT(assignedInsertionPoint);
             return traverseSiblingInCurrentTree(assignedInsertionPoint, direction);
         }
@@ -254,7 +254,7 @@
 Node* ComposedShadowTreeWalker::traverseParentBackToYoungerShadowRootOrHost(const ShadowRoot* shadowRoot, ParentTraversalDetails* details) const
 {
     ASSERT(shadowRoot);
-    ASSERT(!ScopeContentDistribution::assignedTo(shadowRoot));
+    ASSERT(!shadowRoot->insertionPoint());
 
     if (shadowRoot->isYoungest()) {
         if (canCrossUpperBoundary()) {
diff --git a/Source/core/dom/shadow/ContentDistributor.cpp b/Source/core/dom/shadow/ContentDistributor.cpp
index 5b3a68b..e7ae775 100644
--- a/Source/core/dom/shadow/ContentDistributor.cpp
+++ b/Source/core/dom/shadow/ContentDistributor.cpp
@@ -99,7 +99,7 @@
     m_insertionPointListIsValid = true;
     ASSERT(m_insertionPointList.isEmpty());
 
-    if (!hasInsertionPoint(shadowRoot))
+    if (!shadowRoot->containsInsertionPoints())
         return m_insertionPointList;
 
     for (Element* element = ElementTraversal::firstWithin(shadowRoot); element; element = ElementTraversal::next(element, shadowRoot)) {
@@ -140,43 +140,6 @@
     invalidateInsertionPointList();
 }
 
-bool ScopeContentDistribution::hasShadowElement(const ShadowRoot* holder)
-{
-    if (!holder->scopeDistribution())
-        return false;
-
-    return holder->scopeDistribution()->hasShadowElementChildren();
-}
-
-bool ScopeContentDistribution::hasContentElement(const ShadowRoot* holder)
-{
-    if (!holder->scopeDistribution())
-        return false;
-
-    return holder->scopeDistribution()->hasContentElementChildren();
-}
-
-unsigned ScopeContentDistribution::countElementShadow(const ShadowRoot* holder)
-{
-    if (!holder->scopeDistribution())
-        return 0;
-
-    return holder->scopeDistribution()->numberOfElementShadowChildren();
-}
-
-bool ScopeContentDistribution::hasInsertionPoint(const ShadowRoot* holder)
-{
-    return hasShadowElement(holder) || hasContentElement(holder);
-}
-
-InsertionPoint* ScopeContentDistribution::assignedTo(const ShadowRoot* holder)
-{
-    if (!holder->scopeDistribution())
-        return 0;
-
-    return holder->scopeDistribution()->insertionPointAssignedTo();
-}
-
 ContentDistributor::ContentDistributor()
     : m_needsSelectFeatureSet(false)
     , m_validity(Undetermined)
@@ -395,14 +358,14 @@
 
 void ContentDistributor::collectSelectFeatureSetFrom(ShadowRoot* root)
 {
-    if (ScopeContentDistribution::hasElementShadow(root)) {
+    if (root->containsShadowRoots()) {
         for (Element* element = ElementTraversal::firstWithin(root); element; element = ElementTraversal::next(element)) {
             if (ElementShadow* elementShadow = element->shadow())
                 m_selectFeatures.add(elementShadow->distributor().ensureSelectFeatureSet(elementShadow));
         }
     }
 
-    if (ScopeContentDistribution::hasContentElement(root)) {
+    if (root->containsContentElements()) {
         for (Element* element = ElementTraversal::firstWithin(root); element; element = ElementTraversal::next(element)) {
             if (!isHTMLContentElement(element))
                 continue;
diff --git a/Source/core/dom/shadow/ContentDistributor.h b/Source/core/dom/shadow/ContentDistributor.h
index 442dc41..ba8707f 100644
--- a/Source/core/dom/shadow/ContentDistributor.h
+++ b/Source/core/dom/shadow/ContentDistributor.h
@@ -92,13 +92,6 @@
 
     bool isUsedForRendering() const;
 
-    static bool hasShadowElement(const ShadowRoot*);
-    static bool hasContentElement(const ShadowRoot*);
-    static bool hasInsertionPoint(const ShadowRoot*);
-    static bool hasElementShadow(const ShadowRoot* holder) { return countElementShadow(holder); }
-    static unsigned countElementShadow(const ShadowRoot*);
-    static InsertionPoint* assignedTo(const ShadowRoot*);
-
 private:
     InsertionPoint* m_insertionPointAssignedTo;
     unsigned m_numberOfShadowElementChildren;
diff --git a/Source/core/dom/shadow/ElementShadow.cpp b/Source/core/dom/shadow/ElementShadow.cpp
index b767737..e1983e5 100644
--- a/Source/core/dom/shadow/ElementShadow.cpp
+++ b/Source/core/dom/shadow/ElementShadow.cpp
@@ -96,32 +96,6 @@
     }
 }
 
-bool ElementShadow::childNeedsStyleRecalc() const
-{
-    ASSERT(youngestShadowRoot());
-    for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot())
-        if (root->childNeedsStyleRecalc())
-            return true;
-
-    return false;
-}
-
-bool ElementShadow::needsStyleRecalc() const
-{
-    ASSERT(youngestShadowRoot());
-    for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot())
-        if (root->needsStyleRecalc())
-            return true;
-
-    return false;
-}
-
-void ElementShadow::recalcStyle(Node::StyleChange change)
-{
-    for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot())
-        root->recalcStyle(change);
-}
-
 void ElementShadow::removeAllEventListeners()
 {
     for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) {
diff --git a/Source/core/dom/shadow/ElementShadow.h b/Source/core/dom/shadow/ElementShadow.h
index a1f645d..084d7c1 100644
--- a/Source/core/dom/shadow/ElementShadow.h
+++ b/Source/core/dom/shadow/ElementShadow.h
@@ -59,9 +59,6 @@
     void attach(const Node::AttachContext&);
     void detach(const Node::AttachContext&);
 
-    bool childNeedsStyleRecalc() const;
-    bool needsStyleRecalc() const;
-    void recalcStyle(Node::StyleChange);
     void removeAllEventListeners();
 
     void invalidateDistribution() { m_distributor.invalidateDistribution(host()); }
diff --git a/Source/core/dom/shadow/InsertionPoint.cpp b/Source/core/dom/shadow/InsertionPoint.cpp
index e0ef0b2..0fe52d9 100644
--- a/Source/core/dom/shadow/InsertionPoint.cpp
+++ b/Source/core/dom/shadow/InsertionPoint.cpp
@@ -90,11 +90,6 @@
     return isActive() && !hasDistribution();
 }
 
-bool InsertionPoint::isShadowBoundary() const
-{
-    return treeScope()->rootNode()->isShadowRoot() && isActive();
-}
-
 bool InsertionPoint::isActive() const
 {
     if (!containingShadowRoot())
@@ -124,7 +119,7 @@
 
 bool InsertionPoint::rendererIsNeeded(const NodeRenderingContext& context)
 {
-    return !isShadowBoundary() && HTMLElement::rendererIsNeeded(context);
+    return !isActive() && HTMLElement::rendererIsNeeded(context);
 }
 
 void InsertionPoint::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
@@ -201,7 +196,7 @@
 
 bool InsertionPoint::contains(const Node* node) const
 {
-    return m_distribution.contains(const_cast<Node*>(node)) || (node->isShadowRoot() && ScopeContentDistribution::assignedTo(toShadowRoot(node)) == this);
+    return m_distribution.contains(const_cast<Node*>(node)) || (node->isShadowRoot() && toShadowRoot(node)->insertionPoint() == this);
 }
 
 const CSSSelectorList& InsertionPoint::emptySelectorList()
@@ -228,7 +223,7 @@
         }
 
         if (Node* parent = parentNodeForDistribution(current)) {
-            if (InsertionPoint* insertedTo = parent->isShadowRoot() ? ScopeContentDistribution::assignedTo(toShadowRoot(parent)) : 0) {
+            if (InsertionPoint* insertedTo = parent->isShadowRoot() ? toShadowRoot(parent)->insertionPoint() : 0) {
                 current = insertedTo;
                 insertionPoint = insertedTo;
                 continue;
@@ -255,7 +250,7 @@
             }
         }
         if (Node* parent = parentNodeForDistribution(current)) {
-            if (InsertionPoint* insertedTo = parent->isShadowRoot() ? ScopeContentDistribution::assignedTo(toShadowRoot(parent)) : 0) {
+            if (InsertionPoint* insertedTo = parent->isShadowRoot() ? toShadowRoot(parent)->insertionPoint() : 0) {
                 current = insertedTo;
                 results.append(insertedTo);
                 continue;
diff --git a/Source/core/dom/shadow/InsertionPoint.h b/Source/core/dom/shadow/InsertionPoint.h
index 44cd1f9..0f1d486 100644
--- a/Source/core/dom/shadow/InsertionPoint.h
+++ b/Source/core/dom/shadow/InsertionPoint.h
@@ -57,7 +57,6 @@
     bool hasDistribution() const { return !m_distribution.isEmpty(); }
     void setDistribution(ContentDistribution& distribution) { m_distribution.swap(distribution); }
     void clearDistribution() { m_distribution.clear(); }
-    bool isShadowBoundary() const;
     bool isActive() const;
 
     PassRefPtr<NodeList> getDistributedNodes() const;
@@ -118,13 +117,6 @@
     return node->isInsertionPoint() && toInsertionPoint(node)->isActive();
 }
 
-inline bool isLowerEncapsulationBoundary(Node* node)
-{
-    if (!node || !node->isInsertionPoint())
-        return false;
-    return toInsertionPoint(node)->isShadowBoundary();
-}
-
 inline Node* parentNodeForDistribution(const Node* node)
 {
     ASSERT(node);
diff --git a/Source/core/dom/shadow/SelectRuleFeatureSet.h b/Source/core/dom/shadow/SelectRuleFeatureSet.h
index 7292b12..429d277 100644
--- a/Source/core/dom/shadow/SelectRuleFeatureSet.h
+++ b/Source/core/dom/shadow/SelectRuleFeatureSet.h
@@ -68,19 +68,19 @@
 inline bool SelectRuleFeatureSet::hasSelectorForId(const AtomicString& idValue) const
 {
     ASSERT(!idValue.isEmpty());
-    return m_cssRuleFeatureSet.idsInRules.contains(idValue.impl());
+    return m_cssRuleFeatureSet.idsInRules.contains(idValue);
 }
 
 inline bool SelectRuleFeatureSet::hasSelectorForClass(const AtomicString& classValue) const
 {
     ASSERT(!classValue.isEmpty());
-    return m_cssRuleFeatureSet.classesInRules.contains(classValue.impl());
+    return m_cssRuleFeatureSet.classesInRules.contains(classValue);
 }
 
 inline bool SelectRuleFeatureSet::hasSelectorForAttribute(const AtomicString& attributeName) const
 {
     ASSERT(!attributeName.isEmpty());
-    return m_cssRuleFeatureSet.attrsInRules.contains(attributeName.impl());
+    return m_cssRuleFeatureSet.attrsInRules.contains(attributeName);
 }
 
 }
diff --git a/Source/core/dom/shadow/ShadowRoot.cpp b/Source/core/dom/shadow/ShadowRoot.cpp
index 2fc2f26..a897eb9 100644
--- a/Source/core/dom/shadow/ShadowRoot.cpp
+++ b/Source/core/dom/shadow/ShadowRoot.cpp
@@ -192,7 +192,7 @@
 bool ShadowRoot::isActive() const
 {
     for (ShadowRoot* shadowRoot = youngerShadowRoot(); shadowRoot; shadowRoot = shadowRoot->youngerShadowRoot())
-        if (!ScopeContentDistribution::hasShadowElement(shadowRoot))
+        if (!shadowRoot->containsShadowElements())
             return false;
     return true;
 }
@@ -302,4 +302,24 @@
     return m_scopeDistribution.get();
 }
 
+bool ShadowRoot::containsShadowElements() const
+{
+    return m_scopeDistribution ? m_scopeDistribution->hasShadowElementChildren() : 0;
+}
+
+bool ShadowRoot::containsContentElements() const
+{
+    return m_scopeDistribution ? m_scopeDistribution->hasContentElementChildren() : 0;
+}
+
+bool ShadowRoot::containsShadowRoots() const
+{
+    return m_scopeDistribution ? m_scopeDistribution->numberOfElementShadowChildren() : 0;
+}
+
+InsertionPoint* ShadowRoot::insertionPoint() const
+{
+    return m_scopeDistribution ? m_scopeDistribution->insertionPointAssignedTo() : 0;
+}
+
 }
diff --git a/Source/core/dom/shadow/ShadowRoot.h b/Source/core/dom/shadow/ShadowRoot.h
index 4e9c5e5..3759557 100644
--- a/Source/core/dom/shadow/ShadowRoot.h
+++ b/Source/core/dom/shadow/ShadowRoot.h
@@ -38,6 +38,7 @@
 namespace WebCore {
 
 class ElementShadow;
+class InsertionPoint;
 class ScopeContentDistribution;
 
 class ShadowRoot FINAL : public DocumentFragment, public TreeScope, public DoublyLinkedListNode<ShadowRoot> {
@@ -93,6 +94,12 @@
     const ScopeContentDistribution* scopeDistribution() const { return m_scopeDistribution.get(); }
     ScopeContentDistribution* ensureScopeDistribution();
 
+    bool containsShadowElements() const;
+    bool containsContentElements() const;
+    bool containsInsertionPoints() const { return containsShadowElements() || containsContentElements(); }
+    bool containsShadowRoots() const;
+    InsertionPoint* insertionPoint() const;
+
     ShadowRootType type() const { return static_cast<ShadowRootType>(m_type); }
 
     PassRefPtr<Node> cloneNode(bool, ExceptionCode&);
diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp
index 9c662c4..8ae0f56 100644
--- a/Source/core/editing/FrameSelection.cpp
+++ b/Source/core/editing/FrameSelection.cpp
@@ -604,11 +604,13 @@
     return positionAfterCurrentWord;
 }
 
+#if ENABLE(USERSELECT_ALL)
 static void adjustPositionForUserSelectAll(VisiblePosition& pos, bool isForward)
 {
     if (Node* rootUserSelectAll = Position::rootUserSelectAllForNode(pos.deepEquivalent().anchorNode()))
         pos = isForward ? positionAfterNode(rootUserSelectAll).downstream(CanCrossEditingBoundary) : positionBeforeNode(rootUserSelectAll).upstream(CanCrossEditingBoundary);
 }
+#endif
 
 VisiblePosition FrameSelection::modifyExtendingRight(TextGranularity granularity)
 {
@@ -648,7 +650,9 @@
         pos = modifyExtendingForward(granularity);
         break;
     }
+#if ENABLE(USERSELECT_ALL)
     adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR);
+#endif
     return pos;
 }
 
@@ -688,7 +692,9 @@
             pos = endOfDocument(pos);
         break;
     }
+#if ENABLE(USERSELECT_ALL)
      adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR);
+#endif
     return pos;
 }
 
@@ -811,7 +817,9 @@
         pos = modifyExtendingBackward(granularity);
         break;
     }
+#if ENABLE(USERSELECT_ALL)
     adjustPositionForUserSelectAll(pos, !(directionOfEnclosingBlock() == LTR));
+#endif
     return pos;
 }
        
@@ -856,7 +864,9 @@
             pos = startOfDocument(pos);
         break;
     }
+#if ENABLE(USERSELECT_ALL)
     adjustPositionForUserSelectAll(pos, !(directionOfEnclosingBlock() == LTR));
+#endif
     return pos;
 }
 
@@ -1463,7 +1473,7 @@
         element = node->parentElement();
 
     if (element && element->renderer())
-        caretColor = element->renderer()->style()->visitedDependentColor(CSSPropertyColor);
+        caretColor = element->renderer()->resolveColor(CSSPropertyColor);
 
     context->fillRect(caret, caretColor);
 }
diff --git a/Source/core/editing/MarkupAccumulator.cpp b/Source/core/editing/MarkupAccumulator.cpp
index cdd87cf..6a4a5d0 100644
--- a/Source/core/editing/MarkupAccumulator.cpp
+++ b/Source/core/editing/MarkupAccumulator.cpp
@@ -286,8 +286,8 @@
         return;
 
     // Use emptyAtoms's impl() for both null and empty strings since the HashMap can't handle 0 as a key
-    AtomicStringImpl* pre = prefix.isEmpty() ? emptyAtom.impl() : prefix.impl();
-    AtomicStringImpl* foundNS = namespaces.get(pre);
+    StringImpl* pre = prefix.isEmpty() ? emptyAtom.impl() : prefix.impl();
+    StringImpl* foundNS = namespaces.get(pre);
     if (foundNS != namespaceURI.impl()) {
         namespaces.set(pre, namespaceURI.impl());
         result.append(' ');
diff --git a/Source/core/editing/MarkupAccumulator.h b/Source/core/editing/MarkupAccumulator.h
index fd0fc36..498548a 100644
--- a/Source/core/editing/MarkupAccumulator.h
+++ b/Source/core/editing/MarkupAccumulator.h
@@ -39,7 +39,7 @@
 class Node;
 class Range;
 
-typedef HashMap<AtomicStringImpl*, AtomicStringImpl*> Namespaces;
+typedef HashMap<StringImpl*, StringImpl*> Namespaces;
 
 enum EntityMask {
     EntityAmp = 0x0001,
diff --git a/Source/core/editing/SetNodeAttributeCommand.cpp b/Source/core/editing/SetNodeAttributeCommand.cpp
index bb97c12..697234f 100644
--- a/Source/core/editing/SetNodeAttributeCommand.cpp
+++ b/Source/core/editing/SetNodeAttributeCommand.cpp
@@ -50,7 +50,7 @@
 void SetNodeAttributeCommand::doUnapply()
 {
     m_element->setAttribute(m_attribute, m_oldValue);
-    AtomicStringImpl* nullString = 0;
+    StringImpl* nullString = 0;
     m_oldValue = nullString;
 }
 
diff --git a/Source/core/editing/VisibleUnits.cpp b/Source/core/editing/VisibleUnits.cpp
index 46abad5..141fae1 100644
--- a/Source/core/editing/VisibleUnits.cpp
+++ b/Source/core/editing/VisibleUnits.cpp
@@ -1107,7 +1107,11 @@
 
     Node* n = startNode;
     while (n) {
+#if ENABLE(USERSELECT_ALL)
         if (boundaryCrossingRule == CannotCrossEditingBoundary && !Position::nodeIsUserSelectAll(n) && n->rendererIsEditable() != startNode->rendererIsEditable())
+#else
+        if (boundaryCrossingRule == CannotCrossEditingBoundary && n->rendererIsEditable() != startNode->rendererIsEditable())
+#endif
             break;
         if (boundaryCrossingRule == CanSkipOverEditingBoundary) {
             while (n && n->rendererIsEditable() != startNode->rendererIsEditable())
@@ -1183,7 +1187,11 @@
 
     Node* n = startNode;
     while (n) {
+#if ENABLE(USERSELECT_ALL)
         if (boundaryCrossingRule == CannotCrossEditingBoundary && !Position::nodeIsUserSelectAll(n) && n->rendererIsEditable() != startNode->rendererIsEditable())
+#else
+        if (boundaryCrossingRule == CannotCrossEditingBoundary && n->rendererIsEditable() != startNode->rendererIsEditable())
+#endif
             break;
         if (boundaryCrossingRule == CanSkipOverEditingBoundary) {
             while (n && n->rendererIsEditable() != startNode->rendererIsEditable())
diff --git a/Source/core/editing/htmlediting.cpp b/Source/core/editing/htmlediting.cpp
index a2fd9aa..c00896f 100644
--- a/Source/core/editing/htmlediting.cpp
+++ b/Source/core/editing/htmlediting.cpp
@@ -448,11 +448,6 @@
     return 0;
 }
 
-bool isFirstVisiblePositionInSpecialElement(const Position& pos)
-{
-    return firstInSpecialElement(pos);
-}
-
 Position positionBeforeContainingSpecialElement(const Position& pos, Node** containingSpecialElement)
 {
     Node* n = firstInSpecialElement(pos);
@@ -466,11 +461,6 @@
     return result;
 }
 
-bool isLastVisiblePositionInSpecialElement(const Position& pos)
-{
-    return lastInSpecialElement(pos);
-}
-
 Position positionAfterContainingSpecialElement(const Position& pos, Node **containingSpecialElement)
 {
     Node* n = lastInSpecialElement(pos);
@@ -484,15 +474,6 @@
     return result;
 }
 
-Position positionOutsideContainingSpecialElement(const Position &pos, Node **containingSpecialElement)
-{
-    if (isFirstVisiblePositionInSpecialElement(pos))
-        return positionBeforeContainingSpecialElement(pos, containingSpecialElement);
-    if (isLastVisiblePositionInSpecialElement(pos))
-        return positionAfterContainingSpecialElement(pos, containingSpecialElement);
-    return pos;
-}
-
 Node* isFirstPositionAfterTable(const VisiblePosition& visiblePosition)
 {
     Position upstream(visiblePosition.deepEquivalent().upstream());
@@ -546,33 +527,6 @@
     return selectedRange.release();
 }
 
-// Extend rangeToExtend to include nodes that wraps range and visibly starts and ends inside or at the boudnaries of maximumRange
-// e.g. if the original range spaned "hello" in <div>hello</div>, then this function extends the range to contain div's around it.
-// Call this function before copying / moving paragraphs to contain all wrapping nodes.
-// This function stops extending the range immediately below rootNode; i.e. the extended range can contain a child node of rootNode
-// but it can never contain rootNode itself.
-PassRefPtr<Range> extendRangeToWrappingNodes(PassRefPtr<Range> range, const Range* maximumRange, const Node* rootNode)
-{
-    ASSERT(range);
-    ASSERT(maximumRange);
-
-    Node* ancestor = range->commonAncestorContainer(IGNORE_EXCEPTION); // Find the closest common ancestor.
-    Node* highestNode = 0;
-    // traverse through ancestors as long as they are contained within the range, content-editable, and below rootNode (could be =0).
-    while (ancestor && ancestor->rendererIsEditable() && isNodeVisiblyContainedWithin(ancestor, maximumRange) && ancestor != rootNode) {
-        highestNode = ancestor;
-        ancestor = ancestor->parentNode();
-    }
-
-    if (!highestNode)
-        return range;
-
-    // Create new range with the highest editable node contained within the range
-    RefPtr<Range> extendedRange = Range::create(range->ownerDocument());
-    extendedRange->selectNode(highestNode, IGNORE_EXCEPTION);
-    return extendedRange.release();
-}
-
 bool isListElement(Node *n)
 {
     return (n && (n->hasTagName(ulTag) || n->hasTagName(olTag) || n->hasTagName(dlTag)));
diff --git a/Source/core/editing/htmlediting.h b/Source/core/editing/htmlediting.h
index 243c47c..de1496f 100644
--- a/Source/core/editing/htmlediting.h
+++ b/Source/core/editing/htmlediting.h
@@ -37,7 +37,6 @@
 class Document;
 class Element;
 class HTMLElement;
-class HTMLTextFormControlElement;
 class Node;
 class Position;
 class Range;
@@ -130,7 +129,6 @@
 Position positionOutsideTabSpan(const Position&);
 Position positionBeforeContainingSpecialElement(const Position&, Node** containingSpecialElement = 0);
 Position positionAfterContainingSpecialElement(const Position&, Node** containingSpecialElement = 0);
-Position positionOutsideContainingSpecialElement(const Position&, Node** containingSpecialElement = 0);
 
 inline Position firstPositionInOrBeforeNode(Node* node)
 {
@@ -155,8 +153,6 @@
 enum EUpdateStyle { UpdateStyle, DoNotUpdateStyle };
 bool isEditablePosition(const Position&, EditableType = ContentIsEditable, EUpdateStyle = UpdateStyle);
 bool isRichlyEditablePosition(const Position&, EditableType = ContentIsEditable);
-bool isFirstVisiblePositionInSpecialElement(const Position&);
-bool isLastVisiblePositionInSpecialElement(const Position&);
 bool lineBreakExistsAtPosition(const Position&);
 bool isVisiblyAdjacent(const Position& first, const Position& second);
 bool isAtUnsplittableElement(const Position&);
@@ -191,7 +187,6 @@
 // Functions returning Range
 
 PassRefPtr<Range> createRange(PassRefPtr<Document>, const VisiblePosition& start, const VisiblePosition& end, ExceptionCode&);
-PassRefPtr<Range> extendRangeToWrappingNodes(PassRefPtr<Range> rangeToExtend, const Range* maximumRange, const Node* rootNode);
 
 // -------------------------------------------------------------------------
 // HTMLElement
diff --git a/Source/core/html/ColorInputType.cpp b/Source/core/html/ColorInputType.cpp
index e6278d4..a0fc7dd 100644
--- a/Source/core/html/ColorInputType.cpp
+++ b/Source/core/html/ColorInputType.cpp
@@ -61,7 +61,7 @@
     // We don't accept #rgb and #aarrggbb formats.
     if (value.length() != 7)
         return false;
-    Color color(value);
+    StyleColor color(value);
     return color.isValid() && !color.hasAlpha();
 }
 
@@ -108,9 +108,9 @@
     return proposedValue.lower();
 }
 
-Color ColorInputType::valueAsColor() const
+StyleColor ColorInputType::valueAsColor() const
 {
-    return Color(element()->value());
+    return StyleColor(element()->value());
 }
 
 void ColorInputType::createShadowSubtree()
@@ -137,7 +137,7 @@
 
     updateColorSwatch();
     if (m_chooser)
-        m_chooser->setSelectedColor(valueAsColor());
+        m_chooser->setSelectedColor(valueAsColor().color());
 }
 
 void ColorInputType::handleDOMActivateEvent(Event* event)
@@ -150,7 +150,7 @@
 
     Chrome* chrome = this->chrome();
     if (chrome && !m_chooser)
-        m_chooser = chrome->createColorChooser(this, valueAsColor());
+        m_chooser = chrome->createColorChooser(this, valueAsColor().color());
 
     event->setDefaultHandled();
 }
@@ -196,7 +196,7 @@
     if (!colorSwatch)
         return;
 
-    colorSwatch->setInlineStyleProperty(CSSPropertyBackgroundColor, element()->value(), false);
+    colorSwatch->setInlineStyleProperty(CSSPropertyBackgroundColor, element()->value());
 }
 
 HTMLElement* ColorInputType::shadowColorSwatch() const
@@ -212,7 +212,7 @@
 
 Color ColorInputType::currentColor()
 {
-    return valueAsColor();
+    return valueAsColor().color();
 }
 
 bool ColorInputType::shouldShowSuggestions() const
@@ -233,10 +233,10 @@
             for (unsigned i = 0; HTMLOptionElement* option = toHTMLOptionElement(options->item(i)); i++) {
                 if (!element()->isValidValue(option->value()))
                     continue;
-                Color color(option->value());
+                StyleColor color(option->value());
                 if (!color.isValid())
                     continue;
-                suggestions.append(color);
+                suggestions.append(color.color());
             }
         }
     }
diff --git a/Source/core/html/ColorInputType.h b/Source/core/html/ColorInputType.h
index 161d912..fedaac7 100644
--- a/Source/core/html/ColorInputType.h
+++ b/Source/core/html/ColorInputType.h
@@ -64,7 +64,7 @@
     virtual bool shouldRespectListAttribute() OVERRIDE;
     virtual bool typeMismatchFor(const String&) const OVERRIDE;
 
-    Color valueAsColor() const;
+    StyleColor valueAsColor() const;
     void endColorChooser();
     void updateColorSwatch();
     HTMLElement* shadowColorSwatch() const;
diff --git a/Source/core/html/FileInputType.cpp b/Source/core/html/FileInputType.cpp
index 6804ebb..c8820eb 100644
--- a/Source/core/html/FileInputType.cpp
+++ b/Source/core/html/FileInputType.cpp
@@ -37,7 +37,6 @@
 #include "core/platform/DragData.h"
 #include "core/platform/FileSystem.h"
 #include "core/platform/LocalizedStrings.h"
-#include "core/platform/graphics/Icon.h"
 #include "core/rendering/RenderFileUploadControl.h"
 #include "wtf/PassOwnPtr.h"
 #include "wtf/text/StringBuilder.h"
@@ -212,7 +211,6 @@
 void FileInputType::setValue(const String&, bool, TextFieldEventBehavior)
 {
     m_fileList->clear();
-    m_icon.clear();
     element()->setNeedsStyleRecalc();
 }
 
@@ -278,15 +276,6 @@
         button->setAttribute(valueAttr, element()->multiple() ? fileButtonChooseMultipleFilesLabel() : fileButtonChooseFileLabel());
 }
 
-void FileInputType::requestIcon(const Vector<String>& paths)
-{
-    if (!paths.size())
-        return;
-
-    if (Chrome* chrome = this->chrome())
-        chrome->loadIconForFiles(paths, newFileIconLoader());
-}
-
 void FileInputType::setFiles(PassRefPtr<FileList> files)
 {
     if (!files)
@@ -315,7 +304,6 @@
     Vector<String> paths;
     for (unsigned i = 0; i < m_fileList->length(); ++i)
         paths.append(m_fileList->item(i)->path());
-    requestIcon(paths);
 
     if (input->renderer())
         input->renderer()->repaint();
@@ -347,16 +335,6 @@
     }
 }
 
-void FileInputType::updateRendering(PassRefPtr<Icon> icon)
-{
-    if (m_icon == icon)
-        return;
-
-    m_icon = icon;
-    if (element()->renderer())
-        element()->renderer()->repaint();
-}
-
 bool FileInputType::receiveDroppedFiles(const DragData* dragData)
 {
     Vector<String> paths;
@@ -391,11 +369,6 @@
     return m_droppedFileSystemId;
 }
 
-Icon* FileInputType::icon() const
-{
-    return m_icon.get();
-}
-
 String FileInputType::defaultToolTip() const
 {
     FileList* fileList = m_fileList.get();
diff --git a/Source/core/html/FileInputType.h b/Source/core/html/FileInputType.h
index 71f626a..2ec2682 100644
--- a/Source/core/html/FileInputType.h
+++ b/Source/core/html/FileInputType.h
@@ -34,7 +34,6 @@
 
 #include "core/html/BaseClickableWithKeyInputType.h"
 #include "core/platform/FileChooser.h"
-#include "core/platform/FileIconLoader.h"
 #include "wtf/RefPtr.h"
 
 namespace WebCore {
@@ -42,7 +41,7 @@
 class DragData;
 class FileList;
 
-class FileInputType : public BaseClickableWithKeyInputType, private FileChooserClient, private FileIconLoaderClient {
+class FileInputType : public BaseClickableWithKeyInputType, private FileChooserClient {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
     static Vector<FileChooserFileInfo> filesFromFormControlState(const FormControlState&);
@@ -66,7 +65,6 @@
     virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) OVERRIDE;
     virtual bool receiveDroppedFiles(const DragData*) OVERRIDE;
     virtual String droppedFileSystemId() OVERRIDE;
-    virtual Icon* icon() const OVERRIDE;
     virtual bool isFileUpload() const OVERRIDE;
     virtual void createShadowSubtree() OVERRIDE;
     virtual void disabledAttributeChanged() OVERRIDE;
@@ -76,15 +74,10 @@
     // FileChooserClient implementation.
     virtual void filesChosen(const Vector<FileChooserFileInfo>&) OVERRIDE;
 
-    // FileIconLoaderClient implementation.
-    virtual void updateRendering(PassRefPtr<Icon>) OVERRIDE;
-
     PassRefPtr<FileList> createFileList(const Vector<FileChooserFileInfo>& files) const;
     void receiveDropForDirectoryUpload(const Vector<String>&);
-    void requestIcon(const Vector<String>&);
 
     RefPtr<FileList> m_fileList;
-    RefPtr<Icon> m_icon;
 
     String m_droppedFileSystemId;
 };
diff --git a/Source/core/html/FormAssociatedElement.cpp b/Source/core/html/FormAssociatedElement.cpp
index a9533cb..21cb452 100644
--- a/Source/core/html/FormAssociatedElement.cpp
+++ b/Source/core/html/FormAssociatedElement.cpp
@@ -176,7 +176,8 @@
         m_formAttributeTargetObserver = nullptr;
     } else {
         resetFormOwner();
-        resetFormAttributeTargetObserver();
+        if (element->inDocument())
+            resetFormAttributeTargetObserver();
     }
 }
 
@@ -250,6 +251,7 @@
 
 void FormAssociatedElement::resetFormAttributeTargetObserver()
 {
+    ASSERT(toHTMLElement(this)->inDocument());
     m_formAttributeTargetObserver = FormAttributeTargetObserver::create(toHTMLElement(this)->fastGetAttribute(formAttr), this);
 }
 
diff --git a/Source/core/html/FormController.cpp b/Source/core/html/FormController.cpp
index dc05f48..5b2ff3c 100644
--- a/Source/core/html/FormController.cpp
+++ b/Source/core/html/FormController.cpp
@@ -82,13 +82,13 @@
 
 class FormElementKey {
 public:
-    FormElementKey(AtomicStringImpl* = 0, AtomicStringImpl* = 0);
+    FormElementKey(StringImpl* = 0, StringImpl* = 0);
     ~FormElementKey();
     FormElementKey(const FormElementKey&);
     FormElementKey& operator=(const FormElementKey&);
 
-    AtomicStringImpl* name() const { return m_name; }
-    AtomicStringImpl* type() const { return m_type; }
+    StringImpl* name() const { return m_name; }
+    StringImpl* type() const { return m_type; }
 
     // Hash table deleted values, which are only constructed and never copied or destroyed.
     FormElementKey(WTF::HashTableDeletedValueType) : m_name(hashTableDeletedValue()) { }
@@ -98,13 +98,13 @@
     void ref() const;
     void deref() const;
 
-    static AtomicStringImpl* hashTableDeletedValue() { return reinterpret_cast<AtomicStringImpl*>(-1); }
+    static StringImpl* hashTableDeletedValue() { return reinterpret_cast<StringImpl*>(-1); }
 
-    AtomicStringImpl* m_name;
-    AtomicStringImpl* m_type;
+    StringImpl* m_name;
+    StringImpl* m_type;
 };
 
-FormElementKey::FormElementKey(AtomicStringImpl* name, AtomicStringImpl* type)
+FormElementKey::FormElementKey(StringImpl* name, StringImpl* type)
     : m_name(name)
     , m_type(type)
 {
@@ -415,7 +415,7 @@
     stateVector.reserveInitialCapacity(m_formElementsWithState.size() * 4);
     stateVector.append(formStateSignature());
     for (SavedFormStateMap::const_iterator it = stateMap->begin(); it != stateMap->end(); ++it) {
-        stateVector.append(it->key.get());
+        stateVector.append(it->key);
         it->value->serializeTo(stateVector);
     }
     bool hasOnlySignature = stateVector.size() == 1;
diff --git a/Source/core/html/FormController.h b/Source/core/html/FormController.h
index 9276e79..5609075 100644
--- a/Source/core/html/FormController.h
+++ b/Source/core/html/FormController.h
@@ -26,7 +26,7 @@
 #include "wtf/Forward.h"
 #include "wtf/ListHashSet.h"
 #include "wtf/Vector.h"
-#include "wtf/text/WTFString.h"
+#include "wtf/text/AtomicStringHash.h"
 
 namespace WebCore {
 
@@ -96,7 +96,7 @@
 
 private:
     typedef ListHashSet<RefPtr<HTMLFormControlElementWithState>, 64> FormElementListHashSet;
-    typedef HashMap<RefPtr<AtomicStringImpl>, OwnPtr<SavedFormState> > SavedFormStateMap;
+    typedef HashMap<AtomicString, OwnPtr<SavedFormState> > SavedFormStateMap;
 
     FormController();
     static PassOwnPtr<SavedFormStateMap> createSavedFormStateMap(const FormElementListHashSet&);
diff --git a/Source/core/html/HTMLCollection.h b/Source/core/html/HTMLCollection.h
index d76c61e..585cd9e 100644
--- a/Source/core/html/HTMLCollection.h
+++ b/Source/core/html/HTMLCollection.h
@@ -70,7 +70,7 @@
 
     virtual void updateNameCache() const;
 
-    typedef HashMap<AtomicStringImpl*, OwnPtr<Vector<Element*> > > NodeCacheMap;
+    typedef HashMap<StringImpl*, OwnPtr<Vector<Element*> > > NodeCacheMap;
     Vector<Element*>* idCache(const AtomicString& name) const { return m_idCache.get(name.impl()); }
     Vector<Element*>* nameCache(const AtomicString& name) const { return m_nameCache.get(name.impl()); }
     void appendIdCache(const AtomicString& name, Element* element) const { append(m_idCache, name, element); }
diff --git a/Source/core/html/HTMLDetailsElement.cpp b/Source/core/html/HTMLDetailsElement.cpp
index 4147245..4b6e3fd 100644
--- a/Source/core/html/HTMLDetailsElement.cpp
+++ b/Source/core/html/HTMLDetailsElement.cpp
@@ -98,15 +98,10 @@
 
 bool HTMLDetailsElement::childShouldCreateRenderer(const NodeRenderingContext& childContext) const
 {
-    if (!childContext.isOnEncapsulationBoundary())
-        return false;
-
     if (m_isOpen)
         return HTMLElement::childShouldCreateRenderer(childContext);
-
     if (!childContext.node()->hasTagName(summaryTag))
         return false;
-
     return childContext.node() == findMainSummary() && HTMLElement::childShouldCreateRenderer(childContext);
 }
 
diff --git a/Source/core/html/HTMLDetailsElement.h b/Source/core/html/HTMLDetailsElement.h
index 565bba9..ea0ffbe 100644
--- a/Source/core/html/HTMLDetailsElement.h
+++ b/Source/core/html/HTMLDetailsElement.h
@@ -44,6 +44,22 @@
     bool m_isOpen;
 };
 
+inline bool isHTMLDetailsElement(const Node* node)
+{
+    return node->hasTagName(HTMLNames::detailsTag);
+}
+
+inline bool isHTMLDetailsElement(const Element* element)
+{
+    return element->hasTagName(HTMLNames::detailsTag);
+}
+
+inline HTMLDetailsElement* toHTMLDetailsElement(Node* node)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLDetailsElement(node));
+    return static_cast<HTMLDetailsElement*>(node);
+}
+
 } // namespace WebCore
 
 #endif // HTMLDetailsElement_h
diff --git a/Source/core/html/HTMLDocument.cpp b/Source/core/html/HTMLDocument.cpp
index 90ccd0f..1af0f73 100644
--- a/Source/core/html/HTMLDocument.cpp
+++ b/Source/core/html/HTMLDocument.cpp
@@ -220,7 +220,7 @@
 // not part of the DOM
 // --------------------------------------------------------------------------
 
-void HTMLDocument::addItemToMap(HashCountedSet<AtomicStringImpl*>& map, const AtomicString& name)
+void HTMLDocument::addItemToMap(HashCountedSet<StringImpl*>& map, const AtomicString& name)
 {
     if (name.isEmpty())
         return;
@@ -229,7 +229,7 @@
         f->script()->namedItemAdded(this, name);
 }
 
-void HTMLDocument::removeItemFromMap(HashCountedSet<AtomicStringImpl*>& map, const AtomicString& name)
+void HTMLDocument::removeItemFromMap(HashCountedSet<StringImpl*>& map, const AtomicString& name)
 {
     if (name.isEmpty())
         return;
@@ -258,16 +258,16 @@
     removeItemFromMap(m_extraNamedItemCounts, name);
 }
 
-static void addLocalNameToSet(HashSet<AtomicStringImpl*>* set, const QualifiedName& qName)
+static void addLocalNameToSet(HashSet<StringImpl*>* set, const QualifiedName& qName)
 {
     set->add(qName.localName().impl());
 }
 
-static HashSet<AtomicStringImpl*>* createHtmlCaseInsensitiveAttributesSet()
+static HashSet<StringImpl*>* createHtmlCaseInsensitiveAttributesSet()
 {
     // This is the list of attributes in HTML 4.01 with values marked as "[CI]" or case-insensitive
     // Mozilla treats all other values as case-sensitive, thus so do we.
-    HashSet<AtomicStringImpl*>* attrSet = new HashSet<AtomicStringImpl*>;
+    HashSet<StringImpl*>* attrSet = new HashSet<StringImpl*>;
 
     addLocalNameToSet(attrSet, accept_charsetAttr);
     addLocalNameToSet(attrSet, acceptAttr);
@@ -320,7 +320,7 @@
 
 bool HTMLDocument::isCaseSensitiveAttribute(const QualifiedName& attributeName)
 {
-    static HashSet<AtomicStringImpl*>* htmlCaseInsensitiveAttributesSet = createHtmlCaseInsensitiveAttributesSet();
+    static HashSet<StringImpl*>* htmlCaseInsensitiveAttributesSet = createHtmlCaseInsensitiveAttributesSet();
     bool isPossibleHTMLAttr = !attributeName.hasPrefix() && (attributeName.namespaceURI() == nullAtom);
     return !isPossibleHTMLAttr || !htmlCaseInsensitiveAttributesSet->contains(attributeName.localName().impl());
 }
diff --git a/Source/core/html/HTMLDocument.h b/Source/core/html/HTMLDocument.h
index 369758a..c224741 100644
--- a/Source/core/html/HTMLDocument.h
+++ b/Source/core/html/HTMLDocument.h
@@ -65,11 +65,11 @@
 
     void addNamedItem(const AtomicString& name);
     void removeNamedItem(const AtomicString& name);
-    bool hasNamedItem(AtomicStringImpl* name);
+    bool hasNamedItem(StringImpl* name);
 
     void addExtraNamedItem(const AtomicString& name);
     void removeExtraNamedItem(const AtomicString& name);
-    bool hasExtraNamedItem(AtomicStringImpl* name);
+    bool hasExtraNamedItem(StringImpl* name);
 
     static bool isCaseSensitiveAttribute(const QualifiedName&);
 
@@ -78,20 +78,20 @@
 
 private:
     HTMLBodyElement* bodyAsHTMLBodyElement() const;
-    void addItemToMap(HashCountedSet<AtomicStringImpl*>&, const AtomicString&);
-    void removeItemFromMap(HashCountedSet<AtomicStringImpl*>&, const AtomicString&);
+    void addItemToMap(HashCountedSet<StringImpl*>&, const AtomicString&);
+    void removeItemFromMap(HashCountedSet<StringImpl*>&, const AtomicString&);
 
-    HashCountedSet<AtomicStringImpl*> m_namedItemCounts;
-    HashCountedSet<AtomicStringImpl*> m_extraNamedItemCounts;
+    HashCountedSet<StringImpl*> m_namedItemCounts;
+    HashCountedSet<StringImpl*> m_extraNamedItemCounts;
 };
 
-inline bool HTMLDocument::hasNamedItem(AtomicStringImpl* name)
+inline bool HTMLDocument::hasNamedItem(StringImpl* name)
 {
     ASSERT(name);
     return m_namedItemCounts.contains(name);
 }
 
-inline bool HTMLDocument::hasExtraNamedItem(AtomicStringImpl* name)
+inline bool HTMLDocument::hasExtraNamedItem(StringImpl* name)
 {
     ASSERT(name);
     return m_extraNamedItemCounts.contains(name);
diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp
index 54a2bbb..2b9bf86 100644
--- a/Source/core/html/HTMLElement.cpp
+++ b/Source/core/html/HTMLElement.cpp
@@ -1054,9 +1054,9 @@
         return;
 
     // If the string is a named CSS color or a 3/6-digit hex color, use that.
-    Color parsedColor(colorString);
+    StyleColor parsedColor(colorString);
     if (!parsedColor.isValid())
-        parsedColor.setRGB(parseColorStringWithCrazyLegacyRules(colorString));
+        parsedColor = parseColorStringWithCrazyLegacyRules(colorString);
 
     style->setProperty(propertyID, cssValuePool().createColorValue(parsedColor.rgb()));
 }
diff --git a/Source/core/html/HTMLFormControlsCollection.cpp b/Source/core/html/HTMLFormControlsCollection.cpp
index f1f06aa..a432b1b 100644
--- a/Source/core/html/HTMLFormControlsCollection.cpp
+++ b/Source/core/html/HTMLFormControlsCollection.cpp
@@ -122,7 +122,7 @@
     if (hasNameCache())
         return;
 
-    HashSet<AtomicStringImpl*> foundInputElements;
+    HashSet<StringImpl*> foundInputElements;
 
     const Vector<FormAssociatedElement*>& elementsArray = formControlElements();
 
diff --git a/Source/core/html/HTMLFormElement.h b/Source/core/html/HTMLFormElement.h
index c3fd077..a0bd172 100644
--- a/Source/core/html/HTMLFormElement.h
+++ b/Source/core/html/HTMLFormElement.h
@@ -157,7 +157,7 @@
     // are any invalid controls in this form.
     bool checkInvalidControlsAndCollectUnhandled(Vector<RefPtr<FormAssociatedElement> >*, HTMLFormControlElement::CheckValidityDispatchEvents = HTMLFormControlElement::CheckValidityDispatchEventsAllowed);
 
-    typedef HashMap<RefPtr<AtomicStringImpl>, RefPtr<Node> > AliasMap;
+    typedef HashMap<AtomicString, RefPtr<Node> > AliasMap;
 
     FormSubmission::Attributes m_attributes;
     OwnPtr<AliasMap> m_elementAliases;
diff --git a/Source/core/html/HTMLInputElement.cpp b/Source/core/html/HTMLInputElement.cpp
index 3325cf9..07a317a 100644
--- a/Source/core/html/HTMLInputElement.cpp
+++ b/Source/core/html/HTMLInputElement.cpp
@@ -1376,11 +1376,6 @@
     return m_inputType->droppedFileSystemId();
 }
 
-Icon* HTMLInputElement::icon() const
-{
-    return m_inputType->icon();
-}
-
 bool HTMLInputElement::canReceiveDroppedFiles() const
 {
     return m_canReceiveDroppedFiles;
diff --git a/Source/core/html/HTMLInputElement.h b/Source/core/html/HTMLInputElement.h
index b45046d..97d068b 100644
--- a/Source/core/html/HTMLInputElement.h
+++ b/Source/core/html/HTMLInputElement.h
@@ -300,10 +300,6 @@
 private:
     enum AutoCompleteSetting { Uninitialized, On, Off };
 
-    // FIXME: Author shadows should be allowed
-    // https://bugs.webkit.org/show_bug.cgi?id=92608
-    virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
-
     virtual void didAddUserAgentShadowRoot(ShadowRoot*) OVERRIDE;
 
     virtual void willChangeForm() OVERRIDE;
diff --git a/Source/core/html/HTMLInputElement.idl b/Source/core/html/HTMLInputElement.idl
index b4db40f..2911901 100644
--- a/Source/core/html/HTMLInputElement.idl
+++ b/Source/core/html/HTMLInputElement.idl
@@ -30,6 +30,8 @@
     [Reflect] attribute DOMString dirName;
     [Reflect] attribute boolean disabled;
     readonly attribute HTMLFormElement form;
+    // The 'files' attribute is intentionally not readonly.
+    // https://www.w3.org/Bugs/Public/show_bug.cgi?id=22682
     attribute FileList files;
     [Reflect, URL] attribute DOMString formAction;
     [TreatNullAs=NullString] attribute DOMString formEnctype;
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index 13cc476..1f180db 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -353,6 +353,8 @@
 
 void HTMLMediaElement::didMoveToNewDocument(Document* oldDocument)
 {
+    LOG(Media, "HTMLMediaElement::didMoveToNewDocument");
+
     if (m_shouldDelayLoadEvent) {
         if (oldDocument)
             oldDocument->decrementLoadEventDelayCount();
@@ -364,6 +366,13 @@
 
     addElementToDocumentMap(this, document());
 
+    // FIXME: This is a temporary fix to prevent this object from causing the
+    // MediaPlayer to dereference Frame and FrameLoader pointers from the
+    // previous document. A proper fix would provide a mechanism to allow this
+    // object to refresh the MediaPlayer's Frame and FrameLoader references on
+    // document changes so that playback can be resumed properly.
+    userCancelledLoad();
+
     HTMLElement::didMoveToNewDocument(oldDocument);
 }
 
@@ -491,14 +500,7 @@
 
 bool HTMLMediaElement::childShouldCreateRenderer(const NodeRenderingContext& childContext) const
 {
-    if (!hasMediaControls())
-        return false;
-    // <media> doesn't allow its content, including shadow subtree, to
-    // be rendered. So this should return false for most of the children.
-    // One exception is a shadow tree built for rendering controls which should be visible.
-    // So we let them go here by comparing its subtree root with one of the controls.
-    return (mediaControls()->treeScope() == childContext.node()->treeScope()
-            && childContext.isOnUpperEncapsulationBoundary() && HTMLElement::childShouldCreateRenderer(childContext));
+    return hasMediaControls() && HTMLElement::childShouldCreateRenderer(childContext);
 }
 
 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint)
diff --git a/Source/core/html/HTMLMeterElement.cpp b/Source/core/html/HTMLMeterElement.cpp
index b8b59e0..891cdb0 100644
--- a/Source/core/html/HTMLMeterElement.cpp
+++ b/Source/core/html/HTMLMeterElement.cpp
@@ -62,11 +62,6 @@
     return new (document()->renderArena()) RenderMeter(this);
 }
 
-bool HTMLMeterElement::childShouldCreateRenderer(const NodeRenderingContext& childContext) const
-{
-    return childContext.isOnUpperEncapsulationBoundary() && HTMLElement::childShouldCreateRenderer(childContext);
-}
-
 void HTMLMeterElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
     if (name == valueAttr || name == minAttr || name == maxAttr || name == lowAttr || name == highAttr || name == optimumAttr)
diff --git a/Source/core/html/HTMLMeterElement.h b/Source/core/html/HTMLMeterElement.h
index 0411f71..b40093c 100644
--- a/Source/core/html/HTMLMeterElement.h
+++ b/Source/core/html/HTMLMeterElement.h
@@ -72,7 +72,6 @@
 
     virtual bool recalcWillValidate() const { return false; }
     virtual RenderObject* createRenderer(RenderStyle*);
-    virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OVERRIDE;
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
 
     void didElementStateChange();
diff --git a/Source/core/html/HTMLObjectElement.cpp b/Source/core/html/HTMLObjectElement.cpp
index 87cf60f..17a14cc 100644
--- a/Source/core/html/HTMLObjectElement.cpp
+++ b/Source/core/html/HTMLObjectElement.cpp
@@ -384,7 +384,7 @@
 // FIXME: This should be removed, all callers are almost certainly wrong.
 static bool isRecognizedTagName(const QualifiedName& tagName)
 {
-    DEFINE_STATIC_LOCAL(HashSet<AtomicStringImpl*>, tagList, ());
+    DEFINE_STATIC_LOCAL(HashSet<StringImpl*>, tagList, ());
     if (tagList.isEmpty()) {
         QualifiedName** tags = HTMLNames::getHTMLTags();
         for (size_t i = 0; i < HTMLNames::HTMLTagsCount; i++) {
diff --git a/Source/core/html/HTMLProgressElement.cpp b/Source/core/html/HTMLProgressElement.cpp
index 3aad685..98d7de6 100644
--- a/Source/core/html/HTMLProgressElement.cpp
+++ b/Source/core/html/HTMLProgressElement.cpp
@@ -64,11 +64,6 @@
     return new (document()->renderArena()) RenderProgress(this);
 }
 
-bool HTMLProgressElement::childShouldCreateRenderer(const NodeRenderingContext& childContext) const
-{
-    return childContext.isOnUpperEncapsulationBoundary() && HTMLElement::childShouldCreateRenderer(childContext);
-}
-
 RenderProgress* HTMLProgressElement::renderProgress() const
 {
     if (renderer() && renderer()->isProgress())
diff --git a/Source/core/html/HTMLProgressElement.h b/Source/core/html/HTMLProgressElement.h
index 91fca9b..128f712 100644
--- a/Source/core/html/HTMLProgressElement.h
+++ b/Source/core/html/HTMLProgressElement.h
@@ -54,7 +54,6 @@
     virtual bool supportLabels() const OVERRIDE { return true; }
 
     virtual RenderObject* createRenderer(RenderStyle*);
-    virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OVERRIDE;
     RenderProgress* renderProgress() const;
 
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
diff --git a/Source/core/html/HTMLSelectElement.cpp b/Source/core/html/HTMLSelectElement.cpp
index 53e16a6..694c7ba 100644
--- a/Source/core/html/HTMLSelectElement.cpp
+++ b/Source/core/html/HTMLSelectElement.cpp
@@ -1579,4 +1579,10 @@
     return true;
 }
 
+bool HTMLSelectElement::anonymousIndexedSetterRemove(unsigned index, ExceptionCode& ec)
+{
+    remove(index);
+    return true;
+}
+
 } // namespace
diff --git a/Source/core/html/HTMLSelectElement.h b/Source/core/html/HTMLSelectElement.h
index bcfed46..6004c71 100644
--- a/Source/core/html/HTMLSelectElement.h
+++ b/Source/core/html/HTMLSelectElement.h
@@ -109,6 +109,7 @@
     void optionSelectionStateChanged(HTMLOptionElement*, bool optionIsSelected);
     bool isParsingInProgress() const { return m_isParsingInProgress; }
     bool anonymousIndexedSetter(unsigned, PassRefPtr<HTMLOptionElement>, ExceptionCode&);
+    bool anonymousIndexedSetterRemove(unsigned, ExceptionCode&);
 
 protected:
     HTMLSelectElement(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser);
diff --git a/Source/core/html/HTMLSelectElement.idl b/Source/core/html/HTMLSelectElement.idl
index 3c6a8f3..a1d0e77 100644
--- a/Source/core/html/HTMLSelectElement.idl
+++ b/Source/core/html/HTMLSelectElement.idl
@@ -33,7 +33,7 @@
     [SetterRaisesException] attribute unsigned long length;
 
     getter Node item([IsIndex,Default=Undefined] optional unsigned long index);
-    [ImplementedAs=anonymousIndexedSetter, RaisesException] setter HTMLOptionElement (unsigned long index, HTMLOptionElement value);
+    [ImplementedAs=anonymousIndexedSetter, RaisesException] setter HTMLOptionElement (unsigned long index, [TreatNullAs=anonymousIndexedSetterRemove, TreatUndefinedAs=anonymousIndexedSetterRemove] HTMLOptionElement value);
     Node namedItem([Default=Undefined] optional DOMString name);
      [RaisesException] void add([Default=Undefined] optional HTMLElement element,
                             [Default=Undefined] optional HTMLElement before);
diff --git a/Source/core/html/HTMLSummaryElement.cpp b/Source/core/html/HTMLSummaryElement.cpp
index d047101..6907751 100644
--- a/Source/core/html/HTMLSummaryElement.cpp
+++ b/Source/core/html/HTMLSummaryElement.cpp
@@ -52,13 +52,6 @@
     return new (document()->renderArena()) RenderBlock(this);
 }
 
-bool HTMLSummaryElement::childShouldCreateRenderer(const NodeRenderingContext& childContext) const
-{
-    if (childContext.node()->isPseudoElement())
-        return true;
-    return childContext.isOnEncapsulationBoundary() && HTMLElement::childShouldCreateRenderer(childContext);
-}
-
 void HTMLSummaryElement::didAddUserAgentShadowRoot(ShadowRoot* root)
 {
     root->appendChild(DetailsMarkerControl::create(document()), ASSERT_NO_EXCEPTION, AttachLazily);
@@ -67,10 +60,10 @@
 
 HTMLDetailsElement* HTMLSummaryElement::detailsElement() const
 {
-    Node* mayDetails = const_cast<HTMLSummaryElement*>(this)->parentNodeForRenderingAndStyle();
-    if (!mayDetails || !mayDetails->hasTagName(detailsTag))
-        return 0;
-    return static_cast<HTMLDetailsElement*>(mayDetails);
+    Node* parent = NodeRenderingTraversal::parent(this);
+    if (parent && isHTMLDetailsElement(parent))
+        return toHTMLDetailsElement(parent);
+    return 0;
 }
 
 bool HTMLSummaryElement::isMainSummary() const
diff --git a/Source/core/html/HTMLSummaryElement.h b/Source/core/html/HTMLSummaryElement.h
index 8a2108e..f0238f0 100644
--- a/Source/core/html/HTMLSummaryElement.h
+++ b/Source/core/html/HTMLSummaryElement.h
@@ -37,7 +37,6 @@
     HTMLSummaryElement(const QualifiedName&, Document*);
 
     virtual RenderObject* createRenderer(RenderStyle*);
-    virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OVERRIDE;
     virtual void defaultEventHandler(Event*);
 
     virtual void didAddUserAgentShadowRoot(ShadowRoot*) OVERRIDE;
diff --git a/Source/core/html/HTMLTextAreaElement.h b/Source/core/html/HTMLTextAreaElement.h
index 58808aa..09533a7 100644
--- a/Source/core/html/HTMLTextAreaElement.h
+++ b/Source/core/html/HTMLTextAreaElement.h
@@ -66,7 +66,6 @@
     enum WrapMethod { NoWrap, SoftWrap, HardWrap };
 
     virtual void didAddUserAgentShadowRoot(ShadowRoot*) OVERRIDE;
-    virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
 
     void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*) const;
     static String sanitizeUserInputValue(const String&, unsigned maxLength);
diff --git a/Source/core/html/HTMLTextFormControlElement.cpp b/Source/core/html/HTMLTextFormControlElement.cpp
index e55dfb4..70fe01d 100644
--- a/Source/core/html/HTMLTextFormControlElement.cpp
+++ b/Source/core/html/HTMLTextFormControlElement.cpp
@@ -61,15 +61,6 @@
 {
 }
 
-bool HTMLTextFormControlElement::childShouldCreateRenderer(const NodeRenderingContext& childContext) const
-{
-    // FIXME: We shouldn't force the pseudo elements down into the shadow, but
-    // this perserves the current behavior of WebKit.
-    if (childContext.node()->isPseudoElement())
-        return HTMLFormControlElementWithState::childShouldCreateRenderer(childContext);
-    return childContext.isOnEncapsulationBoundary() && HTMLFormControlElementWithState::childShouldCreateRenderer(childContext);
-}
-
 Node::InsertionNotificationRequest HTMLTextFormControlElement::insertedInto(ContainerNode* insertionPoint)
 {
     HTMLFormControlElementWithState::insertedInto(insertionPoint);
@@ -161,7 +152,7 @@
     HTMLElement* placeholder = placeholderElement();
     if (!placeholder)
         return;
-    placeholder->setInlineStyleProperty(CSSPropertyVisibility, placeholderShouldBeVisible() ? ASCIILiteral("visible") : ASCIILiteral("hidden"));
+    placeholder->setInlineStyleProperty(CSSPropertyVisibility, placeholderShouldBeVisible() ? CSSValueVisible : CSSValueHidden);
 }
 
 void HTMLTextFormControlElement::fixPlaceholderRenderer(HTMLElement* placeholder, HTMLElement* siblingElement)
@@ -535,7 +526,7 @@
         innerTextElement()->setInnerText(value, ASSERT_NO_EXCEPTION);
 
         if (value.endsWith('\n') || value.endsWith('\r'))
-            innerTextElement()->appendChild(HTMLBRElement::create(document()), ASSERT_NO_EXCEPTION);
+            innerTextElement()->appendChild(HTMLBRElement::create(document()), ASSERT_NO_EXCEPTION, AttachLazily);
     }
 
     setFormControlValueMatchesRenderer(true);
diff --git a/Source/core/html/HTMLTextFormControlElement.h b/Source/core/html/HTMLTextFormControlElement.h
index 79f60a8..c18ef23 100644
--- a/Source/core/html/HTMLTextFormControlElement.h
+++ b/Source/core/html/HTMLTextFormControlElement.h
@@ -117,9 +117,12 @@
     int computeSelectionEnd() const;
     TextFieldSelectionDirection computeSelectionDirection() const;
 
+    // FIXME: Author shadows should be allowed
+    // https://bugs.webkit.org/show_bug.cgi?id=92608
+    virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
+
     virtual void dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode, FocusDirection) OVERRIDE;
     virtual void dispatchBlurEvent(PassRefPtr<Node> newFocusedNode);
-    virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OVERRIDE;
 
     // Returns true if user-editable value is empty. Used to check placeholder visibility.
     virtual bool isEmptyValue() const = 0;
diff --git a/Source/core/html/ImageDocument.cpp b/Source/core/html/ImageDocument.cpp
index db1a3d1..3b046c4 100644
--- a/Source/core/html/ImageDocument.cpp
+++ b/Source/core/html/ImageDocument.cpp
@@ -229,7 +229,7 @@
     m_imageElement->setWidth(static_cast<int>(imageSize.width() * scale));
     m_imageElement->setHeight(static_cast<int>(imageSize.height() * scale));
     
-    m_imageElement->setInlineStyleProperty(CSSPropertyCursor, "-webkit-zoom-in", false);
+    m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueWebkitZoomIn);
 }
 
 void ImageDocument::imageClicked(int x, int y)
@@ -285,7 +285,7 @@
     if (imageFitsInWindow())
         m_imageElement->removeInlineStyleProperty(CSSPropertyCursor);
     else
-        m_imageElement->setInlineStyleProperty(CSSPropertyCursor, "-webkit-zoom-out", false);
+        m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueWebkitZoomOut);
         
     m_didShrinkImage = false;
 }
@@ -318,7 +318,7 @@
         if (fitsInWindow)
             m_imageElement->removeInlineStyleProperty(CSSPropertyCursor);
         else
-            m_imageElement->setInlineStyleProperty(CSSPropertyCursor, "-webkit-zoom-out", false);
+            m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueWebkitZoomOut);
         return;
     }
     
diff --git a/Source/core/html/InputType.cpp b/Source/core/html/InputType.cpp
index 57c8ad3..d100660 100644
--- a/Source/core/html/InputType.cpp
+++ b/Source/core/html/InputType.cpp
@@ -702,12 +702,6 @@
     return String();
 }
 
-Icon* InputType::icon() const
-{
-    ASSERT_NOT_REACHED();
-    return 0;
-}
-
 bool InputType::shouldResetOnDocumentActivation()
 {
     return false;
diff --git a/Source/core/html/InputType.h b/Source/core/html/InputType.h
index e4f473e..0545aac 100644
--- a/Source/core/html/InputType.h
+++ b/Source/core/html/InputType.h
@@ -54,7 +54,6 @@
 class HTMLElement;
 class HTMLFormElement;
 class HTMLInputElement;
-class Icon;
 class KeyboardEvent;
 class MouseEvent;
 class Node;
@@ -243,7 +242,6 @@
     // Should return true if the given DragData has more than one dropped files.
     virtual bool receiveDroppedFiles(const DragData*);
     virtual String droppedFileSystemId();
-    virtual Icon* icon() const;
     // Should return true if the corresponding renderer for a type can display a suggested value.
     virtual bool canSetSuggestedValue();
     virtual bool shouldSendChangeEventAfterCheckedChanged();
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
index b270133..ebea8be 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -1191,6 +1191,25 @@
         max(rect.height(), -rect.height()));
 }
 
+static inline void clipRectsToImageRect(const FloatRect& imageRect, FloatRect* srcRect, FloatRect* dstRect)
+{
+    if (imageRect.contains(*srcRect))
+        return;
+
+    // Compute the src to dst transform
+    FloatSize scale(dstRect->size().width() / srcRect->size().width(), dstRect->size().height() / srcRect->size().height());
+    FloatPoint scaledSrcLocation = srcRect->location();
+    scaledSrcLocation.scale(scale.width(), scale.height());
+    FloatSize offset = dstRect->location() - scaledSrcLocation;
+
+    srcRect->intersect(imageRect);
+
+    // To clip the destination rectangle in the same proportion, transform the clipped src rect
+    *dstRect = *srcRect;
+    dstRect->scale(scale.width(), scale.height());
+    dstRect->move(offset);
+}
+
 void CanvasRenderingContext2D::drawImageInternal(Image* image, const FloatRect& srcRect, const FloatRect& dstRect, const CompositeOperator& op, const BlendMode& blendMode)
 {
     if (!image)
@@ -1272,9 +1291,11 @@
         ec = IndexSizeError;
         return;
     }
-    if (!imageRect.contains(normalizedSrcRect))
+    if (!imageRect.intersects(normalizedSrcRect))
         return;
 
+    clipRectsToImageRect(imageRect, &normalizedSrcRect, &actualDstRect);
+
     Image* imageForRendering = bitmap->bitmapImage();
 
     drawImageInternal(imageForRendering, normalizedSrcRect, actualDstRect, state().m_globalComposite, state().m_globalBlend);
@@ -1340,9 +1361,11 @@
         ec = IndexSizeError;
         return;
     }
-    if (!imageRect.contains(normalizedSrcRect))
+    if (!imageRect.intersects(normalizedSrcRect))
         return;
 
+    clipRectsToImageRect(imageRect, &normalizedSrcRect, &normalizedDstRect);
+
     CachedImage* cachedImage = image->cachedImage();
     if (!cachedImage)
         return;
@@ -1400,9 +1423,14 @@
 
     ec = 0;
 
-    if (!srcCanvasRect.contains(normalizeRect(srcRect)) || !dstRect.width() || !dstRect.height())
+    FloatRect normalizedSrcRect = normalizeRect(srcRect);
+    FloatRect normalizedDstRect = normalizeRect(dstRect);
+
+    if (!srcCanvasRect.intersects(normalizedSrcRect) || !normalizedDstRect.width() || !normalizedDstRect.height())
         return;
 
+    clipRectsToImageRect(srcCanvasRect, &normalizedSrcRect, &normalizedDstRect);
+
     GraphicsContext* c = drawingContext();
     if (!c)
         return;
@@ -1423,19 +1451,19 @@
     if (!isAccelerated() || !sourceContext || !sourceContext->isAccelerated() || !sourceContext->is2d())
         sourceCanvas->makeRenderingResultsAvailable();
 
-    if (rectContainsCanvas(dstRect)) {
-        c->drawImageBuffer(buffer, dstRect, srcRect, state().m_globalComposite, state().m_globalBlend);
+    if (rectContainsCanvas(normalizedDstRect)) {
+        c->drawImageBuffer(buffer, normalizedDstRect, normalizedSrcRect, state().m_globalComposite, state().m_globalBlend);
         didDrawEntireCanvas();
     } else if (isFullCanvasCompositeMode(state().m_globalComposite)) {
-        fullCanvasCompositedDrawImage(buffer, dstRect, srcRect, state().m_globalComposite);
+        fullCanvasCompositedDrawImage(buffer, normalizedDstRect, normalizedSrcRect, state().m_globalComposite);
         didDrawEntireCanvas();
     } else if (state().m_globalComposite == CompositeCopy) {
         clearCanvas();
-        c->drawImageBuffer(buffer, dstRect, srcRect, state().m_globalComposite, state().m_globalBlend);
+        c->drawImageBuffer(buffer, normalizedDstRect, normalizedSrcRect, state().m_globalComposite, state().m_globalBlend);
         didDrawEntireCanvas();
     } else {
-        c->drawImageBuffer(buffer, dstRect, srcRect, state().m_globalComposite, state().m_globalBlend);
-        didDraw(dstRect);
+        c->drawImageBuffer(buffer, normalizedDstRect, normalizedSrcRect, state().m_globalComposite, state().m_globalBlend);
+        didDraw(normalizedDstRect);
     }
 }
 
@@ -1486,9 +1514,14 @@
         return;
     }
 
-    if (!videoRect.contains(normalizeRect(srcRect)) || !dstRect.width() || !dstRect.height())
+    FloatRect normalizedSrcRect = normalizeRect(srcRect);
+    FloatRect normalizedDstRect = normalizeRect(dstRect);
+
+    if (!videoRect.intersects(normalizedSrcRect) || !normalizedDstRect.width() || !normalizedDstRect.height())
         return;
 
+    clipRectsToImageRect(videoRect, &normalizedSrcRect, &normalizedDstRect);
+
     GraphicsContext* c = drawingContext();
     if (!c)
         return;
@@ -1498,10 +1531,10 @@
     checkOrigin(video);
 
     GraphicsContextStateSaver stateSaver(*c);
-    c->clip(dstRect);
-    c->translate(dstRect.x(), dstRect.y());
-    c->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height()));
-    c->translate(-srcRect.x(), -srcRect.y());
+    c->clip(normalizedDstRect);
+    c->translate(normalizedDstRect.x(), normalizedDstRect.y());
+    c->scale(FloatSize(normalizedDstRect.width() / normalizedSrcRect.width(), normalizedDstRect.height() / normalizedSrcRect.height()));
+    c->translate(-normalizedSrcRect.x(), -normalizedSrcRect.y());
     video->paintCurrentFrameInContext(c, IntRect(IntPoint(), size(video)));
     stateSaver.restore();
     didDraw(dstRect);
diff --git a/Source/core/html/shadow/DateTimeEditElement.cpp b/Source/core/html/shadow/DateTimeEditElement.cpp
index 6654f86..1573712 100644
--- a/Source/core/html/shadow/DateTimeEditElement.cpp
+++ b/Source/core/html/shadow/DateTimeEditElement.cpp
@@ -409,7 +409,7 @@
             element->appendChild(Text::create(m_editElement.document(), String(&rightToLeftMark, 1)));
     }
     element->appendChild(Text::create(m_editElement.document(), text));
-    m_editElement.fieldsWrapperElement()->appendChild(element);
+    m_editElement.fieldsWrapperElement()->appendChild(element, ASSERT_NO_EXCEPTION, AttachLazily);
 }
 
 DateTimeNumericFieldElement::Step DateTimeEditBuilder::createStep(double msPerFieldUnit, double msPerFieldSize) const
@@ -463,7 +463,7 @@
     if (m_fields.size() == m_fields.capacity())
         return;
     m_fields.append(field.get());
-    fieldsWrapperElement()->appendChild(field);
+    fieldsWrapperElement()->appendChild(field, ASSERT_NO_EXCEPTION, AttachLazily);
 }
 
 bool DateTimeEditElement::anyEditableFieldsHaveValues() const
@@ -652,7 +652,7 @@
     if (!firstChild()) {
         RefPtr<HTMLDivElement> element = HTMLDivElement::create(document());
         element->setPseudo(fieldsWrapperPseudoId);
-        appendChild(element.get());
+        appendChild(element.get(), ASSERT_NO_EXCEPTION, AttachLazily);
     }
     Element* fieldsWrapper = fieldsWrapperElement();
 
diff --git a/Source/core/html/shadow/HTMLShadowElement.cpp b/Source/core/html/shadow/HTMLShadowElement.cpp
index 71f8ef0..b692d59 100644
--- a/Source/core/html/shadow/HTMLShadowElement.cpp
+++ b/Source/core/html/shadow/HTMLShadowElement.cpp
@@ -63,7 +63,7 @@
     containingRoot->host()->ensureDistribution();
 
     ShadowRoot* older = containingRoot->olderShadowRoot();
-    if (!older || !older->shouldExposeToBindings() || ScopeContentDistribution::assignedTo(older) != this)
+    if (!older || !older->shouldExposeToBindings() || older->insertionPoint() != this)
         return 0;
 
     ASSERT(older->shouldExposeToBindings());
diff --git a/Source/core/html/shadow/MediaControlElementTypes.cpp b/Source/core/html/shadow/MediaControlElementTypes.cpp
index c012642..7eba7a7 100644
--- a/Source/core/html/shadow/MediaControlElementTypes.cpp
+++ b/Source/core/html/shadow/MediaControlElementTypes.cpp
@@ -116,6 +116,11 @@
 {
 }
 
+bool MediaControlInputElement::isMouseFocusable() const
+{
+    return false;
+}
+
 // ----------------------------
 
 MediaControlTimeDisplayElement::MediaControlTimeDisplayElement(Document* document, MediaControlElementType displayType)
diff --git a/Source/core/html/shadow/MediaControlElementTypes.h b/Source/core/html/shadow/MediaControlElementTypes.h
index 7f9296c..5a3fde8 100644
--- a/Source/core/html/shadow/MediaControlElementTypes.h
+++ b/Source/core/html/shadow/MediaControlElementTypes.h
@@ -119,6 +119,7 @@
 
 private:
     virtual void updateDisplayType() { }
+    virtual bool isMouseFocusable() const OVERRIDE;
 };
 
 // ----------------------------
diff --git a/Source/core/html/shadow/MediaControlElements.cpp b/Source/core/html/shadow/MediaControlElements.cpp
index 84f6ea9..6cc16b1 100644
--- a/Source/core/html/shadow/MediaControlElements.cpp
+++ b/Source/core/html/shadow/MediaControlElements.cpp
@@ -798,7 +798,7 @@
     float fontSize = smallestDimension * 0.05f;
     if (fontSize != m_fontSize) {
         m_fontSize = fontSize;
-        setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
+        setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX);
     }
 
     CueList activeCues = mediaElement->currentlyActiveCues();
diff --git a/Source/core/html/track/InbandTextTrack.cpp b/Source/core/html/track/InbandTextTrack.cpp
index c97e193..a18d82b 100644
--- a/Source/core/html/track/InbandTextTrack.cpp
+++ b/Source/core/html/track/InbandTextTrack.cpp
@@ -156,9 +156,9 @@
         cue->setLine(lround(cueData->line()), IGNORE_EXCEPTION);
     if (cueData->size() > 0)
         cue->setSize(lround(cueData->size()), IGNORE_EXCEPTION);
-    if (cueData->backgroundColor().isValid())
+    if (cueData->backgroundColor().alpha())
         cue->setBackgroundColor(cueData->backgroundColor().rgb());
-    if (cueData->foregroundColor().isValid())
+    if (cueData->foregroundColor().alpha())
         cue->setForegroundColor(cueData->foregroundColor().rgb());
 
     if (cueData->align() == GenericCueData::Start)
diff --git a/Source/core/html/track/TextTrackCue.cpp b/Source/core/html/track/TextTrackCue.cpp
index 068e4d1..0c1a1b3 100644
--- a/Source/core/html/track/TextTrackCue.cpp
+++ b/Source/core/html/track/TextTrackCue.cpp
@@ -124,15 +124,15 @@
     setInlineStyleProperty(CSSPropertyDirection, m_cue->getCSSWritingDirection());
 
     // the 'writing-mode' property must be set to writing-mode
-    setInlineStyleProperty(CSSPropertyWebkitWritingMode, m_cue->getCSSWritingMode(), false);
+    setInlineStyleProperty(CSSPropertyWebkitWritingMode, m_cue->getCSSWritingMode());
 
     std::pair<float, float> position = m_cue->getCSSPosition();
 
     // the 'top' property must be set to top,
-    setInlineStyleProperty(CSSPropertyTop, static_cast<double>(position.second), CSSPrimitiveValue::CSS_PERCENTAGE);
+    setInlineStyleProperty(CSSPropertyTop, position.second, CSSPrimitiveValue::CSS_PERCENTAGE);
 
     // the 'left' property must be set to left
-    setInlineStyleProperty(CSSPropertyLeft, static_cast<double>(position.first), CSSPrimitiveValue::CSS_PERCENTAGE);
+    setInlineStyleProperty(CSSPropertyLeft, position.first, CSSPrimitiveValue::CSS_PERCENTAGE);
 
     // the 'width' property must be set to width, and the 'height' property  must be set to height
     if (m_cue->vertical() == horizontalKeyword()) {
diff --git a/Source/core/html/track/TextTrackCueGeneric.cpp b/Source/core/html/track/TextTrackCueGeneric.cpp
index 2b5c3d3..a7f0db2 100644
--- a/Source/core/html/track/TextTrackCueGeneric.cpp
+++ b/Source/core/html/track/TextTrackCueGeneric.cpp
@@ -61,7 +61,7 @@
 
     float size = static_cast<float>(cue->getCSSSize());
     if (cue->useDefaultPosition()) {
-        setInlineStyleProperty(CSSPropertyBottom, "0");
+        setInlineStyleProperty(CSSPropertyBottom, 0.0, CSSPrimitiveValue::CSS_PX);
         setInlineStyleProperty(CSSPropertyMarginBottom, 1.0, CSSPrimitiveValue::CSS_PERCENTAGE);
     } else {
         setInlineStyleProperty(CSSPropertyLeft, static_cast<float>(cue->position()), CSSPrimitiveValue::CSS_PERCENTAGE);
@@ -73,10 +73,10 @@
             setInlineStyleProperty(CSSPropertyHeight, size,  CSSPrimitiveValue::CSS_PERCENTAGE);
     }
 
-    if (cue->foregroundColor().isValid())
+    if (cue->foregroundColor().alpha())
         setInlineStyleProperty(CSSPropertyColor, cue->foregroundColor().serialized());
     
-    if (cue->backgroundColor().isValid())
+    if (cue->backgroundColor().alpha())
         cue->element()->setInlineStyleProperty(CSSPropertyBackgroundColor, cue->backgroundColor().serialized());
 
     if (cue->getWritingDirection() == TextTrackCue::Horizontal)
@@ -88,7 +88,7 @@
         double fontSize = videoSize.height() * cue->baseFontSizeRelativeToVideoHeight() / 100;
         if (cue->fontSizeMultiplier())
             fontSize *= cue->fontSizeMultiplier() / 100;
-        setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
+        setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX);
     }
 
     if (cue->getAlignment() == TextTrackCue::Middle)
@@ -137,7 +137,7 @@
         double fontSize = videoSize.height() * baseFontSizeRelativeToVideoHeight() / 100;
         if (fontSizeMultiplier())
             fontSize *= fontSizeMultiplier() / 100;
-        displayTreeInternal()->setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
+        displayTreeInternal()->setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX);
     }
 
 }
diff --git a/Source/core/html/track/TextTrackCueGeneric.h b/Source/core/html/track/TextTrackCueGeneric.h
index 4997e86..39ba418 100644
--- a/Source/core/html/track/TextTrackCueGeneric.h
+++ b/Source/core/html/track/TextTrackCueGeneric.h
@@ -60,10 +60,10 @@
     void setFontName(String name) { m_fontName = name; }
 
     Color foregroundColor() const { return m_foregroundColor; }
-    void setForegroundColor(RGBA32 color) { m_foregroundColor.setRGB(color); }
+    void setForegroundColor(Color color) { m_foregroundColor = color; }
     
     Color backgroundColor() const { return m_backgroundColor; }
-    void setBackgroundColor(RGBA32 color) { m_backgroundColor.setRGB(color); }
+    void setBackgroundColor(Color color) { m_backgroundColor = color; }
 
     virtual void videoSizeDidChange(const IntSize&);
 
diff --git a/Source/core/html/track/TextTrackRegion.cpp b/Source/core/html/track/TextTrackRegion.cpp
index 6d93be3..236f2f7 100644
--- a/Source/core/html/track/TextTrackRegion.cpp
+++ b/Source/core/html/track/TextTrackRegion.cpp
@@ -464,7 +464,7 @@
     // gradually scrolled out as multiple cues are appended to the region.
     m_cueContainer = HTMLDivElement::create(ownerDocument());
     m_cueContainer->setInlineStyleProperty(CSSPropertyTop,
-        0.0f,
+        0.0,
         CSSPrimitiveValue::CSS_PX);
 
     m_cueContainer->setPseudo(textTrackCueContainerShadowPseudoId());
diff --git a/Source/core/inspector/InspectorCSSAgent.cpp b/Source/core/inspector/InspectorCSSAgent.cpp
index 4c2e610..2d23bf7 100644
--- a/Source/core/inspector/InspectorCSSAgent.cpp
+++ b/Source/core/inspector/InspectorCSSAgent.cpp
@@ -1348,7 +1348,7 @@
         m_nodeIdToForcedPseudoState.set(nodeId, forcedPseudoState);
     else
         m_nodeIdToForcedPseudoState.remove(nodeId);
-    element->ownerDocument()->scheduleForcedStyleRecalc();
+    element->ownerDocument()->setNeedsStyleRecalc();
 }
 
 void InspectorCSSAgent::getNamedFlowCollection(ErrorString* errorString, int documentNodeId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::NamedFlow> >& result)
@@ -1643,7 +1643,7 @@
 
         InlineStyleOverrideScope overrideScope(document);
         m_creatingViaInspectorStyleSheet = true;
-        targetNode->appendChild(styleElement, ec);
+        targetNode->appendChild(styleElement, ec, AttachLazily);
         // At this point the added stylesheet will get bound through the updateActiveStyleSheets() invocation.
         // We just need to pick the respective InspectorStyleSheet from m_documentToInspectorStyleSheet.
         m_creatingViaInspectorStyleSheet = false;
@@ -1883,7 +1883,7 @@
 
     m_nodeIdToForcedPseudoState.clear();
     for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = documentsToChange.end(); it != end; ++it)
-        (*it)->scheduleForcedStyleRecalc();
+        (*it)->setNeedsStyleRecalc();
 }
 
 } // namespace WebCore
diff --git a/Source/core/inspector/InspectorFileSystemAgent.cpp b/Source/core/inspector/InspectorFileSystemAgent.cpp
index 1ff8176..fffd4dc 100644
--- a/Source/core/inspector/InspectorFileSystemAgent.cpp
+++ b/Source/core/inspector/InspectorFileSystemAgent.cpp
@@ -162,7 +162,7 @@
     RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &FileSystemRootRequest::didGetEntry);
     OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, "/");
 
-    LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
+    LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
 }
 
 bool FileSystemRootRequest::didGetEntry(Entry* entry)
@@ -232,7 +232,7 @@
     RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &DirectoryContentRequest::didGetEntry);
     OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path);
 
-    LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
+    LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
 }
 
 bool DirectoryContentRequest::didGetEntry(Entry* entry)
@@ -356,7 +356,7 @@
 
     RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &MetadataRequest::didGetEntry);
     OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, m_path);
-    LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
+    LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
 }
 
 bool MetadataRequest::didGetEntry(Entry* entry)
@@ -463,7 +463,7 @@
     RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &FileContentRequest::didGetEntry);
     OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path);
 
-    LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
+    LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
 }
 
 bool FileContentRequest::didGetEntry(Entry* entry)
@@ -572,11 +572,11 @@
 
     if (path == "/") {
         OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = VoidCallbacks::create(this, errorCallback);
-        LocalFileSystem::localFileSystem().deleteFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
+        LocalFileSystem::from(scriptExecutionContext)->deleteFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
     } else {
         RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &DeleteEntryRequest::didGetEntry);
         OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path);
-        LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
+        LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
     }
 }
 
diff --git a/Source/core/inspector/InspectorFrontendHost.cpp b/Source/core/inspector/InspectorFrontendHost.cpp
index f914a14..770fbcc 100644
--- a/Source/core/inspector/InspectorFrontendHost.cpp
+++ b/Source/core/inspector/InspectorFrontendHost.cpp
@@ -276,13 +276,13 @@
 String InspectorFrontendHost::getSelectionBackgroundColor()
 {
     Color color = m_frontendPage->theme()->activeSelectionBackgroundColor();
-    return color.isValid() ? color.serialized() : "";
+    return color != Color::transparent ? color.serialized() : "";
 }
 
 String InspectorFrontendHost::getSelectionForegroundColor()
 {
     Color color = m_frontendPage->theme()->activeSelectionForegroundColor();
-    return color.isValid() ? color.serialized() : "";
+    return color != Color::transparent ? color.serialized() : "";
 }
 
 bool InspectorFrontendHost::supportsFileSystems()
diff --git a/Source/core/inspector/InspectorInstrumentation.idl b/Source/core/inspector/InspectorInstrumentation.idl
index 672286e..c199707 100644
--- a/Source/core/inspector/InspectorInstrumentation.idl
+++ b/Source/core/inspector/InspectorInstrumentation.idl
@@ -330,6 +330,9 @@
     [Canvas, Page, CSS]
     void frameDetachedFromParent([Keep] Frame*);
 
+    [Page]
+    void childDocumentOpened([Keep] Document*);
+
     [Console, Resource, CSS, Database, DOM, LayerTree, Inspector, Canvas, Page]
     void didCommitLoad([Keep] Frame*, DocumentLoader*);
 
diff --git a/Source/core/inspector/InspectorPageAgent.cpp b/Source/core/inspector/InspectorPageAgent.cpp
index 6adee63..cab38da 100644
--- a/Source/core/inspector/InspectorPageAgent.cpp
+++ b/Source/core/inspector/InspectorPageAgent.cpp
@@ -816,6 +816,11 @@
     m_frontend->loadEventFired(currentTime());
 }
 
+void InspectorPageAgent::childDocumentOpened(Document* document)
+{
+    m_frontend->frameNavigated(buildObjectForFrame(document->frame()));
+}
+
 void InspectorPageAgent::didCommitLoad(Frame*, DocumentLoader* loader)
 {
     if (loader->frame() == m_page->mainFrame()) {
diff --git a/Source/core/inspector/InspectorPageAgent.h b/Source/core/inspector/InspectorPageAgent.h
index 66a9fc4..9e93c76 100644
--- a/Source/core/inspector/InspectorPageAgent.h
+++ b/Source/core/inspector/InspectorPageAgent.h
@@ -43,6 +43,7 @@
 
 class CachedResource;
 class DOMWrapperWorld;
+class Document;
 class DocumentLoader;
 class Frame;
 class GraphicsContext;
@@ -128,6 +129,7 @@
     void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld*);
     void domContentLoadedEventFired(Frame*);
     void loadEventFired(Frame*);
+    void childDocumentOpened(Document*);
     void didCommitLoad(Frame*, DocumentLoader*);
     void frameDetachedFromParent(Frame*);
     void loaderDetachedFromFrame(DocumentLoader*);
diff --git a/Source/core/inspector/PageDebuggerAgent.cpp b/Source/core/inspector/PageDebuggerAgent.cpp
index 1bbb03a..72bd983 100644
--- a/Source/core/inspector/PageDebuggerAgent.cpp
+++ b/Source/core/inspector/PageDebuggerAgent.cpp
@@ -33,11 +33,9 @@
 
 #include "bindings/v8/DOMWrapperWorld.h"
 #include "bindings/v8/PageScriptDebugServer.h"
-#include "bindings/v8/ScriptController.h"
 #include "core/inspector/InspectorOverlay.h"
 #include "core/inspector/InspectorPageAgent.h"
 #include "core/inspector/InstrumentingAgents.h"
-#include "core/page/Frame.h"
 #include "core/page/Page.h"
 #include "core/page/PageConsole.h"
 
@@ -138,10 +136,7 @@
         return;
 
     reset();
-
-    // ScriptController::clearWindowShell() clears its ScriptPreprocessor before didClearWindowObjectInWorld is dispatched.
-    if (!m_pageAgent->scriptPreprocessor().isEmpty())
-        frame->script()->setScriptPreprocessor(m_pageAgent->scriptPreprocessor());
+    scriptDebugServer().setScriptPreprocessor(m_pageAgent->scriptPreprocessor());
 }
 
 } // namespace WebCore
diff --git a/Source/core/loader/CrossOriginAccessControl.h b/Source/core/loader/CrossOriginAccessControl.h
index 0962d13..020aefe 100644
--- a/Source/core/loader/CrossOriginAccessControl.h
+++ b/Source/core/loader/CrossOriginAccessControl.h
@@ -27,7 +27,7 @@
 #ifndef CrossOriginAccessControl_h
 #define CrossOriginAccessControl_h
 
-#include "core/platform/network/ResourceHandle.h"
+#include "core/loader/ResourceLoaderOptions.h"
 #include "core/platform/network/ResourceRequest.h"
 #include "wtf/Forward.h"
 #include "wtf/HashSet.h"
diff --git a/Source/core/loader/CrossOriginPreflightResultCache.h b/Source/core/loader/CrossOriginPreflightResultCache.h
index 69ded5a..814a1e0 100644
--- a/Source/core/loader/CrossOriginPreflightResultCache.h
+++ b/Source/core/loader/CrossOriginPreflightResultCache.h
@@ -27,7 +27,7 @@
 #ifndef CrossOriginPreflightResultCache_h
 #define CrossOriginPreflightResultCache_h
 
-#include "core/platform/network/ResourceHandle.h"
+#include "core/loader/ResourceLoaderOptions.h"
 #include "weborigin/KURLHash.h"
 #include "wtf/HashMap.h"
 #include "wtf/HashSet.h"
diff --git a/Source/core/loader/DocumentLoader.cpp b/Source/core/loader/DocumentLoader.cpp
index c1e7f48..f167804 100644
--- a/Source/core/loader/DocumentLoader.cpp
+++ b/Source/core/loader/DocumentLoader.cpp
@@ -479,9 +479,9 @@
     if (newRequest.cachePolicy() == UseProtocolCachePolicy && isPostOrRedirectAfterPost(newRequest, redirectResponse))
         newRequest.setCachePolicy(ReloadIgnoringCacheData);
 
-    Frame* top = m_frame->tree()->top();
-    if (top) {
-        if (!top->loader()->mixedContentChecker()->canDisplayInsecureContent(top->document()->securityOrigin(), newRequest.url())) {
+    Frame* parent = m_frame->tree()->parent();
+    if (parent) {
+        if (!parent->loader()->mixedContentChecker()->canRunInsecureContent(parent->document()->securityOrigin(), newRequest.url())) {
             cancelMainResourceLoad(ResourceError::cancelledError(newRequest.url()));
             return;
         }
@@ -671,7 +671,6 @@
         return;
     if (isArchiveMIMEType(response().mimeType()))
         return;
-    frameLoader()->client()->didReceiveDocumentData(data, length);
     commitData(data, length);
 
     // If we are sending data to MediaDocument, we should stop here
diff --git a/Source/core/loader/EmptyClients.h b/Source/core/loader/EmptyClients.h
index 3fef241..37cd968 100644
--- a/Source/core/loader/EmptyClients.h
+++ b/Source/core/loader/EmptyClients.h
@@ -151,7 +151,6 @@
     virtual PassRefPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) OVERRIDE;
 
     virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) OVERRIDE;
-    virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*) OVERRIDE { }
 
     virtual void formStateDidChange(const Node*) OVERRIDE { }
 
@@ -220,8 +219,6 @@
 
     virtual void loadURLExternally(const ResourceRequest&, NavigationPolicy, const String& = String()) OVERRIDE { }
 
-    virtual void didReceiveDocumentData(const char*, int) OVERRIDE { }
-
     virtual ResourceError interruptedForPolicyChangeError(const ResourceRequest&) OVERRIDE { return ResourceError("", 0, "", ""); }
 
     virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&) OVERRIDE;
diff --git a/Source/core/loader/FrameLoader.cpp b/Source/core/loader/FrameLoader.cpp
index 0dcff7f..f9b23bb 100644
--- a/Source/core/loader/FrameLoader.cpp
+++ b/Source/core/loader/FrameLoader.cpp
@@ -63,6 +63,7 @@
 #include "core/loader/FrameLoaderClient.h"
 #include "core/loader/IconController.h"
 #include "core/loader/ProgressTracker.h"
+#include "core/loader/ResourceLoader.h"
 #include "core/loader/UniqueIdentifier.h"
 #include "core/loader/appcache/ApplicationCacheHost.h"
 #include "core/loader/cache/CachedResourceLoader.h"
@@ -81,7 +82,6 @@
 #include "core/platform/ScrollAnimator.h"
 #include "core/platform/graphics/FloatRect.h"
 #include "core/platform/network/HTTPParsers.h"
-#include "core/platform/network/ResourceHandle.h"
 #include "core/platform/network/ResourceRequest.h"
 #include "core/xml/parser/XMLDocumentParser.h"
 #include "modules/webdatabase/DatabaseManager.h"
@@ -176,6 +176,7 @@
     , m_suppressOpenerInNewFrame(false)
     , m_startingClientRedirect(false)
     , m_forcedSandboxFlags(SandboxNone)
+    , m_hasAllowedNavigationViaBeforeUnloadConfirmationPanel(false)
 {
 }
 
@@ -942,7 +943,7 @@
         return false;
     }
 
-    if (request.requester() && request.frameName().isEmpty())
+    if (request.requester() && !request.formState() && request.frameName().isEmpty())
         request.setFrameName(m_frame->document()->baseTarget());
 
     // If the requesting SecurityOrigin is not this Frame's SecurityOrigin, the request was initiated by a different frame that should
@@ -952,6 +953,18 @@
     return true;
 }
 
+static bool shouldOpenInNewWindow(Frame* targetFrame, const FrameLoadRequest& request, const NavigationAction& action)
+{
+    if (!targetFrame && !request.frameName().isEmpty())
+        return true;
+    if (!request.formState())
+        return false;
+    NavigationPolicy navigationPolicy = NavigationPolicyCurrentTab;
+    if (!action.specifiesNavigationPolicy(&navigationPolicy))
+        return false;
+    return navigationPolicy != NavigationPolicyCurrentTab;
+}
+
 void FrameLoader::load(const FrameLoadRequest& passedRequest)
 {
     ASSERT(!m_suppressOpenerInNewFrame);
@@ -977,13 +990,17 @@
 
     FrameLoadType newLoadType = determineFrameLoadType(request);
     NavigationAction action(request.resourceRequest(), newLoadType, request.formState(), request.triggeringEvent());
-    if (!targetFrame && !request.frameName().isEmpty()) {
+    if (shouldOpenInNewWindow(targetFrame, request, action)) {
         TemporaryChange<bool> changeOpener(m_suppressOpenerInNewFrame, request.shouldSendReferrer() == NeverSendReferrer);
         checkNewWindowPolicyAndContinue(request.formState(), request.frameName(), action);
         return;
     }
 
     TemporaryChange<bool> changeClientRedirect(m_startingClientRedirect, request.clientRedirect());
+    if (shouldPerformFragmentNavigation(request.formState(), request.resourceRequest().httpMethod(), newLoadType, request.resourceRequest().url())) {
+        checkNavigationPolicyAndContinueFragmentScroll(action, newLoadType != FrameLoadTypeRedirectWithLockedBackForwardList);
+        return;
+    }
     bool sameURL = shouldTreatURLAsSameAsCurrent(request.resourceRequest().url());
     loadWithNavigationAction(request.resourceRequest(), action, newLoadType, request.formState(), request.substituteData());
     // Example of this case are sites that reload the same URL with a different cookie
@@ -1024,15 +1041,8 @@
 
     loader->setReplacesCurrentHistoryItem(type == FrameLoadTypeRedirectWithLockedBackForwardList);
     loader->setIsClientRedirect(m_startingClientRedirect);
-
-    bool isFormSubmission = formState;
-
-    if (shouldPerformFragmentNavigation(isFormSubmission, request.httpMethod(), type, request.url()))
-        checkNavigationPolicyAndContinueFragmentScroll(action, type != FrameLoadTypeRedirectWithLockedBackForwardList);
-    else {
-        setPolicyDocumentLoader(loader.get());
-        checkNavigationPolicyAndContinueLoad(formState, type);
-    }
+    setPolicyDocumentLoader(loader.get());
+    checkNavigationPolicyAndContinueLoad(formState, type);
 }
 
 void FrameLoader::reportLocalLoadFailed(Frame* frame, const String& url)
@@ -1266,6 +1276,8 @@
     if (m_state != FrameStateProvisional)
         return;
 
+    clearAllowNavigationViaBeforeUnloadConfirmationPanel();
+
     if (FrameView* view = m_frame->view()) {
         if (ScrollAnimator* scrollAnimator = view->existingScrollAnimator())
             scrollAnimator->cancelAnimations();
@@ -1304,16 +1316,6 @@
         m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocumentPostCommit);
 }
 
-bool FrameLoader::shouldReload(const KURL& currentURL, const KURL& destinationURL)
-{
-    // This function implements the rule: "Don't reload if navigating by fragment within
-    // the same URL, but do reload if going to a new URL or to the same URL with no
-    // fragment identifier at all."
-    if (!destinationURL.hasFragmentIdentifier())
-        return true;
-    return !equalIgnoringFragmentIdentifier(currentURL, destinationURL);
-}
-
 void FrameLoader::closeOldDataSources()
 {
     // FIXME: Is it important for this traversal to be postorder instead of preorder?
@@ -1713,7 +1715,7 @@
     if (error.isNull()) {
         ASSERT(!newRequest.isNull());
         documentLoader()->applicationCacheHost()->willStartLoadingSynchronously(newRequest);
-        ResourceHandle::loadResourceSynchronously(newRequest, storedCredentials, error, response, data);
+        ResourceLoader::loadResourceSynchronously(newRequest, storedCredentials, error, response, data);
     }
     int encodedDataLength = response.resourceLoadInfo() ? static_cast<int>(response.resourceLoadInfo()->encodedDataLength) : -1;
     notifier()->sendRemainingDelegateMessages(m_documentLoader.get(), identifier, response, data.data(), data.size(), encodedDataLength, error);
@@ -1769,17 +1771,16 @@
 
 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const String& httpMethod, FrameLoadType loadType, const KURL& url)
 {
+    ASSERT(loadType != FrameLoadTypeBackForward);
+    ASSERT(loadType != FrameLoadTypeReloadFromOrigin);
+    ASSERT(loadType != FrameLoadTypeReplace);
     // We don't do this if we are submitting a form with method other than "GET", explicitly reloading,
     // currently displaying a frameset, or if the URL does not have a fragment.
-    // These rules were originally based on what KHTML was doing in KHTMLPart::openURL.
-
-    // FIXME: What about load types other than Standard and Reload?
-
     return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET"))
         && loadType != FrameLoadTypeReload
-        && loadType != FrameLoadTypeReloadFromOrigin
         && loadType != FrameLoadTypeSame
-        && !shouldReload(m_frame->document()->url(), url)
+        && url.hasFragmentIdentifier()
+        && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url)
         // We don't want to just scroll if a link from within a
         // frameset is trying to reload the frameset into _top.
         && !m_frame->document()->isFrameSet();
@@ -1823,7 +1824,7 @@
         for (i = 0; i < targetFrames.size(); i++) {
             if (!targetFrames[i]->tree()->isDescendantOf(m_frame))
                 continue;
-            if (!targetFrames[i]->loader()->fireBeforeUnloadEvent(page->chrome()))
+            if (!targetFrames[i]->loader()->fireBeforeUnloadEvent(page->chrome(), this))
                 break;
         }
 
@@ -1837,7 +1838,7 @@
     return shouldClose;
 }
 
-bool FrameLoader::fireBeforeUnloadEvent(Chrome& chrome)
+bool FrameLoader::fireBeforeUnloadEvent(Chrome& chrome, FrameLoader* navigatingFrameLoader)
 {
     DOMWindow* domWindow = m_frame->domWindow();
     if (!domWindow)
@@ -1857,8 +1858,17 @@
     if (beforeUnloadEvent->result().isNull())
         return true;
 
+    if (navigatingFrameLoader->hasAllowedNavigationViaBeforeUnloadConfirmationPanel()) {
+        m_frame->document()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Blocked attempt to show multiple 'beforeunload' confirmation panels for a single navigation.");
+        return true;
+    }
+
     String text = document->displayStringModifiedByEncoding(beforeUnloadEvent->result());
-    return chrome.runBeforeUnloadConfirmPanel(text, m_frame);
+    if (chrome.runBeforeUnloadConfirmPanel(text, m_frame)) {
+        navigatingFrameLoader->didAllowNavigationViaBeforeUnloadConfirmationPanel();
+        return true;
+    }
+    return false;
 }
 
 void FrameLoader::checkNavigationPolicyAndContinueLoad(PassRefPtr<FormState> formState, FrameLoadType type)
@@ -2269,6 +2279,8 @@
 
     InspectorInstrumentation::didCommitLoad(m_frame, m_documentLoader.get());
 
+    m_frame->page()->didCommitLoad(m_frame);
+
     if (m_frame->page()->mainFrame() == m_frame)
         m_frame->page()->useCounter()->didCommitLoad();
 
diff --git a/Source/core/loader/FrameLoader.h b/Source/core/loader/FrameLoader.h
index c832698..18fb851 100644
--- a/Source/core/loader/FrameLoader.h
+++ b/Source/core/loader/FrameLoader.h
@@ -39,11 +39,11 @@
 #include "core/loader/HistoryController.h"
 #include "core/loader/MixedContentChecker.h"
 #include "core/loader/ResourceLoadNotifier.h"
+#include "core/loader/ResourceLoaderOptions.h"
 #include "core/loader/SubframeLoader.h"
 #include "core/loader/cache/CachePolicy.h"
 #include "core/page/LayoutMilestones.h"
 #include "core/platform/Timer.h"
-#include "core/platform/network/ResourceHandle.h"
 #include "wtf/Forward.h"
 #include "wtf/HashSet.h"
 #include "wtf/OwnPtr.h"
@@ -260,7 +260,10 @@
 
     SubstituteData defaultSubstituteDataForURL(const KURL&);
     
-    bool fireBeforeUnloadEvent(Chrome&);
+    bool fireBeforeUnloadEvent(Chrome&, FrameLoader*);
+    bool hasAllowedNavigationViaBeforeUnloadConfirmationPanel() const { return m_hasAllowedNavigationViaBeforeUnloadConfirmationPanel; }
+    void didAllowNavigationViaBeforeUnloadConfirmationPanel() { m_hasAllowedNavigationViaBeforeUnloadConfirmationPanel = true; }
+    void clearAllowNavigationViaBeforeUnloadConfirmationPanel() { m_hasAllowedNavigationViaBeforeUnloadConfirmationPanel = false; }
 
     void checkNavigationPolicyAndContinueLoad(PassRefPtr<FormState>, FrameLoadType);
     void checkNavigationPolicyAndContinueFragmentScroll(const NavigationAction&, bool isNewNavigation);
@@ -285,9 +288,6 @@
     void loadWithNavigationAction(const ResourceRequest&, const NavigationAction&,
         FrameLoadType, PassRefPtr<FormState>, const SubstituteData&, const String& overrideEncoding = String());
 
-
-    bool shouldReload(const KURL& currentURL, const KURL& destinationURL);
-
     void requestFromDelegate(ResourceRequest&, unsigned long& identifier, ResourceError&);
 
     void detachChildren();
@@ -359,6 +359,8 @@
 
     SandboxFlags m_forcedSandboxFlags;
 
+    bool m_hasAllowedNavigationViaBeforeUnloadConfirmationPanel;
+
     RefPtr<HistoryItem> m_requestedHistoryItem;
 };
 
diff --git a/Source/core/loader/FrameLoaderClient.h b/Source/core/loader/FrameLoaderClient.h
index b323744..0708411 100644
--- a/Source/core/loader/FrameLoaderClient.h
+++ b/Source/core/loader/FrameLoaderClient.h
@@ -130,8 +130,6 @@
 
         virtual void loadURLExternally(const ResourceRequest&, NavigationPolicy, const String& suggestedName = String()) = 0;
 
-        virtual void didReceiveDocumentData(const char*, int) = 0;
-
         virtual bool shouldGoToHistoryItem(HistoryItem*) const = 0;
         virtual bool shouldStopLoadingForHistoryItem(HistoryItem*) const = 0;
 
diff --git a/Source/core/loader/PingLoader.cpp b/Source/core/loader/PingLoader.cpp
index 3d96a33..646de04 100644
--- a/Source/core/loader/PingLoader.cpp
+++ b/Source/core/loader/PingLoader.cpp
@@ -37,10 +37,12 @@
 #include "core/loader/FrameLoader.h"
 #include "core/loader/UniqueIdentifier.h"
 #include "core/page/Frame.h"
+#include "core/platform/chromium/support/WrappedResourceRequest.h"
 #include "core/platform/network/FormData.h"
-#include "core/platform/network/ResourceHandle.h"
 #include "core/platform/network/ResourceRequest.h"
 #include "core/platform/network/ResourceResponse.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebURLLoader.h"
 #include "weborigin/SecurityOrigin.h"
 #include "weborigin/SecurityPolicy.h"
 #include "wtf/OwnPtr.h"
@@ -122,7 +124,11 @@
     : m_timeout(this, &PingLoader::timeout)
 {
     unsigned long identifier = createUniqueIdentifier();
-    m_handle = ResourceHandle::create(request, this, false, false, credentialsAllowed);
+    m_loader = adoptPtr(WebKit::Platform::current()->createURLLoader());
+    ASSERT(m_loader);
+    WebKit::WrappedResourceRequest wrappedRequest(request);
+    wrappedRequest.setAllowStoredCredentials(credentialsAllowed == AllowStoredCredentials);
+    m_loader->loadAsynchronously(wrappedRequest, this);
 
     InspectorInstrumentation::continueAfterPingLoader(frame, identifier, frame->loader()->activeDocumentLoader(), request, ResourceResponse());
 
@@ -133,8 +139,8 @@
 
 PingLoader::~PingLoader()
 {
-    if (m_handle)
-        m_handle->cancel();
+    if (m_loader)
+        m_loader->cancel();
 }
 
 }
diff --git a/Source/core/loader/PingLoader.h b/Source/core/loader/PingLoader.h
index bf3d734..418e420 100644
--- a/Source/core/loader/PingLoader.h
+++ b/Source/core/loader/PingLoader.h
@@ -32,9 +32,9 @@
 #ifndef PingLoader_h
 #define PingLoader_h
 
+#include "core/loader/ResourceLoaderOptions.h"
 #include "core/platform/Timer.h"
-#include "core/platform/network/ResourceHandleClient.h"
-#include "core/platform/network/ResourceHandleTypes.h"
+#include "public/platform/WebURLLoaderClient.h"
 #include "wtf/Noncopyable.h"
 #include "wtf/RefPtr.h"
 
@@ -45,6 +45,7 @@
 class KURL;
 class ResourceError;
 class ResourceHandle;
+class ResourceRequest;
 class ResourceResponse;
 
 // This class triggers asynchronous loads independent of Frame staying alive (i.e., auditing pingbacks).
@@ -52,7 +53,7 @@
 // to allow the load to live long enough to ensure the message was actually sent.
 // Therefore, as soon as a callback is received from the ResourceHandle, this class 
 // will cancel the load and delete itself.
-class PingLoader : private ResourceHandleClient {
+class PingLoader : private WebKit::WebURLLoaderClient {
     WTF_MAKE_NONCOPYABLE(PingLoader); WTF_MAKE_FAST_ALLOCATED;
 public:
     enum ViolationReportType {
@@ -69,13 +70,13 @@
 private:
     PingLoader(Frame*, ResourceRequest&, StoredCredentials = AllowStoredCredentials);
 
-    virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) OVERRIDE { delete this; }
-    virtual void didReceiveData(ResourceHandle*, const char*, int, int) OVERRIDE { delete this; }
-    virtual void didFinishLoading(ResourceHandle*, double) OVERRIDE { delete this; }
-    virtual void didFail(ResourceHandle*, const ResourceError&) OVERRIDE { delete this; }
+    virtual void didReceiveResponse(WebKit::WebURLLoader*, const WebKit::WebURLResponse&) OVERRIDE { delete this; }
+    virtual void didReceiveData(WebKit::WebURLLoader*, const char*, int, int) OVERRIDE { delete this; }
+    virtual void didFinishLoading(WebKit::WebURLLoader*, double) OVERRIDE { delete this; }
+    virtual void didFail(WebKit::WebURLLoader*, const WebKit::WebURLError&) OVERRIDE { delete this; }
     void timeout(Timer<PingLoader>*) { delete this; }
 
-    RefPtr<ResourceHandle> m_handle;
+    OwnPtr<WebKit::WebURLLoader> m_loader;
     Timer<PingLoader> m_timeout;
 };
 
diff --git a/Source/core/loader/ResourceLoadNotifier.cpp b/Source/core/loader/ResourceLoadNotifier.cpp
index 7bfd2cb..cfe2424 100644
--- a/Source/core/loader/ResourceLoadNotifier.cpp
+++ b/Source/core/loader/ResourceLoadNotifier.cpp
@@ -51,7 +51,6 @@
     m_frame->loader()->applyUserAgent(request);
     m_frame->loader()->client()->dispatchWillSendRequest(loader, identifier, request, redirectResponse);
     InspectorInstrumentation::willSendRequest(m_frame, identifier, loader, request, redirectResponse, initiatorInfo);
-    request.setReportLoadTiming(true);
 }
 
 void ResourceLoadNotifier::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r, ResourceLoader* resourceLoader)
diff --git a/Source/core/loader/ResourceLoader.cpp b/Source/core/loader/ResourceLoader.cpp
index 967dc75..6a4172b 100644
--- a/Source/core/loader/ResourceLoader.cpp
+++ b/Source/core/loader/ResourceLoader.cpp
@@ -32,10 +32,15 @@
 
 #include "core/inspector/InspectorInstrumentation.h"
 #include "core/loader/ResourceLoaderHost.h"
-#include "core/page/Page.h"
 #include "core/platform/Logging.h"
+#include "core/platform/chromium/support/WrappedResourceRequest.h"
+#include "core/platform/chromium/support/WrappedResourceResponse.h"
 #include "core/platform/network/ResourceError.h"
-#include "core/platform/network/ResourceHandle.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebData.h"
+#include "public/platform/WebURLError.h"
+#include "public/platform/WebURLRequest.h"
+#include "public/platform/WebURLResponse.h"
 
 namespace WebCore {
 
@@ -54,20 +59,19 @@
 PassRefPtr<ResourceLoader> ResourceLoader::create(ResourceLoaderHost* host, CachedResource* resource, const ResourceRequest& request, const ResourceLoaderOptions& options)
 {
     RefPtr<ResourceLoader> loader(adoptRef(new ResourceLoader(host, resource, options)));
-    if (!loader->init(request))
-        return 0;
+    loader->init(request);
     loader->start();
     return loader.release();
 }
 
 ResourceLoader::ResourceLoader(ResourceLoaderHost* host, CachedResource* resource, const ResourceLoaderOptions& options)
     : m_host(host)
-    , m_loadingMultipartContent(false)
     , m_notifiedLoadComplete(false)
     , m_defersLoading(host->defersLoading())
     , m_options(options)
     , m_resource(resource)
-    , m_state(Uninitialized)
+    , m_state(Initialized)
+    , m_connectionState(ConnectionStateNew)
     , m_requestCountTracker(adoptPtr(new RequestCountTracker(host, resource)))
 {
 }
@@ -80,18 +84,16 @@
 void ResourceLoader::releaseResources()
 {
     ASSERT(m_state != Terminated);
-    if (m_state != Uninitialized) {
-        m_requestCountTracker.clear();
-        m_host->didLoadResource(m_resource);
-        if (m_state == Terminated)
-            return;
-        m_resource->clearLoader();
-        m_host->willTerminateResourceLoader(this);
-    }
+    m_requestCountTracker.clear();
+    m_host->didLoadResource(m_resource);
+    if (m_state == Terminated)
+        return;
+    m_resource->clearLoader();
+    m_host->willTerminateResourceLoader(this);
 
     ASSERT(m_state != Terminated);
     
-    // It's possible that when we release the handle, it will be
+    // It's possible that when we release the loader, it will be
     // deallocated and release the last reference to this object.
     // We need to retain to avoid accessing the object after it
     // has been deallocated and also to avoid reentering this method.
@@ -100,41 +102,28 @@
     m_host.clear();
     m_state = Terminated;
 
-    if (m_handle) {
-        // Clear out the ResourceHandle's client so that it doesn't try to call
-        // us back after we release it, unless it has been replaced by someone else.
-        if (m_handle->client() == this)
-            m_handle->setClient(0);
-        m_handle = 0;
+    if (m_loader) {
+        m_loader->cancel();
+        m_loader.clear();
     }
 
     m_deferredRequest = ResourceRequest();
 }
 
-bool ResourceLoader::init(const ResourceRequest& r)
+void ResourceLoader::init(const ResourceRequest& passedRequest)
 {
-    ASSERT(!m_handle);
-    ASSERT(m_request.isNull());
-    ASSERT(m_deferredRequest.isNull());
-    
-    ResourceRequest clientRequest(r);
-
-    willSendRequest(0, clientRequest, ResourceResponse());
-    if (clientRequest.isNull()) {
-        cancel();
-        return false;
-    }
+    ResourceRequest request(passedRequest);
+    m_host->willSendRequest(m_resource, request, ResourceResponse(), m_options);
+    request.setReportLoadTiming(true);
     ASSERT(m_state != Terminated);
-
-    m_originalRequest = m_request = clientRequest;
-    m_state = Initialized;
+    ASSERT(!request.isNull());
+    m_originalRequest = m_request = request;
     m_host->didInitializeResourceLoader(this);
-    return true;
 }
 
 void ResourceLoader::start()
 {
-    ASSERT(!m_handle);
+    ASSERT(!m_loader);
     ASSERT(!m_request.isNull());
     ASSERT(m_deferredRequest.isNull());
 
@@ -145,15 +134,25 @@
         return;
     }
 
-    if (m_state != Terminated)
-        m_handle = ResourceHandle::create(m_request, this, m_defersLoading, m_options.sniffContent == SniffContent, m_options.allowCredentials);
+    if (m_state == Terminated)
+        return;
+
+    if (m_connectionState != ConnectionStateNew)
+        CRASH();
+    m_connectionState = ConnectionStateStarted;
+
+    m_loader = adoptPtr(WebKit::Platform::current()->createURLLoader());
+    ASSERT(m_loader);
+    WebKit::WrappedResourceRequest wrappedRequest(m_request);
+    wrappedRequest.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredCredentials);
+    m_loader->loadAsynchronously(wrappedRequest, this);
 }
 
 void ResourceLoader::setDefersLoading(bool defers)
 {
     m_defersLoading = defers;
-    if (m_handle)
-        m_handle->setDefersLoading(defers);
+    if (m_loader)
+        m_loader->setDefersLoading(defers);
     if (!defers && !m_deferredRequest.isNull()) {
         m_request = m_deferredRequest;
         m_deferredRequest = ResourceRequest();
@@ -161,9 +160,11 @@
     }
 }
 
-void ResourceLoader::didDownloadData(ResourceHandle*, int length)
+void ResourceLoader::didDownloadData(WebKit::WebURLLoader*, int length)
 {
     RefPtr<ResourceLoader> protect(this);
+    if (m_connectionState != ConnectionStateReceivedResponse)
+        CRASH();
     m_resource->didDownloadData(length);
 }
 
@@ -182,9 +183,9 @@
 
 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority)
 {
-    if (handle()) {
+    if (m_loader) {
         m_host->didChangeLoadingPriority(m_resource, loadPriority);
-        handle()->didChangePriority(loadPriority);
+        m_loader->didChangePriority(static_cast<WebKit::WebURLRequest::Priority>(loadPriority));
     }
 }
 
@@ -221,9 +222,10 @@
         m_state = Finishing;
     m_resource->setResourceError(nonNullError);
 
-    if (m_handle) {
-        m_handle->cancel();
-        m_handle = 0;
+    if (m_loader) {
+        m_connectionState = ConnectionStateCanceled;
+        m_loader->cancel();
+        m_loader.clear();
     }
 
     m_host->didFailLoading(m_resource, nonNullError, m_options);
@@ -234,69 +236,73 @@
         releaseResources();
 }
 
-void ResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse)
+void ResourceLoader::willSendRequest(WebKit::WebURLLoader*, WebKit::WebURLRequest& passedRequest, const WebKit::WebURLResponse& passedRedirectResponse)
 {
-    // Store the previous URL because we may modify it.
-    KURL previousURL = m_request.url();
     RefPtr<ResourceLoader> protect(this);
 
+    ResourceRequest& request(passedRequest.toMutableResourceRequest());
     ASSERT(!request.isNull());
-    if (!redirectResponse.isNull()) {
-        if (!m_host->shouldRequest(m_resource, request, m_options)) {
-            cancel();
-            return;
-        }
-
-        m_resource->willSendRequest(request, redirectResponse);
+    const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceResponse());
+    ASSERT(!redirectResponse.isNull());
+    if (!m_host->shouldRequest(m_resource, request, m_options)) {
+        cancel();
+        return;
     }
-
+    m_host->redirectReceived(m_resource, redirectResponse);
+    m_resource->willSendRequest(request, redirectResponse);
     if (request.isNull() || m_state == Terminated)
         return;
 
     m_host->willSendRequest(m_resource, request, redirectResponse, m_options);
+    request.setReportLoadTiming(true);
+    ASSERT(!request.isNull());
     m_request = request;
-
-    if (request.isNull())
-        cancel();
 }
 
-void ResourceLoader::didReceiveCachedMetadata(ResourceHandle*, const char* data, int length)
+void ResourceLoader::didReceiveCachedMetadata(WebKit::WebURLLoader*, const char* data, int length)
 {
+    if (m_connectionState != ConnectionStateReceivedResponse && m_connectionState != ConnectionStateReceivingData)
+        CRASH();
     ASSERT(m_state == Initialized);
     m_resource->setSerializedCachedMetadata(data, length);
 }
 
-void ResourceLoader::didSendData(ResourceHandle*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
+void ResourceLoader::didSendData(WebKit::WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
 {
     ASSERT(m_state == Initialized);
     RefPtr<ResourceLoader> protect(this);
     m_resource->didSendData(bytesSent, totalBytesToBeSent);
 }
 
-void ResourceLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
+void ResourceLoader::didReceiveResponse(WebKit::WebURLLoader*, const WebKit::WebURLResponse& response)
 {
     ASSERT(!response.isNull());
     ASSERT(m_state == Initialized);
 
+    bool isMultipartPayload = response.isMultipartPayload();
+    bool isValidStateTransition = (m_connectionState == ConnectionStateStarted || m_connectionState == ConnectionStateReceivedResponse);
+    // In the case of multipart loads, calls to didReceiveData & didReceiveResponse can be interleaved.
+    if (!isMultipartPayload && !isValidStateTransition)
+        CRASH();
+    m_connectionState = ConnectionStateReceivedResponse;
+
     // Reference the object in this method since the additional processing can do
     // anything including removing the last reference to this object.
     RefPtr<ResourceLoader> protect(this);
-    m_resource->responseReceived(response);
+    m_resource->responseReceived(response.toResourceResponse());
     if (m_state == Terminated)
         return;
 
-    m_host->didReceiveResponse(m_resource, response, m_options);
+    m_host->didReceiveResponse(m_resource, response.toResourceResponse(), m_options);
 
-    if (response.isMultipart()) {
-        m_loadingMultipartContent = true;
-
+    if (response.toResourceResponse().isMultipart()) {
         // We don't count multiParts in a CachedResourceLoader's request count
         m_requestCountTracker.clear();
         if (!m_resource->isImage()) {
             cancel();
             return;
         }
-    } else if (m_loadingMultipartContent) {
+    } else if (isMultipartPayload) {
         // Since a subresource loader does not load multipart sections progressively, data was delivered to the loader all at once.
         // After the first multipart section is complete, signal to delegates that this load is "finished"
         m_host->subresourceLoaderFinishedLoadingOnePart(this);
@@ -310,8 +316,12 @@
     cancel();
 }
 
-void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, int length, int encodedDataLength)
+void ResourceLoader::didReceiveData(WebKit::WebURLLoader*, const char* data, int length, int encodedDataLength)
 {
+    if (m_connectionState != ConnectionStateReceivedResponse && m_connectionState != ConnectionStateReceivingData)
+        CRASH();
+    m_connectionState = ConnectionStateReceivingData;
+
     // It is possible to receive data on uninitialized resources if it had an error status code, and we are running a nested message
     // loop. When this occurs, ignoring the data is the correct action.
     if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgnoreHTTPStatusCodeErrors())
@@ -332,8 +342,11 @@
     InspectorInstrumentation::didReceiveResourceData(cookie);
 }
 
-void ResourceLoader::didFinishLoading(ResourceHandle*, double finishTime)
+void ResourceLoader::didFinishLoading(WebKit::WebURLLoader*, double finishTime)
 {
+    if (m_connectionState != ConnectionStateReceivedResponse && m_connectionState != ConnectionStateReceivingData)
+        CRASH();
+    m_connectionState = ConnectionStateFinishedLoading;
     if (m_state != Initialized)
         return;
     ASSERT(m_state != Terminated);
@@ -352,8 +365,9 @@
     releaseResources();
 }
 
-void ResourceLoader::didFail(ResourceHandle*, const ResourceError& error)
+void ResourceLoader::didFail(WebKit::WebURLLoader*, const WebKit::WebURLError& error)
 {
+    m_connectionState = ConnectionStateFailed;
     ASSERT(m_state != Terminated);
     LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string().latin1().data());
 
@@ -380,4 +394,22 @@
     return m_host->isLoadedBy(loader);
 }
 
+void ResourceLoader::loadResourceSynchronously(const ResourceRequest& request, StoredCredentials storedCredentials, ResourceError& error, ResourceResponse& response, Vector<char>& data)
+{
+    OwnPtr<WebKit::WebURLLoader> loader = adoptPtr(WebKit::Platform::current()->createURLLoader());
+    ASSERT(loader);
+
+    WebKit::WrappedResourceRequest requestIn(request);
+    requestIn.setAllowStoredCredentials(storedCredentials == AllowStoredCredentials);
+    WebKit::WrappedResourceResponse responseOut(response);
+    WebKit::WebURLError errorOut;
+    WebKit::WebData dataOut;
+
+    loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut);
+
+    error = errorOut;
+    data.clear();
+    data.append(dataOut.data(), dataOut.size());
+}
+
 }
diff --git a/Source/core/loader/ResourceLoader.h b/Source/core/loader/ResourceLoader.h
index fb2c106..6c39120 100644
--- a/Source/core/loader/ResourceLoader.h
+++ b/Source/core/loader/ResourceLoader.h
@@ -30,29 +30,27 @@
 #define ResourceLoader_h
 
 #include "core/loader/ResourceLoaderOptions.h"
-#include "core/platform/network/ResourceHandleClient.h"
 #include "core/platform/network/ResourceRequest.h"
-#include "core/platform/network/ResourceResponse.h"
-
+#include "public/platform/WebURLLoader.h"
+#include "public/platform/WebURLLoaderClient.h"
 #include "wtf/Forward.h"
 #include "wtf/RefCounted.h"
 
 namespace WebCore {
 
 class CachedResource;
-class DocumentLoader;
-class Frame;
-class FrameLoader;
 class KURL;
-class ResourceBuffer;
-class ResourceHandle;
+class ResourceError;
+class ResourceResponse;
 class ResourceLoaderHost;
 
-class ResourceLoader : public RefCounted<ResourceLoader>, protected ResourceHandleClient {
+class ResourceLoader : public RefCounted<ResourceLoader>, protected WebKit::WebURLLoaderClient {
 public:
     static PassRefPtr<ResourceLoader> create(ResourceLoaderHost*, CachedResource*, const ResourceRequest&, const ResourceLoaderOptions&);
     virtual ~ResourceLoader();
 
+    static void loadResourceSynchronously(const ResourceRequest&, StoredCredentials, ResourceError&, ResourceResponse&, Vector<char>& data);
+
     void cancel();
     void cancel(const ResourceError&);
     void cancelIfNotFinishing();
@@ -67,18 +65,17 @@
 
     void didChangePriority(ResourceLoadPriority);
 
-    // ResourceHandleClient
-    virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse& redirectResponse) OVERRIDE;
-    virtual void didSendData(ResourceHandle*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) OVERRIDE;
-    virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) OVERRIDE;
-    virtual void didReceiveData(ResourceHandle*, const char*, int, int encodedDataLength) OVERRIDE;
-    virtual void didReceiveCachedMetadata(ResourceHandle*, const char* data, int length) OVERRIDE;
-    virtual void didFinishLoading(ResourceHandle*, double finishTime) OVERRIDE;
-    virtual void didFail(ResourceHandle*, const ResourceError&) OVERRIDE;
-    virtual void didDownloadData(ResourceHandle*, int) OVERRIDE;
+    // WebURLLoaderClient
+    virtual void willSendRequest(WebKit::WebURLLoader*, WebKit::WebURLRequest&, const WebKit::WebURLResponse& redirectResponse) OVERRIDE;
+    virtual void didSendData(WebKit::WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) OVERRIDE;
+    virtual void didReceiveResponse(WebKit::WebURLLoader*, const WebKit::WebURLResponse&) OVERRIDE;
+    virtual void didReceiveData(WebKit::WebURLLoader*, const char*, int, int encodedDataLength) OVERRIDE;
+    virtual void didReceiveCachedMetadata(WebKit::WebURLLoader*, const char* data, int length) OVERRIDE;
+    virtual void didFinishLoading(WebKit::WebURLLoader*, double finishTime) OVERRIDE;
+    virtual void didFail(WebKit::WebURLLoader*, const WebKit::WebURLError&) OVERRIDE;
+    virtual void didDownloadData(WebKit::WebURLLoader*, int) OVERRIDE;
 
-    const KURL& url() const { return m_request.url(); } 
-    ResourceHandle* handle() const { return m_handle.get(); }
+    const KURL& url() const { return m_request.url(); }
     bool shouldSendResourceLoadCallbacks() const { return m_options.sendLoadCallbacks == SendCallbacks; }
     bool shouldSniffContent() const { return m_options.sniffContent == SniffContent; }
     bool isLoadedBy(ResourceLoaderHost*) const;
@@ -89,18 +86,17 @@
 private:
     ResourceLoader(ResourceLoaderHost*, CachedResource*, const ResourceLoaderOptions&);
 
-    bool init(const ResourceRequest&);
+    void init(const ResourceRequest&);
     void start();
 
     void didFinishLoadingOnePart(double finishTime);
 
-    RefPtr<ResourceHandle> m_handle;
+    OwnPtr<WebKit::WebURLLoader> m_loader;
     RefPtr<ResourceLoaderHost> m_host;
 
     ResourceRequest m_request;
     ResourceRequest m_originalRequest; // Before redirects.
 
-    bool m_loadingMultipartContent;
     bool m_notifiedLoadComplete;
 
     bool m_defersLoading;
@@ -108,12 +104,21 @@
     ResourceLoaderOptions m_options;
 
     enum ResourceLoaderState {
-        Uninitialized,
         Initialized,
         Finishing,
         Terminated
     };
 
+    enum ConnectionState {
+        ConnectionStateNew,
+        ConnectionStateStarted,
+        ConnectionStateReceivedResponse,
+        ConnectionStateReceivingData,
+        ConnectionStateFinishedLoading,
+        ConnectionStateCanceled,
+        ConnectionStateFailed,
+    };
+
     class RequestCountTracker {
     public:
         RequestCountTracker(ResourceLoaderHost*, CachedResource*);
@@ -125,6 +130,11 @@
 
     CachedResource* m_resource;
     ResourceLoaderState m_state;
+
+    // Used for sanity checking to make sure we don't experience illegal state
+    // transitions.
+    ConnectionState m_connectionState;
+
     OwnPtr<RequestCountTracker> m_requestCountTracker;
 };
 
diff --git a/Source/core/loader/ResourceLoaderHost.h b/Source/core/loader/ResourceLoaderHost.h
index 5bda7dd..c7af3d2 100644
--- a/Source/core/loader/ResourceLoaderHost.h
+++ b/Source/core/loader/ResourceLoaderHost.h
@@ -54,6 +54,7 @@
     virtual void incrementRequestCount(const CachedResource*) = 0;
     virtual void decrementRequestCount(const CachedResource*) = 0;
     virtual void didLoadResource(CachedResource*) = 0;
+    virtual void redirectReceived(CachedResource*, const ResourceResponse&) = 0;
 
     virtual void didFinishLoading(const CachedResource*, double finishTime, const ResourceLoaderOptions&) = 0;
     virtual void didChangeLoadingPriority(const CachedResource*, ResourceLoadPriority) = 0;
diff --git a/Source/core/loader/ResourceLoaderOptions.h b/Source/core/loader/ResourceLoaderOptions.h
index 53a3a95..adecfa4 100644
--- a/Source/core/loader/ResourceLoaderOptions.h
+++ b/Source/core/loader/ResourceLoaderOptions.h
@@ -32,7 +32,6 @@
 #define ResourceLoaderOptions_h
 
 #include "core/loader/cache/CachedResourceInitiatorInfo.h"
-#include "core/platform/network/ResourceHandleTypes.h"
 
 namespace WebCore {
 
@@ -77,6 +76,20 @@
     WorkerContext,
 };
 
+enum StoredCredentials {
+    AllowStoredCredentials,
+    DoNotAllowStoredCredentials
+};
+
+// APIs like XMLHttpRequest and EventSource let the user decide
+// whether to send credentials, but they're always sent for
+// same-origin requests. Additional information is needed to handle
+// cross-origin redirects correctly.
+enum CredentialRequest {
+    ClientRequestedCredentials,
+    ClientDidNotRequestCredentials
+};
+
 struct ResourceLoaderOptions {
     ResourceLoaderOptions()
         : sendLoadCallbacks(DoNotSendCallbacks)
diff --git a/Source/core/loader/cache/CachedResource.cpp b/Source/core/loader/cache/CachedResource.cpp
index 3a070be..24d14ee 100644
--- a/Source/core/loader/cache/CachedResource.cpp
+++ b/Source/core/loader/cache/CachedResource.cpp
@@ -36,7 +36,7 @@
 #include "core/platform/Logging.h"
 #include "core/platform/PurgeableBuffer.h"
 #include "core/platform/SharedBuffer.h"
-#include "core/platform/network/ResourceHandle.h"
+#include "public/platform/Platform.h"
 #include "weborigin/KURL.h"
 #include "wtf/CurrentTime.h"
 #include "wtf/MathExtras.h"
@@ -332,7 +332,8 @@
     ASSERT(!m_cachedMetadata);
 
     m_cachedMetadata = CachedMetadata::create(dataTypeID, data, size);
-    ResourceHandle::cacheMetadata(m_response, m_cachedMetadata->serialize());
+    const Vector<char>& serializedData = m_cachedMetadata->serialize();
+    WebKit::Platform::current()->cacheMetadata(m_response.url(), m_response.responseTime(), serializedData.data(), serializedData.size());
 }
 
 CachedMetadata* CachedResource::cachedMetadata(unsigned dataTypeID) const
diff --git a/Source/core/loader/cache/CachedResource.h b/Source/core/loader/cache/CachedResource.h
index a47846d..a1c69af 100644
--- a/Source/core/loader/cache/CachedResource.h
+++ b/Source/core/loader/cache/CachedResource.h
@@ -159,7 +159,6 @@
     // FIXME: Remove the stringless variant once all the callsites' error messages are updated.
     bool passesAccessControlCheck(SecurityOrigin*);
     bool passesAccessControlCheck(SecurityOrigin*, String& errorDescription);
-    bool canBeAccessedBy(SecurityOrigin*, String& error);
 
     // Called by the cache if the object has been removed from the cache
     // while still being referenced. This means the object should delete itself
diff --git a/Source/core/loader/cache/CachedResourceLoader.cpp b/Source/core/loader/cache/CachedResourceLoader.cpp
index 2dd3289..d06f008 100644
--- a/Source/core/loader/cache/CachedResourceLoader.cpp
+++ b/Source/core/loader/cache/CachedResourceLoader.cpp
@@ -53,6 +53,7 @@
 #include "core/page/DOMWindow.h"
 #include "core/page/Frame.h"
 #include "core/page/Performance.h"
+#include "core/page/ResourceTimingInfo.h"
 #include "core/page/Settings.h"
 #include "core/platform/Logging.h"
 #include "public/platform/Platform.h"
@@ -707,18 +708,17 @@
     if (request.options().requestInitiatorContext != DocumentContext)
         return;
 
-    CachedResourceInitiatorInfo info = request.options().initiatorInfo;
-    info.startTime = monotonicallyIncreasingTime();
+    RefPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(request.options().initiatorInfo.name, monotonicallyIncreasingTime());
 
     if (resource->type() == CachedResource::MainResource) {
         // <iframe>s should report the initial navigation requested by the parent document, but not subsequent navigations.
         if (frame()->ownerElement() && !frame()->ownerElement()->loadedNonEmptyDocument()) {
-            info.name = frame()->ownerElement()->localName();
-            m_initiatorMap.add(resource.get(), info);
+            info->setInitiatorType(frame()->ownerElement()->localName());
+            m_resourceTimingInfoMap.add(resource.get(), info);
             frame()->ownerElement()->didLoadNonEmptyDocument();
         }
     } else {
-        m_initiatorMap.add(resource.get(), info);
+        m_resourceTimingInfoMap.add(resource.get(), info);
     }
 }
 
@@ -895,22 +895,32 @@
     return CachePolicyVerify;
 }
 
+void CachedResourceLoader::redirectReceived(CachedResource* resource, const ResourceResponse& redirectResponse)
+{
+    ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource);
+    if (it != m_resourceTimingInfoMap.end())
+        it->value->addRedirect(redirectResponse);
+}
+
 void CachedResourceLoader::didLoadResource(CachedResource* resource)
 {
     RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader);
     RefPtr<Document> protectDocument(m_document);
 
     if (resource && resource->response().isHTTP() && ((!resource->errorOccurred() && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) {
-        HashMap<CachedResource*, CachedResourceInitiatorInfo>::iterator initiatorIt = m_initiatorMap.find(resource);
-        if (initiatorIt != m_initiatorMap.end()) {
+        ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource);
+        if (it != m_resourceTimingInfoMap.end()) {
             ASSERT(document());
             Document* initiatorDocument = document();
             if (resource->type() == CachedResource::MainResource)
                 initiatorDocument = document()->parentDocument();
             ASSERT(initiatorDocument);
-            const CachedResourceInitiatorInfo& info = initiatorIt->value;
-            initiatorDocument->domWindow()->performance()->addResourceTiming(info.name, initiatorDocument, resource->resourceRequest(), resource->response(), info.startTime, resource->loadFinishTime());
-            m_initiatorMap.remove(initiatorIt);
+            RefPtr<ResourceTimingInfo> info = it->value;
+            info->setInitialRequest(resource->resourceRequest());
+            info->setFinalResponse(resource->response());
+            info->setLoadFinishTime(resource->loadFinishTime());
+            initiatorDocument->domWindow()->performance()->addResourceTiming(*info, initiatorDocument);
+            m_resourceTimingInfoMap.remove(it);
         }
     }
 
diff --git a/Source/core/loader/cache/CachedResourceLoader.h b/Source/core/loader/cache/CachedResourceLoader.h
index b0b05bf..2682e9e 100644
--- a/Source/core/loader/cache/CachedResourceLoader.h
+++ b/Source/core/loader/cache/CachedResourceLoader.h
@@ -56,6 +56,7 @@
 class FrameLoader;
 class ImageLoader;
 class KURL;
+class ResourceTimingInfo;
 
 // The CachedResourceLoader provides a per-context interface to the MemoryCache
 // and enforces a bunch of security checks and rules for resource revalidation.
@@ -132,6 +133,7 @@
     virtual void incrementRequestCount(const CachedResource*) OVERRIDE;
     virtual void decrementRequestCount(const CachedResource*) OVERRIDE;
     virtual void didLoadResource(CachedResource*) OVERRIDE;
+    virtual void redirectReceived(CachedResource*, const ResourceResponse&) OVERRIDE;
     virtual void didFinishLoading(const CachedResource*, double finishTime, const ResourceLoaderOptions&) OVERRIDE;
     virtual void didChangeLoadingPriority(const CachedResource*, ResourceLoadPriority) OVERRIDE;
     virtual void didFailLoading(const CachedResource*, const ResourceError&, const ResourceLoaderOptions&) OVERRIDE;
@@ -196,7 +198,8 @@
 
     Timer<CachedResourceLoader> m_garbageCollectDocumentResourcesTimer;
 
-    HashMap<CachedResource*, CachedResourceInitiatorInfo> m_initiatorMap;
+    typedef HashMap<CachedResource*, RefPtr<ResourceTimingInfo> > ResourceTimingInfoMap;
+    ResourceTimingInfoMap m_resourceTimingInfoMap;
 
     // 29 bits left
     bool m_autoLoadImages : 1;
diff --git a/Source/core/make_derived_sources.target.darwin-arm.mk b/Source/core/make_derived_sources.target.darwin-arm.mk
index a7adb64..8f9fab3 100644
--- a/Source/core/make_derived_sources.target.darwin-arm.mk
+++ b/Source/core/make_derived_sources.target.darwin-arm.mk
@@ -189,9 +189,9 @@
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir))
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
-$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/make-css-file-arrays.pl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/preprocessor.pm $(LOCAL_PATH)/third_party/WebKit/Source/core/css/html.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/quirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/view-source.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromium.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumLinux.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumSkia.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWin.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWinQuirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/svg.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mathml.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControls.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControlsAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/fullscreen.css $(GYP_TARGET_DEPENDENCIES)
+$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/make-css-file-arrays.pl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/preprocessor.pm $(LOCAL_PATH)/third_party/WebKit/Source/core/css/html.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/quirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/view-source.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromium.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumLinux.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumSkia.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWin.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWinQuirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/svg.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControls.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControlsAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/fullscreen.css $(GYP_TARGET_DEPENDENCIES)
 	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_UserAgentStyleSheets ($@)"
-	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/action_useragentstylesheets.py "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h" "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp" css/html.css css/quirks.css css/view-source.css css/themeChromium.css css/themeChromiumAndroid.css css/themeChromiumLinux.css css/themeChromiumSkia.css css/themeWin.css css/themeWinQuirks.css css/svg.css css/mathml.css css/mediaControls.css css/mediaControlsAndroid.css css/fullscreen.css -- css/make-css-file-arrays.pl scripts/preprocessor.pm -- --defines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\""
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/action_useragentstylesheets.py "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h" "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp" css/html.css css/quirks.css css/view-source.css css/themeChromium.css css/themeChromiumAndroid.css css/themeChromiumLinux.css css/themeChromiumSkia.css css/themeWin.css css/themeWinQuirks.css css/svg.css css/mediaControls.css css/mediaControlsAndroid.css css/fullscreen.css -- css/make-css-file-arrays.pl scripts/preprocessor.pm -- --defines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\""
 
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp: $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h ;
 
@@ -279,7 +279,7 @@
 $(gyp_shared_intermediate_dir)/webkit/CSSGrammar.y: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
 $(gyp_shared_intermediate_dir)/webkit/CSSGrammar.y: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSGrammar.y.in $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSGrammar.y.includes $(GYP_TARGET_DEPENDENCIES)
 	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_preprocess_grammar ($@)"
-	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; perl -Iscripts css/makegrammar.pl --outputDir "$(gyp_shared_intermediate_dir)/webkit/" --extraDefines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\"" --preprocessOnly --preprocessor "/usr/bin/gcc -E -P -x c++" css/CSSGrammar.y.in css/CSSGrammar.y.includes
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; perl -Iscripts css/makegrammar.pl --outputDir "$(gyp_shared_intermediate_dir)/webkit/" css/CSSGrammar.y.in css/CSSGrammar.y.includes
 
 
 ### Rules for action "MakeTokenMatcher":
@@ -450,10 +450,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DANDROID' \
 	'-D__GNU_SOURCE=1' \
 	'-DUSE_STLPORT=1' \
@@ -530,10 +530,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DANDROID' \
 	'-D__GNU_SOURCE=1' \
 	'-DUSE_STLPORT=1' \
diff --git a/Source/core/make_derived_sources.target.darwin-mips.mk b/Source/core/make_derived_sources.target.darwin-mips.mk
index d043294..a716749 100644
--- a/Source/core/make_derived_sources.target.darwin-mips.mk
+++ b/Source/core/make_derived_sources.target.darwin-mips.mk
@@ -189,9 +189,9 @@
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir))
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
-$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/make-css-file-arrays.pl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/preprocessor.pm $(LOCAL_PATH)/third_party/WebKit/Source/core/css/html.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/quirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/view-source.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromium.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumLinux.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumSkia.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWin.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWinQuirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/svg.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mathml.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControls.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControlsAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/fullscreen.css $(GYP_TARGET_DEPENDENCIES)
+$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/make-css-file-arrays.pl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/preprocessor.pm $(LOCAL_PATH)/third_party/WebKit/Source/core/css/html.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/quirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/view-source.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromium.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumLinux.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumSkia.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWin.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWinQuirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/svg.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControls.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControlsAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/fullscreen.css $(GYP_TARGET_DEPENDENCIES)
 	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_UserAgentStyleSheets ($@)"
-	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/action_useragentstylesheets.py "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h" "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp" css/html.css css/quirks.css css/view-source.css css/themeChromium.css css/themeChromiumAndroid.css css/themeChromiumLinux.css css/themeChromiumSkia.css css/themeWin.css css/themeWinQuirks.css css/svg.css css/mathml.css css/mediaControls.css css/mediaControlsAndroid.css css/fullscreen.css -- css/make-css-file-arrays.pl scripts/preprocessor.pm -- --defines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\""
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/action_useragentstylesheets.py "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h" "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp" css/html.css css/quirks.css css/view-source.css css/themeChromium.css css/themeChromiumAndroid.css css/themeChromiumLinux.css css/themeChromiumSkia.css css/themeWin.css css/themeWinQuirks.css css/svg.css css/mediaControls.css css/mediaControlsAndroid.css css/fullscreen.css -- css/make-css-file-arrays.pl scripts/preprocessor.pm -- --defines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\""
 
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp: $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h ;
 
@@ -279,7 +279,7 @@
 $(gyp_shared_intermediate_dir)/webkit/CSSGrammar.y: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
 $(gyp_shared_intermediate_dir)/webkit/CSSGrammar.y: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSGrammar.y.in $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSGrammar.y.includes $(GYP_TARGET_DEPENDENCIES)
 	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_preprocess_grammar ($@)"
-	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; perl -Iscripts css/makegrammar.pl --outputDir "$(gyp_shared_intermediate_dir)/webkit/" --extraDefines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\"" --preprocessOnly --preprocessor "/usr/bin/gcc -E -P -x c++" css/CSSGrammar.y.in css/CSSGrammar.y.includes
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; perl -Iscripts css/makegrammar.pl --outputDir "$(gyp_shared_intermediate_dir)/webkit/" css/CSSGrammar.y.in css/CSSGrammar.y.includes
 
 
 ### Rules for action "MakeTokenMatcher":
@@ -450,10 +450,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DANDROID' \
 	'-D__GNU_SOURCE=1' \
 	'-DUSE_STLPORT=1' \
@@ -530,10 +530,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DANDROID' \
 	'-D__GNU_SOURCE=1' \
 	'-DUSE_STLPORT=1' \
diff --git a/Source/core/make_derived_sources.target.darwin-x86.mk b/Source/core/make_derived_sources.target.darwin-x86.mk
index 9dc8cd6..6594a40 100644
--- a/Source/core/make_derived_sources.target.darwin-x86.mk
+++ b/Source/core/make_derived_sources.target.darwin-x86.mk
@@ -189,9 +189,9 @@
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir))
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
-$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/make-css-file-arrays.pl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/preprocessor.pm $(LOCAL_PATH)/third_party/WebKit/Source/core/css/html.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/quirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/view-source.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromium.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumLinux.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumSkia.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWin.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWinQuirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/svg.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mathml.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControls.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControlsAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/fullscreen.css $(GYP_TARGET_DEPENDENCIES)
+$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/make-css-file-arrays.pl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/preprocessor.pm $(LOCAL_PATH)/third_party/WebKit/Source/core/css/html.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/quirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/view-source.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromium.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumLinux.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumSkia.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWin.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWinQuirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/svg.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControls.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControlsAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/fullscreen.css $(GYP_TARGET_DEPENDENCIES)
 	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_UserAgentStyleSheets ($@)"
-	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/action_useragentstylesheets.py "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h" "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp" css/html.css css/quirks.css css/view-source.css css/themeChromium.css css/themeChromiumAndroid.css css/themeChromiumLinux.css css/themeChromiumSkia.css css/themeWin.css css/themeWinQuirks.css css/svg.css css/mathml.css css/mediaControls.css css/mediaControlsAndroid.css css/fullscreen.css -- css/make-css-file-arrays.pl scripts/preprocessor.pm -- --defines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\""
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/action_useragentstylesheets.py "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h" "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp" css/html.css css/quirks.css css/view-source.css css/themeChromium.css css/themeChromiumAndroid.css css/themeChromiumLinux.css css/themeChromiumSkia.css css/themeWin.css css/themeWinQuirks.css css/svg.css css/mediaControls.css css/mediaControlsAndroid.css css/fullscreen.css -- css/make-css-file-arrays.pl scripts/preprocessor.pm -- --defines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\""
 
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp: $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h ;
 
@@ -279,7 +279,7 @@
 $(gyp_shared_intermediate_dir)/webkit/CSSGrammar.y: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
 $(gyp_shared_intermediate_dir)/webkit/CSSGrammar.y: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSGrammar.y.in $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSGrammar.y.includes $(GYP_TARGET_DEPENDENCIES)
 	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_preprocess_grammar ($@)"
-	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; perl -Iscripts css/makegrammar.pl --outputDir "$(gyp_shared_intermediate_dir)/webkit/" --extraDefines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\"" --preprocessOnly --preprocessor "/usr/bin/gcc -E -P -x c++" css/CSSGrammar.y.in css/CSSGrammar.y.includes
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; perl -Iscripts css/makegrammar.pl --outputDir "$(gyp_shared_intermediate_dir)/webkit/" css/CSSGrammar.y.in css/CSSGrammar.y.includes
 
 
 ### Rules for action "MakeTokenMatcher":
@@ -452,10 +452,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DANDROID' \
 	'-D__GNU_SOURCE=1' \
 	'-DUSE_STLPORT=1' \
@@ -535,10 +535,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DANDROID' \
 	'-D__GNU_SOURCE=1' \
 	'-DUSE_STLPORT=1' \
diff --git a/Source/core/make_derived_sources.target.linux-arm.mk b/Source/core/make_derived_sources.target.linux-arm.mk
index a7adb64..8f9fab3 100644
--- a/Source/core/make_derived_sources.target.linux-arm.mk
+++ b/Source/core/make_derived_sources.target.linux-arm.mk
@@ -189,9 +189,9 @@
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir))
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
-$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/make-css-file-arrays.pl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/preprocessor.pm $(LOCAL_PATH)/third_party/WebKit/Source/core/css/html.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/quirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/view-source.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromium.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumLinux.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumSkia.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWin.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWinQuirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/svg.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mathml.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControls.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControlsAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/fullscreen.css $(GYP_TARGET_DEPENDENCIES)
+$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/make-css-file-arrays.pl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/preprocessor.pm $(LOCAL_PATH)/third_party/WebKit/Source/core/css/html.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/quirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/view-source.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromium.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumLinux.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumSkia.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWin.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWinQuirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/svg.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControls.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControlsAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/fullscreen.css $(GYP_TARGET_DEPENDENCIES)
 	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_UserAgentStyleSheets ($@)"
-	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/action_useragentstylesheets.py "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h" "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp" css/html.css css/quirks.css css/view-source.css css/themeChromium.css css/themeChromiumAndroid.css css/themeChromiumLinux.css css/themeChromiumSkia.css css/themeWin.css css/themeWinQuirks.css css/svg.css css/mathml.css css/mediaControls.css css/mediaControlsAndroid.css css/fullscreen.css -- css/make-css-file-arrays.pl scripts/preprocessor.pm -- --defines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\""
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/action_useragentstylesheets.py "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h" "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp" css/html.css css/quirks.css css/view-source.css css/themeChromium.css css/themeChromiumAndroid.css css/themeChromiumLinux.css css/themeChromiumSkia.css css/themeWin.css css/themeWinQuirks.css css/svg.css css/mediaControls.css css/mediaControlsAndroid.css css/fullscreen.css -- css/make-css-file-arrays.pl scripts/preprocessor.pm -- --defines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\""
 
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp: $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h ;
 
@@ -279,7 +279,7 @@
 $(gyp_shared_intermediate_dir)/webkit/CSSGrammar.y: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
 $(gyp_shared_intermediate_dir)/webkit/CSSGrammar.y: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSGrammar.y.in $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSGrammar.y.includes $(GYP_TARGET_DEPENDENCIES)
 	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_preprocess_grammar ($@)"
-	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; perl -Iscripts css/makegrammar.pl --outputDir "$(gyp_shared_intermediate_dir)/webkit/" --extraDefines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\"" --preprocessOnly --preprocessor "/usr/bin/gcc -E -P -x c++" css/CSSGrammar.y.in css/CSSGrammar.y.includes
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; perl -Iscripts css/makegrammar.pl --outputDir "$(gyp_shared_intermediate_dir)/webkit/" css/CSSGrammar.y.in css/CSSGrammar.y.includes
 
 
 ### Rules for action "MakeTokenMatcher":
@@ -450,10 +450,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DANDROID' \
 	'-D__GNU_SOURCE=1' \
 	'-DUSE_STLPORT=1' \
@@ -530,10 +530,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DANDROID' \
 	'-D__GNU_SOURCE=1' \
 	'-DUSE_STLPORT=1' \
diff --git a/Source/core/make_derived_sources.target.linux-mips.mk b/Source/core/make_derived_sources.target.linux-mips.mk
index d043294..a716749 100644
--- a/Source/core/make_derived_sources.target.linux-mips.mk
+++ b/Source/core/make_derived_sources.target.linux-mips.mk
@@ -189,9 +189,9 @@
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir))
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
-$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/make-css-file-arrays.pl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/preprocessor.pm $(LOCAL_PATH)/third_party/WebKit/Source/core/css/html.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/quirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/view-source.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromium.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumLinux.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumSkia.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWin.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWinQuirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/svg.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mathml.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControls.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControlsAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/fullscreen.css $(GYP_TARGET_DEPENDENCIES)
+$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/make-css-file-arrays.pl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/preprocessor.pm $(LOCAL_PATH)/third_party/WebKit/Source/core/css/html.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/quirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/view-source.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromium.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumLinux.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumSkia.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWin.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWinQuirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/svg.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControls.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControlsAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/fullscreen.css $(GYP_TARGET_DEPENDENCIES)
 	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_UserAgentStyleSheets ($@)"
-	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/action_useragentstylesheets.py "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h" "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp" css/html.css css/quirks.css css/view-source.css css/themeChromium.css css/themeChromiumAndroid.css css/themeChromiumLinux.css css/themeChromiumSkia.css css/themeWin.css css/themeWinQuirks.css css/svg.css css/mathml.css css/mediaControls.css css/mediaControlsAndroid.css css/fullscreen.css -- css/make-css-file-arrays.pl scripts/preprocessor.pm -- --defines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\""
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/action_useragentstylesheets.py "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h" "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp" css/html.css css/quirks.css css/view-source.css css/themeChromium.css css/themeChromiumAndroid.css css/themeChromiumLinux.css css/themeChromiumSkia.css css/themeWin.css css/themeWinQuirks.css css/svg.css css/mediaControls.css css/mediaControlsAndroid.css css/fullscreen.css -- css/make-css-file-arrays.pl scripts/preprocessor.pm -- --defines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\""
 
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp: $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h ;
 
@@ -279,7 +279,7 @@
 $(gyp_shared_intermediate_dir)/webkit/CSSGrammar.y: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
 $(gyp_shared_intermediate_dir)/webkit/CSSGrammar.y: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSGrammar.y.in $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSGrammar.y.includes $(GYP_TARGET_DEPENDENCIES)
 	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_preprocess_grammar ($@)"
-	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; perl -Iscripts css/makegrammar.pl --outputDir "$(gyp_shared_intermediate_dir)/webkit/" --extraDefines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\"" --preprocessOnly --preprocessor "/usr/bin/gcc -E -P -x c++" css/CSSGrammar.y.in css/CSSGrammar.y.includes
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; perl -Iscripts css/makegrammar.pl --outputDir "$(gyp_shared_intermediate_dir)/webkit/" css/CSSGrammar.y.in css/CSSGrammar.y.includes
 
 
 ### Rules for action "MakeTokenMatcher":
@@ -450,10 +450,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DANDROID' \
 	'-D__GNU_SOURCE=1' \
 	'-DUSE_STLPORT=1' \
@@ -530,10 +530,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DANDROID' \
 	'-D__GNU_SOURCE=1' \
 	'-DUSE_STLPORT=1' \
diff --git a/Source/core/make_derived_sources.target.linux-x86.mk b/Source/core/make_derived_sources.target.linux-x86.mk
index 9dc8cd6..6594a40 100644
--- a/Source/core/make_derived_sources.target.linux-x86.mk
+++ b/Source/core/make_derived_sources.target.linux-x86.mk
@@ -189,9 +189,9 @@
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir))
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
-$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/make-css-file-arrays.pl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/preprocessor.pm $(LOCAL_PATH)/third_party/WebKit/Source/core/css/html.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/quirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/view-source.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromium.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumLinux.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumSkia.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWin.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWinQuirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/svg.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mathml.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControls.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControlsAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/fullscreen.css $(GYP_TARGET_DEPENDENCIES)
+$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/make-css-file-arrays.pl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/preprocessor.pm $(LOCAL_PATH)/third_party/WebKit/Source/core/css/html.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/quirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/view-source.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromium.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumLinux.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeChromiumSkia.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWin.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/themeWinQuirks.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/svg.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControls.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/mediaControlsAndroid.css $(LOCAL_PATH)/third_party/WebKit/Source/core/css/fullscreen.css $(GYP_TARGET_DEPENDENCIES)
 	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_UserAgentStyleSheets ($@)"
-	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/action_useragentstylesheets.py "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h" "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp" css/html.css css/quirks.css css/view-source.css css/themeChromium.css css/themeChromiumAndroid.css css/themeChromiumLinux.css css/themeChromiumSkia.css css/themeWin.css css/themeWinQuirks.css css/svg.css css/mathml.css css/mediaControls.css css/mediaControlsAndroid.css css/fullscreen.css -- css/make-css-file-arrays.pl scripts/preprocessor.pm -- --defines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\""
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/action_useragentstylesheets.py "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h" "$(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp" css/html.css css/quirks.css css/view-source.css css/themeChromium.css css/themeChromiumAndroid.css css/themeChromiumLinux.css css/themeChromiumSkia.css css/themeWin.css css/themeWinQuirks.css css/svg.css css/mediaControls.css css/mediaControlsAndroid.css css/fullscreen.css -- css/make-css-file-arrays.pl scripts/preprocessor.pm -- --defines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\""
 
 $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheetsData.cpp: $(gyp_shared_intermediate_dir)/webkit/UserAgentStyleSheets.h ;
 
@@ -279,7 +279,7 @@
 $(gyp_shared_intermediate_dir)/webkit/CSSGrammar.y: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
 $(gyp_shared_intermediate_dir)/webkit/CSSGrammar.y: $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSGrammar.y.in $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSGrammar.y.includes $(GYP_TARGET_DEPENDENCIES)
 	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_preprocess_grammar ($@)"
-	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; perl -Iscripts css/makegrammar.pl --outputDir "$(gyp_shared_intermediate_dir)/webkit/" --extraDefines "\"ENABLE_CSS3_TEXT=0\" \"ENABLE_CSS_EXCLUSIONS=1\" \"ENABLE_CSS_REGIONS=1\" \"ENABLE_CUSTOM_SCHEME_HANDLER=0\" \"ENABLE_ENCRYPTED_MEDIA_V2=1\" \"ENABLE_SVG_FONTS=1\" \"ENABLE_TOUCH_ICON_LOADING=1\" \"ENABLE_GDI_FONTS_ON_WINDOWS=1\" \"WTF_USE_CONCATENATED_IMPULSE_RESPONSES=1\" \"ENABLE_CALENDAR_PICKER=0\" \"ENABLE_FAST_MOBILE_SCROLLING=1\" \"ENABLE_INPUT_SPEECH=0\" \"ENABLE_LEGACY_NOTIFICATIONS=0\" \"ENABLE_MEDIA_CAPTURE=1\" \"ENABLE_NOTIFICATIONS=0\" \"ENABLE_ORIENTATION_EVENTS=1\" \"ENABLE_PRINTING=0\" \"ENABLE_NAVIGATOR_CONTENT_UTILS=0\" \"WTF_USE_NATIVE_FULLSCREEN_VIDEO=1\" \"ENABLE_OPENTYPE_VERTICAL=1\" \"WTF_USE_HARFBUZZ=1\"" --preprocessOnly --preprocessor "/usr/bin/gcc -E -P -x c++" css/CSSGrammar.y.in css/CSSGrammar.y.includes
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; perl -Iscripts css/makegrammar.pl --outputDir "$(gyp_shared_intermediate_dir)/webkit/" css/CSSGrammar.y.in css/CSSGrammar.y.includes
 
 
 ### Rules for action "MakeTokenMatcher":
@@ -452,10 +452,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DANDROID' \
 	'-D__GNU_SOURCE=1' \
 	'-DUSE_STLPORT=1' \
@@ -535,10 +535,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DANDROID' \
 	'-D__GNU_SOURCE=1' \
 	'-DUSE_STLPORT=1' \
diff --git a/Source/core/page/Chrome.cpp b/Source/core/page/Chrome.cpp
index aaafe0e..c62c697 100644
--- a/Source/core/page/Chrome.cpp
+++ b/Source/core/page/Chrome.cpp
@@ -387,11 +387,6 @@
     m_client->runOpenPanel(frame, fileChooser);
 }
 
-void Chrome::loadIconForFiles(const Vector<String>& filenames, FileIconLoader* loader)
-{
-    m_client->loadIconForFiles(filenames, loader);
-}
-
 void Chrome::dispatchViewportPropertiesDidChange(const ViewportArguments& arguments) const
 {
     m_client->dispatchViewportPropertiesDidChange(arguments);
diff --git a/Source/core/page/Chrome.h b/Source/core/page/Chrome.h
index e5a0f24..ecddbbe 100644
--- a/Source/core/page/Chrome.h
+++ b/Source/core/page/Chrome.h
@@ -36,7 +36,6 @@
 class DateTimeChooser;
 class DateTimeChooserClient;
 class FileChooser;
-class FileIconLoader;
 class FloatRect;
 class Frame;
 class Geolocation;
@@ -129,7 +128,6 @@
     PassRefPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&);
 
     void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
-    void loadIconForFiles(const Vector<String>&, FileIconLoader*);
     void enumerateChosenDirectory(FileChooser*);
 
     void dispatchViewportPropertiesDidChange(const ViewportArguments&) const;
diff --git a/Source/core/page/ChromeClient.h b/Source/core/page/ChromeClient.h
index 65f5de2..b95a1df 100644
--- a/Source/core/page/ChromeClient.h
+++ b/Source/core/page/ChromeClient.h
@@ -56,7 +56,6 @@
 class DateTimeChooserClient;
 class Element;
 class FileChooser;
-class FileIconLoader;
 class FloatRect;
 class Frame;
 class Geolocation;
@@ -192,8 +191,6 @@
     virtual PassRefPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) = 0;
 
     virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0;
-    // Asynchronous request to load an icon for specified filenames.
-    virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*) = 0;
 
     // Asychronous request to enumerate all files in a directory chosen by the user.
     virtual void enumerateChosenDirectory(FileChooser*) = 0;
diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp
index ecc6e87..d7a1900 100644
--- a/Source/core/page/EventHandler.cpp
+++ b/Source/core/page/EventHandler.cpp
@@ -381,6 +381,7 @@
 
 static VisibleSelection expandSelectionToRespectUserSelectAll(Node* targetNode, const VisibleSelection& selection)
 {
+#if ENABLE(USERSELECT_ALL)
     Node* rootUserSelectAll = Position::rootUserSelectAllForNode(targetNode);
     if (!rootUserSelectAll)
         return selection;
@@ -390,6 +391,10 @@
     newSelection.setExtent(positionAfterNode(rootUserSelectAll).downstream(CanCrossEditingBoundary));
 
     return newSelection;
+#else
+    UNUSED_PARAM(targetNode);
+    return selection;
+#endif
 }
 
 bool EventHandler::updateSelectionForMouseDownDispatchingSelectStart(Node* targetNode, const VisibleSelection& selection, TextGranularity granularity)
@@ -765,6 +770,7 @@
         newSelection = VisibleSelection(targetPosition);
     }
 
+#if ENABLE(USERSELECT_ALL)
     Node* rootUserSelectAllForMousePressNode = Position::rootUserSelectAllForNode(m_mousePressNode.get());
     if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePressNode == Position::rootUserSelectAllForNode(target)) {
         newSelection.setBase(positionBeforeNode(rootUserSelectAllForMousePressNode).upstream(CanCrossEditingBoundary));
@@ -782,6 +788,9 @@
         else
             newSelection.setExtent(targetPosition);
     }
+#else
+    newSelection.setExtent(targetPosition);
+#endif
 
     if (m_frame->selection()->granularity() != CharacterGranularity)
         newSelection.expandUsingGranularity(m_frame->selection()->granularity());
@@ -1172,7 +1181,7 @@
         if (renderer) {
             if (RenderLayer* layer = renderer->enclosingLayer()) {
                 if (FrameView* view = m_frame->view())
-                    inResizer = layer->isPointInResizeControl(view->windowToContents(event.event().position()), RenderLayer::ResizerForPointer);
+                    inResizer = layer->isPointInResizeControl(view->windowToContents(event.event().position()), ResizerForPointer);
             }
         }
         if ((editable || (renderer && renderer->isText() && node->canStartSelection())) && !inResizer && !scrollbar)
@@ -1276,6 +1285,8 @@
     m_frame->loader()->resetMultipleFormSubmissionProtection();
     
     cancelFakeMouseMoveEvent();
+    if (m_eventHandlerWillResetCapturingMouseEventsNode)
+        m_capturingMouseEventsNode = 0;
     m_mousePressed = true;
     m_capturesDragging = true;
     setLastKnownMousePosition(mouseEvent);
@@ -1336,7 +1347,7 @@
     if (FrameView* view = m_frame->view()) {
         RenderLayer* layer = m_clickNode->renderer() ? m_clickNode->renderer()->enclosingLayer() : 0;
         IntPoint p = view->windowToContents(mouseEvent.position());
-        if (layer && layer->isPointInResizeControl(p, RenderLayer::ResizerForPointer)) {
+        if (layer && layer->isPointInResizeControl(p, ResizerForPointer)) {
             layer->setInResizeMode(true);
             m_resizeLayer = layer;
             m_offsetFromResizeCorner = layer->offsetFromResizeCorner(p);
@@ -1406,6 +1417,20 @@
     return layer;
 }
 
+ScrollableArea* EventHandler::associatedScrollableArea(const RenderLayer* layer) const
+{
+    ScrollableArea* layerScrollableArea = layer->scrollableArea();
+    if (!layerScrollableArea)
+        return 0;
+
+    if (FrameView* frameView = m_frame->view()) {
+        if (frameView->containsScrollableArea(layerScrollableArea))
+            return layerScrollableArea;
+    }
+
+    return 0;
+}
+
 bool EventHandler::mouseMoved(const PlatformMouseEvent& event)
 {
     RefPtr<FrameView> protector(m_frame->view());
@@ -1419,10 +1444,8 @@
         return result;
 
     if (RenderLayer* layer = layerForNode(hoveredNode.innerNode())) {
-        if (FrameView* frameView = m_frame->view()) {
-            if (frameView->containsScrollableArea(layer))
-                layer->mouseMovedInContentArea();
-        }
+        if (ScrollableArea* layerScrollableArea = associatedScrollableArea(layer))
+            layerScrollableArea->mouseMovedInContentArea();
     }
 
     if (FrameView* frameView = m_frame->view())
@@ -1870,7 +1893,7 @@
 {
     ASSERT(m_frame);
     ASSERT(m_frame->document());
-    
+
     return m_frame->document()->prepareMouseEvent(request, documentPointForWindowPoint(m_frame, mev.position()), mev);
 }
 
@@ -1950,12 +1973,8 @@
             }
         } else if (page && (layerForLastNode && (!layerForNodeUnderMouse || layerForNodeUnderMouse != layerForLastNode))) {
             // The mouse has moved between layers.
-            if (Frame* frame = m_lastNodeUnderMouse->document()->frame()) {
-                if (FrameView* frameView = frame->view()) {
-                    if (frameView->containsScrollableArea(layerForLastNode))
-                        layerForLastNode->mouseExitedContentArea();
-                }
-            }
+            if (ScrollableArea* scrollableAreaForLastNode = associatedScrollableArea(layerForLastNode))
+                scrollableAreaForLastNode->mouseExitedContentArea();
         }
 
         if (m_nodeUnderMouse && (!m_lastNodeUnderMouse || m_lastNodeUnderMouse->document() != m_frame->document())) {
@@ -1966,12 +1985,8 @@
             }
         } else if (page && (layerForNodeUnderMouse && (!layerForLastNode || layerForNodeUnderMouse != layerForLastNode))) {
             // The mouse has moved between layers.
-            if (Frame* frame = m_nodeUnderMouse->document()->frame()) {
-                if (FrameView* frameView = frame->view()) {
-                    if (frameView->containsScrollableArea(layerForNodeUnderMouse))
-                        layerForNodeUnderMouse->mouseEnteredContentArea();
-                }
-            }
+            if (ScrollableArea* scrollableAreaForNodeUnderMouse = associatedScrollableArea(layerForNodeUnderMouse))
+                scrollableAreaForNodeUnderMouse->mouseEnteredContentArea();
         }
 
         if (m_lastNodeUnderMouse && m_lastNodeUnderMouse->document() != m_frame->document()) {
@@ -2407,7 +2422,7 @@
     if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) {
         RenderLayer* layer = eventTarget->renderer() ? eventTarget->renderer()->enclosingLayer() : 0;
         IntPoint p = m_frame->view()->windowToContents(gestureEvent.position());
-        if (layer && layer->isPointInResizeControl(p, RenderLayer::ResizerForTouch)) {
+        if (layer && layer->isPointInResizeControl(p, ResizerForTouch)) {
             layer->setInResizeMode(true);
             m_resizeLayer = layer;
             m_offsetFromResizeCorner = layer->offsetFromResizeCorner(p);
diff --git a/Source/core/page/EventHandler.h b/Source/core/page/EventHandler.h
index e1afe16..0d44e6f 100644
--- a/Source/core/page/EventHandler.h
+++ b/Source/core/page/EventHandler.h
@@ -67,6 +67,7 @@
 class RenderObject;
 class RenderWidget;
 class SVGElementInstance;
+class ScrollableArea;
 class Scrollbar;
 class TextEvent;
 class TouchEvent;
@@ -231,6 +232,8 @@
 
     bool isInsideScrollbar(const IntPoint&) const;
 
+    ScrollableArea* associatedScrollableArea(const RenderLayer*) const;
+
     bool dispatchSyntheticTouchEventIfEnabled(const PlatformMouseEvent&);
     HitTestResult hitTestResultInFrame(Frame*, const LayoutPoint&, HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
 
diff --git a/Source/core/page/Frame.cpp b/Source/core/page/Frame.cpp
index 1645d7c..98930c8 100644
--- a/Source/core/page/Frame.cpp
+++ b/Source/core/page/Frame.cpp
@@ -452,7 +452,7 @@
     return 0;
 }
 
-void Frame::createView(const IntSize& viewportSize, const Color& backgroundColor, bool transparent,
+void Frame::createView(const IntSize& viewportSize, const StyleColor& backgroundColor, bool transparent,
     const IntSize& fixedLayoutSize, bool useFixedLayout, ScrollbarMode horizontalScrollbarMode, bool horizontalLock,
     ScrollbarMode verticalScrollbarMode, bool verticalLock)
 {
@@ -479,7 +479,7 @@
     setView(frameView);
 
     if (backgroundColor.isValid())
-        frameView->updateBackgroundRecursively(backgroundColor, transparent);
+        frameView->updateBackgroundRecursively(backgroundColor.color(), transparent);
 
     if (isMainFrame)
         frameView->setParentVisible(true);
diff --git a/Source/core/page/Frame.h b/Source/core/page/Frame.h
index ca10068..7e90ab9 100644
--- a/Source/core/page/Frame.h
+++ b/Source/core/page/Frame.h
@@ -28,6 +28,7 @@
 #ifndef Frame_h
 #define Frame_h
 
+#include "core/css/StyleColor.h"
 #include "core/loader/FrameLoader.h"
 #include "core/loader/NavigationScheduler.h"
 #include "core/page/AdjustViewSizeOrNot.h"
@@ -69,7 +70,7 @@
 
         void init();
         void setView(PassRefPtr<FrameView>);
-        void createView(const IntSize&, const Color&, bool,
+        void createView(const IntSize&, const StyleColor&, bool,
             const IntSize& fixedLayoutSize = IntSize(), bool useFixedLayout = false, ScrollbarMode = ScrollbarAuto, bool horizontalLock = false,
             ScrollbarMode = ScrollbarAuto, bool verticalLock = false);
 
diff --git a/Source/core/page/FrameView.cpp b/Source/core/page/FrameView.cpp
index 26badff..69aa73e 100644
--- a/Source/core/page/FrameView.cpp
+++ b/Source/core/page/FrameView.cpp
@@ -373,13 +373,13 @@
     ScrollbarOverlayStyle oldOverlayStyle = scrollbarOverlayStyle();
     ScrollbarOverlayStyle overlayStyle = ScrollbarOverlayStyleDefault;
 
-    Color backgroundColor = documentBackgroundColor();
+    StyleColor backgroundColor = documentBackgroundColor();
     if (backgroundColor.isValid()) {
         // Reduce the background color from RGB to a lightness value
         // and determine which scrollbar style to use based on a lightness
         // heuristic.
         double hue, saturation, lightness;
-        backgroundColor.getHSL(hue, saturation, lightness);
+        backgroundColor.color().getHSL(hue, saturation, lightness);
         if (lightness <= .5)
             overlayStyle = ScrollbarOverlayStyleLight;
     }
@@ -2034,19 +2034,19 @@
     return m_baseBackgroundColor;
 }
 
-void FrameView::setBaseBackgroundColor(const Color& backgroundColor)
+void FrameView::setBaseBackgroundColor(const StyleColor& backgroundColor)
 {
     if (!backgroundColor.isValid())
         m_baseBackgroundColor = Color::white;
     else
-        m_baseBackgroundColor = backgroundColor;
+        m_baseBackgroundColor = backgroundColor.color();
 
     if (renderView() && renderView()->layer()->backing())
         renderView()->layer()->backing()->updateContentsOpaque();
     recalculateScrollbarOverlayStyle();
 }
 
-void FrameView::updateBackgroundRecursively(const Color& backgroundColor, bool transparent)
+void FrameView::updateBackgroundRecursively(const StyleColor& backgroundColor, bool transparent)
 {
     for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext(m_frame.get())) {
         if (FrameView* view = frame->view()) {
@@ -2734,7 +2734,7 @@
     ScrollView::paintScrollbar(context, bar, rect);
 }
 
-Color FrameView::documentBackgroundColor() const
+StyleColor FrameView::documentBackgroundColor() const
 {
     // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background color of
     // the document and the body against the base background color of the frame view.
@@ -2748,21 +2748,21 @@
     Element* bodyElement = frame()->document()->body();
 
     // Start with invalid colors.
-    Color htmlBackgroundColor;
-    Color bodyBackgroundColor;
+    StyleColor htmlBackgroundColor;
+    StyleColor bodyBackgroundColor;
     if (htmlElement && htmlElement->renderer())
-        htmlBackgroundColor = htmlElement->renderer()->style()->visitedDependentColor(CSSPropertyBackgroundColor);
+        htmlBackgroundColor = htmlElement->renderer()->resolveStyleColor(CSSPropertyBackgroundColor);
     if (bodyElement && bodyElement->renderer())
-        bodyBackgroundColor = bodyElement->renderer()->style()->visitedDependentColor(CSSPropertyBackgroundColor);
+        bodyBackgroundColor = bodyElement->renderer()->resolveStyleColor(CSSPropertyBackgroundColor);
 
     if (!bodyBackgroundColor.isValid()) {
         if (!htmlBackgroundColor.isValid())
-            return Color();
-        return baseBackgroundColor().blend(htmlBackgroundColor);
+            return StyleColor();
+        return baseBackgroundColor().blend(htmlBackgroundColor.color());
     }
 
     if (!htmlBackgroundColor.isValid())
-        return baseBackgroundColor().blend(bodyBackgroundColor);
+        return baseBackgroundColor().blend(bodyBackgroundColor.color());
 
     // We take the aggregate of the base background color
     // the <html> background color, and the <body>
@@ -2771,7 +2771,7 @@
     // technically part of the document background, but it
     // otherwise poses problems when the aggregate is not
     // fully opaque.
-    return baseBackgroundColor().blend(htmlBackgroundColor).blend(bodyBackgroundColor);
+    return baseBackgroundColor().blend(htmlBackgroundColor.color()).blend(bodyBackgroundColor.color());
 }
 
 bool FrameView::hasCustomScrollbars() const
diff --git a/Source/core/page/FrameView.h b/Source/core/page/FrameView.h
index fad036e..ff021cf 100644
--- a/Source/core/page/FrameView.h
+++ b/Source/core/page/FrameView.h
@@ -141,8 +141,8 @@
     bool hasOpaqueBackground() const;
 
     Color baseBackgroundColor() const;
-    void setBaseBackgroundColor(const Color&);
-    void updateBackgroundRecursively(const Color&, bool);
+    void setBaseBackgroundColor(const StyleColor&);
+    void updateBackgroundRecursively(const StyleColor&, bool);
 
     bool shouldUpdateWhileOffscreen() const;
     void setShouldUpdateWhileOffscreen(bool);
@@ -233,7 +233,7 @@
     virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect);
     virtual void paintScrollbar(GraphicsContext*, Scrollbar*, const IntRect&) OVERRIDE;
 
-    Color documentBackgroundColor() const;
+    StyleColor documentBackgroundColor() const;
 
     static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting
 
diff --git a/Source/core/page/ImageBitmap.idl b/Source/core/page/ImageBitmap.idl
index 40c4f3a..b7eec85 100644
--- a/Source/core/page/ImageBitmap.idl
+++ b/Source/core/page/ImageBitmap.idl
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 [
-    NoInterfaceObject
 ] interface ImageBitmap {
-
+    readonly attribute long width;
+    readonly attribute long height;
 };
\ No newline at end of file
diff --git a/Source/core/page/Page.cpp b/Source/core/page/Page.cpp
index bf99a97..021f2f0 100644
--- a/Source/core/page/Page.cpp
+++ b/Source/core/page/Page.cpp
@@ -333,7 +333,7 @@
     HashSet<Page*>::iterator end = allPages->end();
     for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it)
         for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext())
-            frame->document()->scheduleForcedStyleRecalc();
+            frame->document()->setNeedsStyleRecalc();
 }
 
 void Page::setNeedsRecalcStyleInAllFrames()
@@ -734,6 +734,11 @@
         (*it)->multisamplingChanged(m_settings->openGLMultisamplingEnabled());
 }
 
+void Page::didCommitLoad(Frame* frame)
+{
+    lifecycleNotifier()->notifyDidCommitLoad(frame);
+}
+
 PageLifecycleNotifier* Page::lifecycleNotifier()
 {
     return static_cast<PageLifecycleNotifier*>(LifecycleContext::lifecycleNotifier());
diff --git a/Source/core/page/Page.h b/Source/core/page/Page.h
index 0e986a9..6d5af3b 100644
--- a/Source/core/page/Page.h
+++ b/Source/core/page/Page.h
@@ -255,6 +255,8 @@
     void removeMultisamplingChangedObserver(MultisamplingChangedObserver*);
     void multisamplingChanged();
 
+    void didCommitLoad(Frame*);
+
 protected:
     PageLifecycleNotifier* lifecycleNotifier();
 
diff --git a/Source/core/page/PageLifecycleNotifier.h b/Source/core/page/PageLifecycleNotifier.h
index 0927605..f57128c 100644
--- a/Source/core/page/PageLifecycleNotifier.h
+++ b/Source/core/page/PageLifecycleNotifier.h
@@ -34,12 +34,14 @@
 namespace WebCore {
 
 class Page;
+class Frame;
 
 class PageLifecycleNotifier : public LifecycleNotifier {
 public:
     static PassOwnPtr<PageLifecycleNotifier> create(LifecycleContext*);
 
     void notifyPageVisibilityChanged();
+    void notifyDidCommitLoad(Frame*);
 
     virtual void addObserver(LifecycleObserver*, LifecycleObserver::Type) OVERRIDE;
     virtual void removeObserver(LifecycleObserver*, LifecycleObserver::Type) OVERRIDE;
@@ -63,6 +65,13 @@
         (*it)->pageVisibilityChanged();
 }
 
+inline void PageLifecycleNotifier::notifyDidCommitLoad(Frame* frame)
+{
+    TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverPageObservers);
+    for (PageObserverSet::iterator it = m_pageObservers.begin(); it != m_pageObservers.end(); ++it)
+        (*it)->didCommitLoad(frame);
+}
+
 } // namespace WebCore
 
 #endif // PageLifecycleNotifier_h
diff --git a/Source/core/page/PageLifecycleObserver.h b/Source/core/page/PageLifecycleObserver.h
index 7af0422..6262695 100644
--- a/Source/core/page/PageLifecycleObserver.h
+++ b/Source/core/page/PageLifecycleObserver.h
@@ -31,6 +31,7 @@
 
 namespace WebCore {
 
+class Frame;
 class Page;
 
 class PageLifecycleObserver : public LifecycleObserver {
@@ -41,6 +42,7 @@
     Page* page() const;
 
     virtual void pageVisibilityChanged() { }
+    virtual void didCommitLoad(Frame*) { }
 };
 
 } // namespace WebCore
diff --git a/Source/core/page/PageSerializer.cpp b/Source/core/page/PageSerializer.cpp
index 407a1b5..54e5776 100644
--- a/Source/core/page/PageSerializer.cpp
+++ b/Source/core/page/PageSerializer.cpp
@@ -280,7 +280,7 @@
 
 void PageSerializer::addImageToResources(CachedImage* image, RenderObject* imageRenderer, const KURL& url)
 {
-    if (!url.isValid() || m_resourceURLs.contains(url))
+    if (!url.isValid() || m_resourceURLs.contains(url) || url.protocolIsData())
         return;
 
     if (!image || image->image() == Image::nullImage())
diff --git a/Source/core/page/Performance.cpp b/Source/core/page/Performance.cpp
index 4f346ab..7a934be 100644
--- a/Source/core/page/Performance.cpp
+++ b/Source/core/page/Performance.cpp
@@ -40,6 +40,8 @@
 #include "core/page/PerformanceResourceTiming.h"
 #include "core/page/PerformanceTiming.h"
 #include "core/page/PerformanceUserTiming.h"
+#include "core/page/ResourceTimingInfo.h"
+#include "weborigin/SecurityOrigin.h"
 #include "wtf/CurrentTime.h"
 
 #include "core/page/Frame.h"
@@ -159,13 +161,79 @@
         dispatchEvent(Event::create(eventNames().webkitresourcetimingbufferfullEvent, false, false));
 }
 
-void Performance::addResourceTiming(const String& initiatorName, Document* initiatorDocument, const ResourceRequest& request, const ResourceResponse& response, double initiationTime, double finishTime)
+static bool passesTimingAllowCheck(const ResourceResponse& response, Document* requestingDocument)
+{
+    AtomicallyInitializedStatic(AtomicString&, timingAllowOrigin = *new AtomicString("timing-allow-origin"));
+
+    RefPtr<SecurityOrigin> resourceOrigin = SecurityOrigin::create(response.url());
+    if (resourceOrigin->isSameSchemeHostPort(requestingDocument->securityOrigin()))
+        return true;
+
+    const String& timingAllowOriginString = response.httpHeaderField(timingAllowOrigin);
+    if (timingAllowOriginString.isEmpty() || equalIgnoringCase(timingAllowOriginString, "null"))
+        return false;
+
+    if (timingAllowOriginString == "*")
+        return true;
+
+    const String& securityOrigin = requestingDocument->securityOrigin()->toString();
+    Vector<String> timingAllowOrigins;
+    timingAllowOriginString.split(" ", timingAllowOrigins);
+    for (size_t i = 0; i < timingAllowOrigins.size(); ++i) {
+        if (timingAllowOrigins[i] == securityOrigin)
+            return true;
+    }
+
+    return false;
+}
+
+static bool allowsTimingRedirect(const Vector<ResourceResponse>& redirectChain, const ResourceResponse& finalResponse, Document* initiatorDocument)
+{
+    if (!passesTimingAllowCheck(finalResponse, initiatorDocument))
+        return false;
+
+    for (size_t i = 0; i < redirectChain.size(); i++) {
+        if (!passesTimingAllowCheck(redirectChain[i], initiatorDocument))
+            return false;
+    }
+
+    return true;
+}
+
+void Performance::addResourceTiming(const ResourceTimingInfo& info, Document* initiatorDocument)
 {
     if (isResourceTimingBufferFull())
         return;
 
-    RefPtr<PerformanceEntry> entry = PerformanceResourceTiming::create(initiatorName, request, response, initiationTime, finishTime, initiatorDocument);
+    const ResourceResponse& finalResponse = info.finalResponse();
+    bool allowTimingDetails = passesTimingAllowCheck(finalResponse, initiatorDocument);
+    double startTime = info.initialTime();
 
+    if (info.redirectChain().isEmpty()) {
+        RefPtr<PerformanceEntry> entry = PerformanceResourceTiming::create(info, initiatorDocument, startTime, allowTimingDetails);
+        addResourceTimingBuffer(entry);
+        return;
+    }
+
+    const Vector<ResourceResponse>& redirectChain = info.redirectChain();
+    bool allowRedirectDetails = allowsTimingRedirect(redirectChain, finalResponse, initiatorDocument);
+
+    if (!allowRedirectDetails) {
+        ResourceLoadTiming* finalTiming = finalResponse.resourceLoadTiming();
+        ASSERT(finalTiming);
+        startTime = finalTiming->requestTime;
+    }
+
+    ResourceLoadTiming* lastRedirectTiming = redirectChain.last().resourceLoadTiming();
+    ASSERT(lastRedirectTiming);
+    double lastRedirectEndTime = lastRedirectTiming->receiveHeadersEnd;
+
+    RefPtr<PerformanceEntry> entry = PerformanceResourceTiming::create(info, initiatorDocument, startTime, lastRedirectEndTime, allowTimingDetails, allowRedirectDetails);
+    addResourceTimingBuffer(entry);
+}
+
+void Performance::addResourceTimingBuffer(PassRefPtr<PerformanceEntry> entry)
+{
     m_resourceTimingBuffer.append(entry);
 
     if (isResourceTimingBufferFull())
diff --git a/Source/core/page/Performance.h b/Source/core/page/Performance.h
index 4a6f305..a5ff477 100644
--- a/Source/core/page/Performance.h
+++ b/Source/core/page/Performance.h
@@ -49,6 +49,7 @@
 class Document;
 class ResourceRequest;
 class ResourceResponse;
+class ResourceTimingInfo;
 class UserTiming;
 
 class Performance : public ScriptWrappable, public RefCounted<Performance>, public DOMWindowProperty, public EventTarget {
@@ -73,7 +74,7 @@
 
     DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitresourcetimingbufferfull);
 
-    void addResourceTiming(const String& initiatorName, Document*, const ResourceRequest&, const ResourceResponse&, double initiationTime, double finishTime);
+    void addResourceTiming(const ResourceTimingInfo&, Document*);
 
     using RefCounted<Performance>::ref;
     using RefCounted<Performance>::deref;
@@ -92,6 +93,7 @@
     virtual EventTargetData* eventTargetData();
     virtual EventTargetData* ensureEventTargetData();
     bool isResourceTimingBufferFull();
+    void addResourceTimingBuffer(PassRefPtr<PerformanceEntry>);
 
     EventTargetData m_eventTargetData;
 
diff --git a/Source/core/page/PerformanceResourceTiming.cpp b/Source/core/page/PerformanceResourceTiming.cpp
index 180d380..4f1f7a5 100644
--- a/Source/core/page/PerformanceResourceTiming.cpp
+++ b/Source/core/page/PerformanceResourceTiming.cpp
@@ -35,10 +35,9 @@
 #include "core/dom/Document.h"
 #include "core/loader/DocumentLoadTiming.h"
 #include "core/loader/DocumentLoader.h"
+#include "core/page/ResourceTimingInfo.h"
 #include "core/platform/network/ResourceRequest.h"
 #include "core/platform/network/ResourceResponse.h"
-#include "weborigin/SecurityOrigin.h"
-#include "wtf/Vector.h"
 
 namespace WebCore {
 
@@ -48,38 +47,15 @@
     return document->loader()->timing()->monotonicTimeToZeroBasedDocumentTime(seconds) * 1000.0;
 }
 
-static bool passesTimingAllowCheck(const ResourceResponse& response, Document* requestingDocument)
-{
-    AtomicallyInitializedStatic(AtomicString&, timingAllowOrigin = *new AtomicString("timing-allow-origin"));
-
-    RefPtr<SecurityOrigin> resourceOrigin = SecurityOrigin::create(response.url());
-    if (resourceOrigin->isSameSchemeHostPort(requestingDocument->securityOrigin()))
-        return true;
-
-    const String& timingAllowOriginString = response.httpHeaderField(timingAllowOrigin);
-    if (timingAllowOriginString.isEmpty() || equalIgnoringCase(timingAllowOriginString, "null"))
-        return false;
-
-    if (timingAllowOriginString == "*")
-        return true;
-
-    const String& securityOrigin = requestingDocument->securityOrigin()->toString();
-    Vector<String> timingAllowOrigins;
-    timingAllowOriginString.split(" ", timingAllowOrigins);
-    for (size_t i = 0; i < timingAllowOrigins.size(); ++i)
-        if (timingAllowOrigins[i] == securityOrigin)
-            return true;
-
-    return false;
-}
-
-PerformanceResourceTiming::PerformanceResourceTiming(const AtomicString& initiatorType, const ResourceRequest& request, const ResourceResponse& response, double initiationTime, double finishTime, Document* requestingDocument)
-    : PerformanceEntry(request.url().string(), "resource", monotonicTimeToDocumentMilliseconds(requestingDocument, initiationTime), monotonicTimeToDocumentMilliseconds(requestingDocument, finishTime))
-    , m_initiatorType(initiatorType)
-    , m_timing(response.resourceLoadTiming())
-    , m_finishTime(finishTime)
-    , m_didReuseConnection(response.connectionReused())
-    , m_shouldReportDetails(passesTimingAllowCheck(response, requestingDocument))
+PerformanceResourceTiming::PerformanceResourceTiming(const ResourceTimingInfo& info, Document* requestingDocument, double startTime, double lastRedirectEndTime, bool allowTimingDetails, bool allowRedirectDetails)
+    : PerformanceEntry(info.initialRequest().url().string(), "resource", monotonicTimeToDocumentMilliseconds(requestingDocument, startTime), monotonicTimeToDocumentMilliseconds(requestingDocument, info.loadFinishTime()))
+    , m_initiatorType(info.initiatorType())
+    , m_timing(info.finalResponse().resourceLoadTiming())
+    , m_lastRedirectEndTime(lastRedirectEndTime)
+    , m_finishTime(info.loadFinishTime())
+    , m_didReuseConnection(info.finalResponse().connectionReused())
+    , m_allowTimingDetails(allowTimingDetails)
+    , m_allowRedirectDetails(allowRedirectDetails)
     , m_requestingDocument(requestingDocument)
 {
     ScriptWrappable::init(this);
@@ -96,28 +72,35 @@
 
 double PerformanceResourceTiming::redirectStart() const
 {
-    // FIXME: Need to track and report redirects for resources.
-    if (!m_shouldReportDetails)
+    if (!m_lastRedirectEndTime || !m_allowRedirectDetails)
         return 0.0;
-    return 0;
+
+    return PerformanceEntry::startTime();
 }
 
 double PerformanceResourceTiming::redirectEnd() const
 {
-    if (!m_shouldReportDetails)
+    if (!m_lastRedirectEndTime || !m_allowRedirectDetails)
         return 0.0;
-    return 0;
+
+    return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_lastRedirectEndTime);
 }
 
 double PerformanceResourceTiming::fetchStart() const
 {
-    // FIXME: This should be different depending on redirects.
-    return (startTime());
+    if (m_lastRedirectEndTime) {
+        // FIXME: ASSERT(m_timing) should be in constructor once timeticks of
+        // AppCache is exposed from chrome network stack, crbug/251100
+        ASSERT(m_timing);
+        return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_timing->requestTime);
+    }
+
+    return PerformanceEntry::startTime();
 }
 
 double PerformanceResourceTiming::domainLookupStart() const
 {
-    if (!m_shouldReportDetails)
+    if (!m_allowTimingDetails)
         return 0.0;
 
     if (!m_timing || m_timing->dnsStart == 0.0)
@@ -128,7 +111,7 @@
 
 double PerformanceResourceTiming::domainLookupEnd() const
 {
-    if (!m_shouldReportDetails)
+    if (!m_allowTimingDetails)
         return 0.0;
 
     if (!m_timing || m_timing->dnsEnd == 0.0)
@@ -139,7 +122,7 @@
 
 double PerformanceResourceTiming::connectStart() const
 {
-    if (!m_shouldReportDetails)
+    if (!m_allowTimingDetails)
         return 0.0;
 
     // connectStart will be zero when a network request is not made.
@@ -156,7 +139,7 @@
 
 double PerformanceResourceTiming::connectEnd() const
 {
-    if (!m_shouldReportDetails)
+    if (!m_allowTimingDetails)
         return 0.0;
 
     // connectStart will be zero when a network request is not made.
@@ -168,7 +151,7 @@
 
 double PerformanceResourceTiming::secureConnectionStart() const
 {
-    if (!m_shouldReportDetails)
+    if (!m_allowTimingDetails)
         return 0.0;
 
     if (!m_timing || m_timing->sslStart == 0.0) // Secure connection not negotiated.
@@ -179,7 +162,7 @@
 
 double PerformanceResourceTiming::requestStart() const
 {
-    if (!m_shouldReportDetails)
+    if (!m_allowTimingDetails)
         return 0.0;
 
     if (!m_timing)
@@ -190,7 +173,7 @@
 
 double PerformanceResourceTiming::responseStart() const
 {
-    if (!m_shouldReportDetails)
+    if (!m_allowTimingDetails)
         return 0.0;
 
     if (!m_timing)
diff --git a/Source/core/page/PerformanceResourceTiming.h b/Source/core/page/PerformanceResourceTiming.h
index 9f05fbe..5ea27ea 100644
--- a/Source/core/page/PerformanceResourceTiming.h
+++ b/Source/core/page/PerformanceResourceTiming.h
@@ -43,12 +43,18 @@
 class ResourceLoadTiming;
 class ResourceRequest;
 class ResourceResponse;
+class ResourceTimingInfo;
 
 class PerformanceResourceTiming : public PerformanceEntry {
 public:
-    static PassRefPtr<PerformanceResourceTiming> create(const AtomicString& initiatorType, const ResourceRequest& request, const ResourceResponse& response, double initiationTime, double finishTime, Document* requestingDocument)
+    static PassRefPtr<PerformanceResourceTiming> create(const ResourceTimingInfo& info, Document* requestingDocument, double startTime, double lastRedirectEndTime, bool m_allowTimingDetails, bool m_allowRedirectDetails)
     {
-        return adoptRef(new PerformanceResourceTiming(initiatorType, request, response, initiationTime, finishTime, requestingDocument));
+        return adoptRef(new PerformanceResourceTiming(info, requestingDocument, startTime, lastRedirectEndTime, m_allowTimingDetails, m_allowRedirectDetails));
+    }
+
+    static PassRefPtr<PerformanceResourceTiming> create(const ResourceTimingInfo& info, Document* requestingDocument, double startTime, bool m_allowTimingDetails)
+    {
+        return adoptRef(new PerformanceResourceTiming(info, requestingDocument, startTime, 0.0, m_allowTimingDetails, false));
     }
 
     AtomicString initiatorType() const;
@@ -68,14 +74,16 @@
     virtual bool isResource() { return true; }
 
 private:
-    PerformanceResourceTiming(const AtomicString& initatorType, const ResourceRequest&, const ResourceResponse&, double initiationTime, double finishTime, Document*);
+    PerformanceResourceTiming(const ResourceTimingInfo&, Document* requestingDocument, double startTime, double lastRedirectEndTime, bool m_allowTimingDetails, bool m_allowRedirectDetails);
     ~PerformanceResourceTiming();
 
     AtomicString m_initiatorType;
     RefPtr<ResourceLoadTiming> m_timing;
+    double m_lastRedirectEndTime;
     double m_finishTime;
     bool m_didReuseConnection;
-    bool m_shouldReportDetails;
+    bool m_allowTimingDetails;
+    bool m_allowRedirectDetails;
     RefPtr<Document> m_requestingDocument;
 };
 
diff --git a/Source/core/page/ResourceTimingInfo.h b/Source/core/page/ResourceTimingInfo.h
new file mode 100644
index 0000000..8679bdf
--- /dev/null
+++ b/Source/core/page/ResourceTimingInfo.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2013 Intel 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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.
+ */
+
+#ifndef ResourceTimingInfo_h
+#define ResourceTimingInfo_h
+
+#include "core/platform/network/ResourceRequest.h"
+#include "core/platform/network/ResourceResponse.h"
+#include "wtf/text/AtomicString.h"
+
+namespace WebCore {
+
+class ResourceTimingInfo : public RefCounted<ResourceTimingInfo> {
+public:
+    static PassRefPtr<ResourceTimingInfo> create(const AtomicString& type, const double time)
+    {
+        return adoptRef(new ResourceTimingInfo(type, time));
+    }
+
+    double initialTime() const { return m_initialTime; }
+
+    void setInitiatorType(const AtomicString& type) { m_type = type; }
+    const AtomicString& initiatorType() const { return m_type; }
+
+    void setLoadFinishTime(double time) { m_loadFinishTime = time; }
+    double loadFinishTime() const { return m_loadFinishTime; }
+
+    void setInitialRequest(const ResourceRequest& request) { m_initialRequest = request; }
+    const ResourceRequest& initialRequest() const { return m_initialRequest; }
+
+    void setFinalResponse(const ResourceResponse& response) { m_finalResponse = response; }
+    const ResourceResponse& finalResponse() const { return m_finalResponse; }
+
+    void addRedirect(const ResourceResponse& redirectResponse) { m_redirectChain.append(redirectResponse); }
+    const Vector<ResourceResponse>& redirectChain() const { return m_redirectChain; }
+
+private:
+    ResourceTimingInfo(const AtomicString& type, const double time)
+        : m_type(type)
+        , m_initialTime(time)
+    {
+    }
+
+    AtomicString m_type;
+    double m_initialTime;
+    double m_loadFinishTime;
+    ResourceRequest m_initialRequest;
+    ResourceResponse m_finalResponse;
+    Vector<ResourceResponse> m_redirectChain;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/core/page/RuntimeEnabledFeatures.in b/Source/core/page/RuntimeEnabledFeatures.in
index 884debe..b5d0d09 100644
--- a/Source/core/page/RuntimeEnabledFeatures.in
+++ b/Source/core/page/RuntimeEnabledFeatures.in
@@ -62,6 +62,7 @@
 Notifications status=stable
 PagePopup status=stable
 ParseSVGAsHTML
+PathOpsSVGClipping
 PeerConnection depends_on=MediaStream, status=stable
 ProgrammaticScrollNotifications status=test
 Promise status=experimental
diff --git a/Source/core/page/animation/CSSPropertyAnimation.cpp b/Source/core/page/animation/CSSPropertyAnimation.cpp
index 9eba320..97a3dbd 100644
--- a/Source/core/page/animation/CSSPropertyAnimation.cpp
+++ b/Source/core/page/animation/CSSPropertyAnimation.cpp
@@ -68,9 +68,11 @@
     return narrowPrecisionToFloat(from + (to - from) * progress);
 }
 
-static inline Color blendFunc(const AnimationBase*, const Color& from, const Color& to, double progress)
+static inline Color blendFunc(const AnimationBase* animation, const StyleColor& from, const StyleColor& to, double progress)
 {
-    return blend(from, to, progress);
+    Color fromColor = animation->renderer()->resolveColor(from);
+    Color toColor = animation->renderer()->resolveColor(to);
+    return blend(fromColor, toColor, progress);
 }
 
 static inline Length blendFunc(const AnimationBase*, const Length& from, const Length& to, double progress)
@@ -107,11 +109,14 @@
     if (from->style() != to->style())
         return to->clone();
 
+    Color fromColor = anim->renderer()->resolveColor(from->color());
+    Color toColor = anim->renderer()->resolveColor(to->color());
+
     return ShadowData::create(blend(from->location(), to->location(), progress),
         blend(from->blur(), to->blur(), progress),
         blend(from->spread(), to->spread(), progress),
         blendFunc(anim, from->style(), to->style(), progress),
-        blend(from->color(), to->color(), progress));
+        blend(fromColor, toColor, progress));
 }
 
 static inline TransformOperations blendFunc(const AnimationBase* anim, const TransformOperations& from, const TransformOperations& to, double progress)
@@ -426,21 +431,21 @@
     }
 };
 
-class PropertyWrapperColor : public PropertyWrapperGetter<Color> {
+class PropertyWrapperColor : public PropertyWrapperGetter<StyleColor> {
 public:
-    PropertyWrapperColor(CSSPropertyID prop, Color (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&))
-        : PropertyWrapperGetter<Color>(prop, getter)
+    PropertyWrapperColor(CSSPropertyID prop, StyleColor (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const StyleColor&))
+        : PropertyWrapperGetter<StyleColor>(prop, getter)
         , m_setter(setter)
     {
     }
 
     virtual void blend(const AnimationBase* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
     {
-        (dst->*m_setter)(blendFunc(anim, (a->*PropertyWrapperGetter<Color>::m_getter)(), (b->*PropertyWrapperGetter<Color>::m_getter)(), progress));
+        (dst->*m_setter)(blendFunc(anim, (a->*PropertyWrapperGetter<StyleColor>::m_getter)(), (b->*PropertyWrapperGetter<StyleColor>::m_getter)(), progress));
     }
 
 protected:
-    void (RenderStyle::*m_setter)(const Color&);
+    void (RenderStyle::*m_setter)(const StyleColor&);
 };
 
 class PropertyWrapperAcceleratedOpacity : public PropertyWrapper<float> {
@@ -630,7 +635,7 @@
 
 class PropertyWrapperMaybeInvalidColor : public AnimationPropertyWrapperBase {
 public:
-    PropertyWrapperMaybeInvalidColor(CSSPropertyID prop, Color (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&))
+    PropertyWrapperMaybeInvalidColor(CSSPropertyID prop, StyleColor (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const StyleColor&))
         : AnimationPropertyWrapperBase(prop)
         , m_getter(getter)
         , m_setter(setter)
@@ -639,8 +644,8 @@
 
     virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
     {
-        Color fromColor = (a->*m_getter)();
-        Color toColor = (b->*m_getter)();
+        StyleColor fromColor = (a->*m_getter)();
+        StyleColor toColor = (b->*m_getter)();
 
         if (!fromColor.isValid() && !toColor.isValid())
             return true;
@@ -655,8 +660,8 @@
 
     virtual void blend(const AnimationBase* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
     {
-        Color fromColor = (a->*m_getter)();
-        Color toColor = (b->*m_getter)();
+        StyleColor fromColor = (a->*m_getter)();
+        StyleColor toColor = (b->*m_getter)();
 
         if (!fromColor.isValid() && !toColor.isValid())
             return;
@@ -669,23 +674,23 @@
     }
 
 private:
-    Color (RenderStyle::*m_getter)() const;
-    void (RenderStyle::*m_setter)(const Color&);
+    StyleColor (RenderStyle::*m_getter)() const;
+    void (RenderStyle::*m_setter)(const StyleColor&);
 };
 
 
 enum MaybeInvalidColorTag { MaybeInvalidColor };
 class PropertyWrapperVisitedAffectedColor : public AnimationPropertyWrapperBase {
 public:
-    PropertyWrapperVisitedAffectedColor(CSSPropertyID prop, Color (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&),
-                                        Color (RenderStyle::*visitedGetter)() const, void (RenderStyle::*visitedSetter)(const Color&))
+    PropertyWrapperVisitedAffectedColor(CSSPropertyID prop, StyleColor (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const StyleColor&),
+        StyleColor (RenderStyle::*visitedGetter)() const, void (RenderStyle::*visitedSetter)(const StyleColor&))
         : AnimationPropertyWrapperBase(prop)
         , m_wrapper(adoptPtr(new PropertyWrapperColor(prop, getter, setter)))
         , m_visitedWrapper(adoptPtr(new PropertyWrapperColor(prop, visitedGetter, visitedSetter)))
     {
     }
-    PropertyWrapperVisitedAffectedColor(CSSPropertyID prop, MaybeInvalidColorTag, Color (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&),
-                                        Color (RenderStyle::*visitedGetter)() const, void (RenderStyle::*visitedSetter)(const Color&))
+    PropertyWrapperVisitedAffectedColor(CSSPropertyID prop, MaybeInvalidColorTag, StyleColor (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const StyleColor&),
+        StyleColor (RenderStyle::*visitedGetter)() const, void (RenderStyle::*visitedSetter)(const StyleColor&))
         : AnimationPropertyWrapperBase(prop)
         , m_wrapper(adoptPtr(new PropertyWrapperMaybeInvalidColor(prop, getter, setter)))
         , m_visitedWrapper(adoptPtr(new PropertyWrapperMaybeInvalidColor(prop, visitedGetter, visitedSetter)))
@@ -937,7 +942,7 @@
 
 class PropertyWrapperSVGPaint : public AnimationPropertyWrapperBase {
 public:
-    PropertyWrapperSVGPaint(CSSPropertyID prop, const SVGPaint::SVGPaintType& (RenderStyle::*paintTypeGetter)() const, Color (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&))
+    PropertyWrapperSVGPaint(CSSPropertyID prop, const SVGPaint::SVGPaintType& (RenderStyle::*paintTypeGetter)() const, StyleColor (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const StyleColor&))
         : AnimationPropertyWrapperBase(prop)
         , m_paintTypeGetter(paintTypeGetter)
         , m_getter(getter)
@@ -950,20 +955,20 @@
         if ((a->*m_paintTypeGetter)() != (b->*m_paintTypeGetter)())
             return false;
 
-        // We only support animations between SVGPaints that are pure Color values.
+        // We only support animations between SVGPaints that are pure StyleColor values.
         // For everything else we must return true for this method, otherwise
         // we will try to animate between values forever.
         if ((a->*m_paintTypeGetter)() == SVGPaint::SVG_PAINTTYPE_RGBCOLOR) {
-            Color fromColor = (a->*m_getter)();
-            Color toColor = (b->*m_getter)();
+            StyleColor fromColor = (a->*m_getter)();
+            StyleColor toColor = (b->*m_getter)();
 
             if (!fromColor.isValid() && !toColor.isValid())
                 return true;
 
             if (!fromColor.isValid())
-                fromColor = Color();
+                fromColor = StyleColor();
             if (!toColor.isValid())
-                toColor = Color();
+                toColor = StyleColor();
 
             return fromColor == toColor;
         }
@@ -976,23 +981,23 @@
             || (b->*m_paintTypeGetter)() != SVGPaint::SVG_PAINTTYPE_RGBCOLOR)
             return;
 
-        Color fromColor = (a->*m_getter)();
-        Color toColor = (b->*m_getter)();
+        StyleColor fromColor = (a->*m_getter)();
+        StyleColor toColor = (b->*m_getter)();
 
         if (!fromColor.isValid() && !toColor.isValid())
             return;
 
         if (!fromColor.isValid())
-            fromColor = Color();
+            fromColor = StyleColor();
         if (!toColor.isValid())
-            toColor = Color();
+            toColor = StyleColor();
         (dst->*m_setter)(blendFunc(anim, fromColor, toColor, progress));
     }
 
 private:
     const SVGPaint::SVGPaintType& (RenderStyle::*m_paintTypeGetter)() const;
-    Color (RenderStyle::*m_getter)() const;
-    void (RenderStyle::*m_setter)(const Color&);
+    StyleColor (RenderStyle::*m_getter)() const;
+    void (RenderStyle::*m_setter)(const StyleColor&);
 };
 
 static void addShorthandProperties()
diff --git a/Source/core/page/animation/CompositeAnimation.cpp b/Source/core/page/animation/CompositeAnimation.cpp
index 4616348..29898bb 100644
--- a/Source/core/page/animation/CompositeAnimation.cpp
+++ b/Source/core/page/animation/CompositeAnimation.cpp
@@ -211,23 +211,21 @@
             it->value->setIndex(-1);
             
         // Toss the animation order map.
-        m_keyframeAnimationOrderMap.clear();
+        m_keyframeAnimationOrderList.clear();
 
         DEFINE_STATIC_LOCAL(const AtomicString, none, ("none", AtomicString::ConstructFromLiteral));
-        
+
         // Now mark any still active animations as active and add any new animations.
         if (targetStyle->animations()) {
             int numAnims = targetStyle->animations()->size();
             for (int i = 0; i < numAnims; ++i) {
                 const CSSAnimationData* anim = targetStyle->animations()->animation(i);
-                AtomicString animationName(anim->name());
-
                 if (!anim->isValidAnimation())
                     continue;
                 
                 // See if there is a current animation for this name.
-                RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(animationName.impl());
-                
+                AtomicString name(anim->name());
+                RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(name);
                 if (keyframeAnim) {
                     // If this animation is postActive, skip it so it gets removed at the end of this function.
                     if (keyframeAnim->postActive())
@@ -241,33 +239,44 @@
                     // Set the saved animation to this new one, just in case the play state has changed.
                     keyframeAnim->setAnimation(anim);
                     keyframeAnim->setIndex(i);
-                } else if ((anim->duration() || anim->delay()) && anim->iterationCount() && animationName != none) {
+                } else if ((anim->duration() || anim->delay()) && anim->iterationCount() && name != none) {
                     keyframeAnim = KeyframeAnimation::create(const_cast<CSSAnimationData*>(anim), renderer, i, this, targetStyle);
-                    m_keyframeAnimations.set(keyframeAnim->name().impl(), keyframeAnim);
+                    m_keyframeAnimations.set(name, keyframeAnim);
                 }
                 
                 // Add this to the animation order map.
                 if (keyframeAnim)
-                    m_keyframeAnimationOrderMap.append(keyframeAnim->name().impl());
+                    m_keyframeAnimationOrderList.append(name);
             }
         }
     }
-    
+
     // Make a list of animations to be removed.
-    Vector<AtomicStringImpl*> animsToBeRemoved;
+    Vector<AtomicString> animsToBeRemoved;
     kfend = m_keyframeAnimations.end();
     for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) {
         KeyframeAnimation* keyframeAnim = it->value.get();
         if (keyframeAnim->index() < 0) {
-            animsToBeRemoved.append(keyframeAnim->name().impl());
+            animsToBeRemoved.append(keyframeAnim->name());
             animationController()->animationWillBeRemoved(keyframeAnim);
             keyframeAnim->clear();
         }
     }
     
-    // Now remove the animations from the list.
-    for (size_t j = 0; j < animsToBeRemoved.size(); ++j)
-        m_keyframeAnimations.remove(animsToBeRemoved[j]);
+    // Now remove the animations from the list, and keep stale keys out of the order list.
+    if (animsToBeRemoved.size()) {
+        for (size_t j = 0; j < animsToBeRemoved.size(); ++j) {
+            ASSERT(m_keyframeAnimations.contains(animsToBeRemoved[j]));
+            m_keyframeAnimations.remove(animsToBeRemoved[j]);
+        }
+        Vector<AtomicString> newOrderList;
+        for (size_t j = 0; j < m_keyframeAnimationOrderList.size(); ++j) {
+            AtomicString key = m_keyframeAnimationOrderList[j];
+            if (m_keyframeAnimations.contains(key))
+                newOrderList.append(key);
+        }
+        m_keyframeAnimationOrderList.swap(newOrderList);
+    }
 }
 
 PassRefPtr<RenderStyle> CompositeAnimation::animate(RenderObject* renderer, RenderStyle* currentStyle, RenderStyle* targetStyle)
@@ -293,10 +302,10 @@
 
     // Now that we have animation objects ready, let them know about the new goal state.  We want them
     // to fill in a RenderStyle*& only if needed.
-    for (Vector<AtomicStringImpl*>::const_iterator it = m_keyframeAnimationOrderMap.begin(); it != m_keyframeAnimationOrderMap.end(); ++it) {
+    for (Vector<AtomicString>::const_iterator it = m_keyframeAnimationOrderList.begin(); it != m_keyframeAnimationOrderList.end(); ++it) {
         RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(*it);
-        if (keyframeAnim)
-            keyframeAnim->animate(this, renderer, currentStyle, targetStyle, resultStyle);
+        ASSERT(keyframeAnim);
+        keyframeAnim->animate(this, renderer, currentStyle, targetStyle, resultStyle);
     }
 
     return resultStyle ? resultStyle.release() : targetStyle;
@@ -313,10 +322,10 @@
 
     m_keyframeAnimations.checkConsistency();
 
-    for (Vector<AtomicStringImpl*>::const_iterator it = m_keyframeAnimationOrderMap.begin(); it != m_keyframeAnimationOrderMap.end(); ++it) {
+    for (Vector<AtomicString>::const_iterator it = m_keyframeAnimationOrderList.begin(); it != m_keyframeAnimationOrderList.end(); ++it) {
         RefPtr<KeyframeAnimation> keyframeAnimation = m_keyframeAnimations.get(*it);
-        if (keyframeAnimation)
-            keyframeAnimation->getAnimatedStyle(resultStyle);
+        ASSERT(keyframeAnimation);
+        keyframeAnimation->getAnimatedStyle(resultStyle);
     }
     
     return resultStyle;
diff --git a/Source/core/page/animation/CompositeAnimation.h b/Source/core/page/animation/CompositeAnimation.h
index 2a6d0de..d2f8da8 100644
--- a/Source/core/page/animation/CompositeAnimation.h
+++ b/Source/core/page/animation/CompositeAnimation.h
@@ -88,12 +88,12 @@
     void updateKeyframeAnimations(RenderObject*, RenderStyle* currentStyle, RenderStyle* targetStyle);
     
     typedef HashMap<int, RefPtr<ImplicitAnimation> > CSSPropertyTransitionsMap;
-    typedef HashMap<AtomicStringImpl*, RefPtr<KeyframeAnimation> >  AnimationNameMap;
+    typedef HashMap<AtomicString, RefPtr<KeyframeAnimation> > AnimationNameMap;
 
     AnimationControllerPrivate* m_animationController;
     CSSPropertyTransitionsMap m_transitions;
     AnimationNameMap m_keyframeAnimations;
-    Vector<AtomicStringImpl*> m_keyframeAnimationOrderMap;
+    Vector<AtomicString> m_keyframeAnimationOrderList;
     bool m_suspended;
 };
 
diff --git a/Source/core/page/scrolling/ScrollingCoordinator.cpp b/Source/core/page/scrolling/ScrollingCoordinator.cpp
index 323298d..4e9bdb9 100644
--- a/Source/core/page/scrolling/ScrollingCoordinator.cpp
+++ b/Source/core/page/scrolling/ScrollingCoordinator.cpp
@@ -115,13 +115,10 @@
 
 void ScrollingCoordinator::frameViewLayoutUpdated(FrameView* frameView)
 {
-    if (!touchHitTestingEnabled())
-        return;
-
     TRACE_EVENT0("input", "ScrollingCoordinator::frameViewLayoutUpdated");
 
-    // Compute the region of the page that we can't handle scroll gestures on impl thread:
-    // This currently includes:
+    // Compute the region of the page where we can't handle scroll gestures and mousewheel events
+    // on the impl thread. This currently includes:
     // 1. All scrollable areas, such as subframes, overflow divs and list boxes, whose composited
     // scrolling are not enabled. We need to do this even if the frame view whose layout was updated
     // is not the main frame.
@@ -130,9 +127,13 @@
     // 3. Plugin areas.
     Region shouldHandleScrollGestureOnMainThreadRegion = computeShouldHandleScrollGestureOnMainThreadRegion(m_page->mainFrame(), IntPoint());
     setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGestureOnMainThreadRegion);
-    LayerHitTestRects touchEventTargetRects;
-    computeTouchEventTargetRects(touchEventTargetRects);
-    setTouchEventTargetRects(touchEventTargetRects);
+
+    if (touchHitTestingEnabled()) {
+        LayerHitTestRects touchEventTargetRects;
+        computeTouchEventTargetRects(touchEventTargetRects);
+        setTouchEventTargetRects(touchEventTargetRects);
+    }
+
     if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(frameView))
         scrollLayer->setBounds(frameView->contentsSize());
 }
@@ -470,7 +471,7 @@
         for (FrameView::ResizerAreaSet::const_iterator it = resizerAreas->begin(), end = resizerAreas->end(); it != end; ++it) {
             RenderLayer* layer = *it;
             IntRect bounds = layer->renderer()->absoluteBoundingBoxRect();
-            IntRect corner = layer->resizerCornerRect(bounds, RenderLayer::ResizerForTouch);
+            IntRect corner = layer->resizerCornerRect(bounds, ResizerForTouch);
             corner.moveBy(offset);
             shouldHandleScrollGestureOnMainThreadRegion.unite(corner);
         }
diff --git a/Source/core/platform/FileIconLoader.cpp b/Source/core/platform/FileIconLoader.cpp
deleted file mode 100644
index 4ce073a..0000000
--- a/Source/core/platform/FileIconLoader.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2011 Google 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. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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/platform/FileIconLoader.h"
-
-#include "core/platform/graphics/Icon.h"
-
-namespace WebCore {
-
-FileIconLoaderClient::~FileIconLoaderClient()
-{
-    discardLoader();
-}
-
-FileIconLoader* FileIconLoaderClient::newFileIconLoader()
-{
-    discardLoader();
-
-    m_loader = FileIconLoader::create(this);
-    return m_loader.get();
-}
-
-void FileIconLoaderClient::discardLoader()
-{
-    if (m_loader)
-        m_loader->disconnectClient();
-}
-
-PassRefPtr<FileIconLoader> FileIconLoader::create(FileIconLoaderClient* client)
-{
-    return adoptRef(new FileIconLoader(client));
-}
-
-void FileIconLoader::disconnectClient()
-{
-    m_client = 0;
-}
-
-void FileIconLoader::notifyFinished(PassRefPtr<Icon> icon)
-{
-    if (m_client)
-        m_client->updateRendering(icon);
-}
-
-FileIconLoader::FileIconLoader(FileIconLoaderClient* client)
-    : m_client(client)
-{
-}
-
-}
diff --git a/Source/core/platform/FileIconLoader.h b/Source/core/platform/FileIconLoader.h
deleted file mode 100644
index 39bb4a3..0000000
--- a/Source/core/platform/FileIconLoader.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2011 Google 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. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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.
- *
- */
-
-#ifndef FileIconLoader_h
-#define FileIconLoader_h
-
-#include "wtf/RefPtr.h"
-#include "wtf/RefCounted.h"
-
-namespace WebCore {
-
-class FileIconLoader;
-class Icon;
-
-class FileIconLoaderClient {
-public:
-    virtual void updateRendering(PassRefPtr<Icon>) = 0;
-    virtual ~FileIconLoaderClient();
-
-protected:
-    FileIconLoader* newFileIconLoader();
-
-private:
-    void discardLoader();
-
-    RefPtr<FileIconLoader> m_loader;
-};
-
-class FileIconLoader : public RefCounted<FileIconLoader> {
-public:
-    static PassRefPtr<FileIconLoader> create(FileIconLoaderClient*);
-
-    void disconnectClient();
-    void notifyFinished(PassRefPtr<Icon>);
-
-private:
-    explicit FileIconLoader(FileIconLoaderClient*);
-
-    FileIconLoaderClient* m_client;
-};
-
-} // namespace WebCore
-
-#endif
diff --git a/Source/core/platform/Length.cpp b/Source/core/platform/Length.cpp
index e304b0d..2699386 100644
--- a/Source/core/platform/Length.cpp
+++ b/Source/core/platform/Length.cpp
@@ -85,7 +85,7 @@
         else
             spacified[i] = cc;
     }
-    RefPtr<StringImpl> str = StringImpl::adopt(spacified);
+    RefPtr<StringImpl> str = spacified.release();
     str = str->simplifyWhiteSpace();
     ASSERT(str->is8Bit());
 
diff --git a/Source/core/platform/animation/CSSAnimationData.h b/Source/core/platform/animation/CSSAnimationData.h
index 3ca878a..f8c441c 100644
--- a/Source/core/platform/animation/CSSAnimationData.h
+++ b/Source/core/platform/animation/CSSAnimationData.h
@@ -126,7 +126,7 @@
     void setDuration(double d) { ASSERT(d >= 0); m_duration = d; m_durationSet = true; }
     void setFillMode(unsigned f) { m_fillMode = f; m_fillModeSet = true; }
     void setIterationCount(double c) { m_iterationCount = c; m_iterationCountSet = true; }
-    void setName(const String& n) { m_name = n; m_nameSet = true; }
+    void setName(const AtomicString& n) { m_name = n; m_nameSet = true; }
     void setPlayState(EAnimPlayState d) { m_playState = d; m_playStateSet = true; }
     void setProperty(CSSPropertyID t) { m_property = t; m_propertySet = true; }
     void setTimingFunction(PassRefPtr<TimingFunction> f) { m_timingFunction = f; m_timingFunctionSet = true; }
@@ -150,7 +150,7 @@
     CSSAnimationData();
     CSSAnimationData(const CSSAnimationData& o);
 
-    String m_name;
+    AtomicString m_name;
     CSSPropertyID m_property;
     AnimationMode m_mode;
     double m_iterationCount;
diff --git a/Source/core/platform/graphics/chromium/IconChromium.cpp b/Source/core/platform/chromium/support/WebDeviceOrientationData.cpp
similarity index 73%
rename from Source/core/platform/graphics/chromium/IconChromium.cpp
rename to Source/core/platform/chromium/support/WebDeviceOrientationData.cpp
index ab3f829..2e9817f 100644
--- a/Source/core/platform/graphics/chromium/IconChromium.cpp
+++ b/Source/core/platform/chromium/support/WebDeviceOrientationData.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Google Inc. All rights reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -29,25 +29,19 @@
  */
 
 #include "config.h"
-#include "core/platform/graphics/Icon.h"
+#include "public/platform/WebDeviceOrientationData.h"
 
-#include "core/platform/graphics/GraphicsContext.h"
-#include "wtf/text/WTFString.h"
+#include <string.h>
 
-namespace WebCore {
+namespace WebKit {
 
-Icon::Icon(PassRefPtr<PlatformIcon> icon)
-    : m_icon(icon)
+WebDeviceOrientationData::WebDeviceOrientationData()
 {
+    // Make sure to zero out the memory so that there are no uninitialized bits.
+    // This object is used in the shared memory buffer and is memory copied by
+    // two processes. Valgrind will complain if we copy around memory that is
+    // only partially initialized.
+    memset(this, 0, sizeof(*this));
 }
 
-Icon::~Icon()
-{
-}
-
-void Icon::paint(GraphicsContext* context, const IntRect& rect)
-{
-    context->drawImage(m_icon.get(), rect);
-}
-
-} // namespace WebCore
+} // namespace WebKit
diff --git a/Source/core/platform/graphics/Color.cpp b/Source/core/platform/graphics/Color.cpp
index 2be4404..f3bfb8c 100644
--- a/Source/core/platform/graphics/Color.cpp
+++ b/Source/core/platform/graphics/Color.cpp
@@ -44,6 +44,7 @@
 const RGBA32 Color::gray;
 const RGBA32 Color::lightGray;
 const RGBA32 Color::transparent;
+const RGBA32 Color::stdShadowColor;
 #endif
 
 static const RGBA32 lightenedBlack = 0xFF545454;
@@ -178,28 +179,6 @@
     return dR * dR + dG * dG + dB * dB;
 }
 
-Color::Color(const String& name)
-{
-    if (name[0] == '#') {
-        if (name.is8Bit())
-            m_valid = parseHexColor(name.characters8() + 1, name.length() - 1, m_color);
-        else
-            m_valid = parseHexColor(name.characters16() + 1, name.length() - 1, m_color);
-    } else
-        setNamedColor(name);
-}
-
-Color::Color(const char* name)
-{
-    if (name[0] == '#')
-        m_valid = parseHexColor(&name[1], m_color);
-    else {
-        const NamedColor* foundColor = findColor(name, strlen(name));
-        m_color = foundColor ? foundColor->ARGBValue : 0;
-        m_valid = foundColor;
-    }
-}
-
 String Color::serialized() const
 {
     if (!hasAlpha()) {
@@ -212,17 +191,17 @@
         return builder.toString();
     }
 
-    Vector<LChar> result;
-    result.reserveInitialCapacity(28);
+    StringBuilder result;
+    result.reserveCapacity(28);
     const char commaSpace[] = ", ";
     const char rgbaParen[] = "rgba(";
 
     result.append(rgbaParen, 5);
-    appendNumber(result, red());
+    result.appendNumber(red());
     result.append(commaSpace, 2);
-    appendNumber(result, green());
+    result.appendNumber(green());
     result.append(commaSpace, 2);
-    appendNumber(result, blue());
+    result.appendNumber(blue());
     result.append(commaSpace, 2);
 
     if (!alpha())
@@ -234,7 +213,7 @@
     }
 
     result.append(')');
-    return String::adopt(result);
+    return result.toString();
 }
 
 String Color::nameForRenderTreeAsText() const
@@ -244,29 +223,6 @@
     return String::format("#%02X%02X%02X", red(), green(), blue());
 }
 
-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 Color::setNamedColor(const String& name)
-{
-    const NamedColor* foundColor = findNamedColor(name);
-    m_color = foundColor ? foundColor->ARGBValue : 0;
-    m_valid = foundColor;
-}
-
 Color Color::light() const
 {
     // Hardcode this common case for speed.
diff --git a/Source/core/platform/graphics/Color.h b/Source/core/platform/graphics/Color.h
index 1288d4b..1734fb1 100644
--- a/Source/core/platform/graphics/Color.h
+++ b/Source/core/platform/graphics/Color.h
@@ -55,16 +55,14 @@
 class Color {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    Color() : m_color(0), m_valid(false) { }
-    Color(RGBA32 color, bool valid = true) : m_color(color), m_valid(valid) { ASSERT(!m_color || m_valid); }
-    Color(int r, int g, int b) : m_color(makeRGB(r, g, b)), m_valid(true) { }
-    Color(int r, int g, int b, int a) : m_color(makeRGBA(r, g, b, a)), m_valid(true) { }
+    Color() : m_color(0) { }
+    Color(RGBA32 color) : m_color(color) { }
+    Color(int r, int g, int b) : m_color(makeRGB(r, g, b)) { }
+    Color(int r, int g, int b, int a) : m_color(makeRGBA(r, g, b, a)) { }
     // Color is currently limited to 32bit RGBA, perhaps some day we'll support better colors
-    Color(float r, float g, float b, float a) : m_color(makeRGBA32FromFloats(r, g, b, a)), m_valid(true) { }
+    Color(float r, float g, float b, float a) : m_color(makeRGBA32FromFloats(r, g, b, a)) { }
     // Creates a new color from the specific CMYK and alpha values.
-    Color(float c, float m, float y, float k, float a) : m_color(makeRGBAFromCMYKA(c, m, y, k, a)), m_valid(true) { }
-    explicit Color(const String&);
-    explicit Color(const char*);
+    Color(float c, float m, float y, float k, float a) : m_color(makeRGBAFromCMYKA(c, m, y, k, a)) { }
 
     static Color createUnchecked(int r, int g, int b)
     {
@@ -85,10 +83,6 @@
     // The latter format is not a valid CSS color, and should only be seen in DRT dumps.
     String nameForRenderTreeAsText() const;
 
-    void setNamedColor(const String&);
-
-    bool isValid() const { return m_valid; }
-
     bool hasAlpha() const { return alpha() < 255; }
 
     int red() const { return redChannel(m_color); }
@@ -97,8 +91,8 @@
     int alpha() const { return alphaChannel(m_color); }
     
     RGBA32 rgb() const { return m_color; } // Preserve the alpha.
-    void setRGB(int r, int g, int b) { m_color = makeRGB(r, g, b); m_valid = true; }
-    void setRGB(RGBA32 rgb) { m_color = rgb; m_valid = true; }
+    void setRGB(int r, int g, int b) { m_color = makeRGB(r, g, b); }
+    void setRGB(RGBA32 rgb) { m_color = rgb; }
     void getRGBA(float& r, float& g, float& b, float& a) const;
     void getRGBA(double& r, double& g, double& b, double& a) const;
     void getHSL(double& h, double& s, double& l) const;
@@ -120,15 +114,15 @@
     static const RGBA32 gray = 0xFFA0A0A0;
     static const RGBA32 lightGray = 0xFFC0C0C0;
     static const RGBA32 transparent = 0x00000000;
+    static const RGBA32 stdShadowColor = 0x00000055;
 
 private:
     RGBA32 m_color;
-    bool m_valid;
 };
 
 inline bool operator==(const Color& a, const Color& b)
 {
-    return a.rgb() == b.rgb() && a.isValid() == b.isValid();
+    return a.rgb() == b.rgb();
 }
 
 inline bool operator!=(const Color& a, const Color& b)
@@ -141,10 +135,6 @@
 
 inline Color blend(const Color& from, const Color& to, double progress, bool blendPremultiplied = true)
 {
-    // We need to preserve the state of the valid flag at the end of the animation
-    if (progress == 1 && !to.isValid())
-        return Color();
-    
     if (blendPremultiplied) {
         // Contrary to the name, RGBA32 actually stores ARGB, so we can initialize Color directly from premultipliedARGBFromColor().
         // Also, premultipliedARGBFromColor() bails on zero alpha, so special-case that.
diff --git a/Source/core/platform/graphics/DrawLooper.cpp b/Source/core/platform/graphics/DrawLooper.cpp
index a1425c6..ef906ae 100644
--- a/Source/core/platform/graphics/DrawLooper.cpp
+++ b/Source/core/platform/graphics/DrawLooper.cpp
@@ -53,14 +53,10 @@
     ShadowTransformMode shadowTransformMode, ShadowAlphaMode shadowAlphaMode)
 {
     // Detect when there's no effective shadow.
-    if (!color.isValid() || !color.alpha())
+    if (!color.alpha())
         return;
 
-    SkColor skColor;
-    if (color.isValid())
-        skColor = color.rgb();
-    else
-        skColor = SkColorSetARGB(0xFF / 3, 0, 0, 0); // "std" apple shadow color.
+    SkColor skColor = color.rgb();
 
     SkLayerDrawLooper::LayerInfo info;
 
diff --git a/Source/core/platform/graphics/GraphicsContext.cpp b/Source/core/platform/graphics/GraphicsContext.cpp
index c3a16ac..98dbcaa 100644
--- a/Source/core/platform/graphics/GraphicsContext.cpp
+++ b/Source/core/platform/graphics/GraphicsContext.cpp
@@ -277,7 +277,7 @@
     if (paintingDisabled())
         return;
 
-    if (!color.isValid() || !color.alpha() || (!offset.width() && !offset.height() && !blur)) {
+    if (!color.alpha() || (!offset.width() && !offset.height() && !blur)) {
         clearShadow();
         return;
     }
diff --git a/Source/core/platform/graphics/GraphicsContextTest.cpp b/Source/core/platform/graphics/GraphicsContextTest.cpp
new file mode 100644
index 0000000..09e1436
--- /dev/null
+++ b/Source/core/platform/graphics/GraphicsContextTest.cpp
@@ -0,0 +1,1102 @@
+/*
+ * Copyright (C) 2012 Google 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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/platform/graphics/GraphicsContext.h"
+
+#include "SkCanvas.h"
+#include "core/platform/graphics/BitmapImage.h"
+#include "core/platform/graphics/ImageBuffer.h"
+#include "core/platform/graphics/skia/NativeImageSkia.h"
+#include <gtest/gtest.h>
+
+using namespace WebCore;
+
+namespace {
+
+#define EXPECT_EQ_RECT(a, b) \
+    EXPECT_EQ(a.x(), b.x()); \
+    EXPECT_EQ(a.y(), b.y()); \
+    EXPECT_EQ(a.width(), b.width()); \
+    EXPECT_EQ(a.height(), b.height());
+
+#define EXPECT_PIXELS_MATCH(bitmap, opaqueRect) \
+{ \
+    SkAutoLockPixels locker(bitmap); \
+    for (int y = opaqueRect.y(); y < opaqueRect.maxY(); ++y) \
+        for (int x = opaqueRect.x(); x < opaqueRect.maxX(); ++x) { \
+            int alpha = *bitmap.getAddr32(x, y) >> 24; \
+            EXPECT_EQ(255, alpha); \
+        } \
+}
+
+#define EXPECT_PIXELS_MATCH_EXACT(bitmap, opaqueRect) \
+{ \
+    SkAutoLockPixels locker(bitmap); \
+    for (int y = 0; y < bitmap.height(); ++y) \
+        for (int x = 0; x < bitmap.width(); ++x) {     \
+            int alpha = *bitmap.getAddr32(x, y) >> 24; \
+            bool opaque = opaqueRect.contains(x, y); \
+            EXPECT_EQ(opaque, alpha == 255); \
+        } \
+}
+
+TEST(GraphicsContextTest, trackOpaqueTest)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400);
+    bitmap.allocPixels();
+    bitmap.eraseColor(0);
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
+
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(10, 10, 90, 90), alpha, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(99, 13, 10, 90), opaque, CompositePlusLighter);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(99, 13, 10, 90), opaque, CompositeSourceIn);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(99, 13, 10, 90), alpha, CompositeSourceIn);
+    EXPECT_EQ_RECT(IntRect(10, 10, 89, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(8, 8, 3, 90), opaque, CompositeSourceOut);
+    EXPECT_EQ_RECT(IntRect(11, 10, 88, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(30, 30, 290, 290), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(30, 30, 290, 290), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(40, 20, 290, 50), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(30, 30, 290, 290), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(10, 10, 390, 50), opaque, CompositeSourceIn);
+    EXPECT_EQ_RECT(IntRect(30, 30, 290, 290), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(10, 10, 390, 50), alpha);
+    EXPECT_EQ_RECT(IntRect(30, 30, 290, 290), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(10, 10, 390, 50), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(30, 10, 290, 310), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, trackOpaqueClipTest)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400);
+    bitmap.allocPixels();
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
+
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.clearRect(FloatRect(10, 10, 90, 90));
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+
+    context.save();
+    context.clip(FloatRect(0, 0, 10, 10));
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+    context.restore();
+
+    context.clearRect(FloatRect(10, 10, 90, 90));
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+
+    context.save();
+    context.clip(FloatRect(20, 20, 10, 10));
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(20, 20, 10, 10), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.clearRect(FloatRect(10, 10, 90, 90));
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+
+    // The intersection of the two clips becomes empty.
+    context.clip(FloatRect(30, 20, 10, 10));
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+    context.restore();
+
+    context.clearRect(FloatRect(10, 10, 90, 90));
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+
+    // The transform and the clip need to interact correctly (transform first)
+    context.save();
+    context.translate(10, 10);
+    context.clip(FloatRect(20, 20, 10, 10));
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(30, 30, 10, 10), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+    context.restore();
+
+    context.clearRect(FloatRect(10, 10, 90, 90));
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+
+    // The transform and the clip need to interact correctly (clip first)
+    context.save();
+    context.clip(FloatRect(20, 20, 10, 10));
+    context.translate(10, 10);
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(20, 20, 10, 10), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+    context.restore();
+
+    context.clearRect(FloatRect(10, 10, 90, 90));
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+
+    Path path;
+    path.moveTo(FloatPoint(0, 0));
+    path.addLineTo(FloatPoint(100, 0));
+
+    // Non-rectangular clips just cause the paint to be considered non-opaque.
+    context.save();
+    context.clipPath(path, RULE_EVENODD);
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+    context.restore();
+
+    // Another non-rectangular clip.
+    context.save();
+    context.clip(IntRect(30, 30, 20, 20));
+    context.clipOut(IntRect(30, 30, 10, 10));
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+    context.restore();
+
+    OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100));
+    alphaImage->context()->fillRect(IntRect(0, 0, 100, 100), alpha);
+
+    // Clipping with a non-opaque Image (there is no way to mark an ImageBuffer as opaque today).
+    context.save();
+    context.clipToImageBuffer(alphaImage.get(), FloatRect(30, 30, 10, 10));
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    context.restore();
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, trackImageMask)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400);
+    bitmap.allocPixels();
+    bitmap.eraseColor(0);
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
+
+    // Image masks are done by drawing a bitmap into a transparency layer that uses DstIn to mask
+    // out a transparency layer below that is filled with the mask color. In the end this should
+    // not be marked opaque.
+
+    context.setCompositeOperation(CompositeSourceOver);
+    context.beginTransparencyLayer(1);
+    context.fillRect(FloatRect(10, 10, 10, 10), opaque, CompositeSourceOver);
+
+    context.setCompositeOperation(CompositeDestinationIn);
+    context.beginTransparencyLayer(1);
+
+    OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100));
+    alphaImage->context()->fillRect(IntRect(0, 0, 100, 100), alpha);
+
+    context.setCompositeOperation(CompositeSourceOver);
+    context.drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10));
+
+    context.endTransparencyLayer();
+    context.endTransparencyLayer();
+
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, trackImageMaskWithOpaqueRect)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400);
+    bitmap.allocPixels();
+    bitmap.eraseColor(0);
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
+
+    // Image masks are done by drawing a bitmap into a transparency layer that uses DstIn to mask
+    // out a transparency layer below that is filled with the mask color. In the end this should
+    // not be marked opaque.
+
+    context.setCompositeOperation(CompositeSourceOver);
+    context.beginTransparencyLayer(1);
+    context.fillRect(FloatRect(10, 10, 10, 10), opaque, CompositeSourceOver);
+
+    context.setCompositeOperation(CompositeDestinationIn);
+    context.beginTransparencyLayer(1);
+
+    OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100));
+    alphaImage->context()->fillRect(IntRect(0, 0, 100, 100), alpha);
+
+    context.setCompositeOperation(CompositeSourceOver);
+    context.drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10));
+
+    // We can't have an opaque mask actually, but we can pretend here like it would look if we did.
+    context.fillRect(FloatRect(12, 12, 3, 3), opaque, CompositeSourceOver);
+
+    context.endTransparencyLayer();
+    context.endTransparencyLayer();
+
+    EXPECT_EQ_RECT(IntRect(12, 12, 3, 3), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, trackOpaqueJoinTest)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400);
+    bitmap.allocPixels();
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
+
+    context.fillRect(FloatRect(20, 20, 10, 10), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(20, 20, 10, 10), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    // Doesn't join
+    context.fillRect(FloatRect(31, 20, 10, 10), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(20, 20, 10, 10), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    // Does join
+    context.fillRect(FloatRect(30, 20, 10, 10), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(20, 20, 20, 10), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    // Doesn't join
+    context.fillRect(FloatRect(20, 31, 20, 10), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(20, 20, 20, 10), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    // Does join
+    context.fillRect(FloatRect(20, 30, 20, 10), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(20, 20, 20, 20), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    // Doesn't join
+    context.fillRect(FloatRect(9, 20, 10, 20), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(20, 20, 20, 20), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    // Does join
+    context.fillRect(FloatRect(10, 20, 10, 20), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 20, 30, 20), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    // Doesn't join
+    context.fillRect(FloatRect(10, 9, 30, 10), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 20, 30, 20), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    // Does join
+    context.fillRect(FloatRect(10, 10, 30, 10), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 30, 30), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, trackOpaqueLineTest)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 200, 200);
+    bitmap.allocPixels();
+    bitmap.eraseColor(0);
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
+
+    context.setShouldAntialias(false);
+    context.setMiterLimit(0);
+    context.setStrokeThickness(4);
+    context.setLineCap(SquareCap);
+    context.setStrokeStyle(SolidStroke);
+    context.setCompositeOperation(CompositeSourceOver);
+
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.setCompositeOperation(CompositeSourceIn);
+
+    context.save();
+    context.setStrokeColor(alpha);
+    context.drawLine(IntPoint(0, 0), IntPoint(100, 0));
+    context.restore();
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.save();
+    context.setStrokeColor(opaque);
+    context.drawLine(IntPoint(0, 10), IntPoint(100, 10));
+    context.restore();
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.save();
+    context.setStrokeColor(alpha);
+    context.drawLine(IntPoint(0, 10), IntPoint(100, 10));
+    context.restore();
+    EXPECT_EQ_RECT(IntRect(10, 13, 90, 87), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.save();
+    context.setStrokeColor(alpha);
+    context.drawLine(IntPoint(0, 11), IntPoint(100, 11));
+    context.restore();
+    EXPECT_EQ_RECT(IntRect(10, 14, 90, 86), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.setShouldAntialias(true);
+    context.setCompositeOperation(CompositeSourceOver);
+
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.setCompositeOperation(CompositeSourceIn);
+
+    context.save();
+    context.setStrokeColor(alpha);
+    context.drawLine(IntPoint(0, 0), IntPoint(100, 0));
+    context.restore();
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.setShouldAntialias(false);
+    context.save();
+    context.setStrokeColor(opaque);
+    context.drawLine(IntPoint(0, 10), IntPoint(100, 10));
+    context.restore();
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.setShouldAntialias(true);
+    context.save();
+    context.setStrokeColor(opaque);
+    context.drawLine(IntPoint(0, 10), IntPoint(100, 10));
+    context.restore();
+    EXPECT_EQ_RECT(IntRect(10, 13, 90, 87), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.save();
+    context.setStrokeColor(alpha);
+    context.drawLine(IntPoint(0, 11), IntPoint(100, 11));
+    context.restore();
+    EXPECT_EQ_RECT(IntRect(10, 14, 90, 86), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, trackOpaquePathTest)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 200, 200);
+    bitmap.allocPixels();
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
+
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.setShouldAntialias(false);
+    context.setMiterLimit(1);
+    context.setStrokeThickness(5);
+    context.setLineCap(SquareCap);
+    context.setStrokeStyle(SolidStroke);
+    context.setCompositeOperation(CompositeSourceIn);
+
+    Path path;
+
+    context.setFillColor(alpha);
+    path.moveTo(FloatPoint(0, 0));
+    path.addLineTo(FloatPoint(100, 0));
+    context.fillPath(path);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+    path.clear();
+
+    context.setFillColor(opaque);
+    path.moveTo(FloatPoint(0, 10));
+    path.addLineTo(FloatPoint(100, 13));
+    context.fillPath(path);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+    path.clear();
+
+    context.setFillColor(alpha);
+    path.moveTo(FloatPoint(0, 10));
+    path.addLineTo(FloatPoint(100, 13));
+    context.fillPath(path);
+    EXPECT_EQ_RECT(IntRect(10, 13, 90, 87), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+    path.clear();
+
+    context.setFillColor(alpha);
+    path.moveTo(FloatPoint(0, 14));
+    path.addLineTo(FloatPoint(100, 10));
+    context.fillPath(path);
+    EXPECT_EQ_RECT(IntRect(10, 14, 90, 86), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+    path.clear();
+}
+
+TEST(GraphicsContextTest, trackOpaqueImageTest)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 200, 200);
+    bitmap.allocPixels();
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
+
+    SkBitmap opaqueBitmap;
+    opaqueBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
+    opaqueBitmap.allocPixels();
+
+    opaqueBitmap.setIsOpaque(true);
+    for (int y = 0; y < opaqueBitmap.height(); ++y)
+        for (int x = 0; x < opaqueBitmap.width(); ++x)
+            *opaqueBitmap.getAddr32(x, y) = 0xFFFFFFFF;
+    RefPtr<BitmapImage> opaqueImage = BitmapImage::create(NativeImageSkia::create(opaqueBitmap));
+    EXPECT_TRUE(opaqueImage->currentFrameKnownToBeOpaque());
+
+    SkBitmap alphaBitmap;
+    alphaBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
+    alphaBitmap.allocPixels();
+
+    alphaBitmap.setIsOpaque(false);
+    for (int y = 0; y < alphaBitmap.height(); ++y)
+        for (int x = 0; x < alphaBitmap.width(); ++x)
+            *alphaBitmap.getAddr32(x, y) = 0x00000000;
+    RefPtr<BitmapImage> alphaImage = BitmapImage::create(NativeImageSkia::create(alphaBitmap));
+    EXPECT_FALSE(alphaImage->currentFrameKnownToBeOpaque());
+
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawImage(opaqueImage.get(), IntPoint(0, 0));
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+    context.drawImage(alphaImage.get(), IntPoint(0, 0));
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawImage(opaqueImage.get(), IntPoint(5, 5));
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+    context.drawImage(alphaImage.get(), IntPoint(5, 5));
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawImage(opaqueImage.get(), IntPoint(10, 10));
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+    context.drawImage(alphaImage.get(), IntPoint(10, 10));
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawImage(alphaImage.get(), IntPoint(20, 10), CompositeSourceIn);
+    EXPECT_EQ_RECT(IntRect(10, 20, 90, 80), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.save();
+    context.setAlpha(0.5);
+    context.drawImage(opaqueImage.get(), IntPoint(25, 15), CompositeSourceIn);
+    context.restore();
+    EXPECT_EQ_RECT(IntRect(10, 25, 90, 75), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawImage(alphaImage.get(), IntPoint(10, 20), CompositeSourceIn);
+    EXPECT_EQ_RECT(IntRect(20, 10, 80, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.save();
+    context.setAlpha(0.5);
+    context.drawImage(opaqueImage.get(), IntPoint(15, 25), CompositeSourceIn);
+    context.restore();
+    EXPECT_EQ_RECT(IntRect(25, 10, 75, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, trackOpaqueOvalTest)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 200, 200);
+    bitmap.allocPixels();
+    bitmap.eraseColor(0);
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
+
+    EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawEllipse(IntRect(10, 10, 90, 90));
+    EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.setCompositeOperation(CompositeSourceIn);
+
+    context.setShouldAntialias(false);
+
+    context.setFillColor(opaque);
+    context.drawEllipse(IntRect(10, 10, 50, 30));
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.setFillColor(alpha);
+    context.drawEllipse(IntRect(10, 10, 30, 50));
+    EXPECT_EQ_RECT(IntRect(40, 10, 60, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.setShouldAntialias(true);
+
+    context.setFillColor(opaque);
+    context.drawEllipse(IntRect(10, 10, 50, 30));
+    EXPECT_EQ_RECT(IntRect(40, 41, 60, 59), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.setFillColor(alpha);
+    context.drawEllipse(IntRect(20, 10, 30, 50));
+    EXPECT_EQ_RECT(IntRect(51, 41, 49, 59), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, trackOpaqueRoundedRectTest)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 200, 200);
+    bitmap.allocPixels();
+    bitmap.eraseColor(0);
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
+    IntSize radii(10, 10);
+
+    EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRoundedRect(IntRect(10, 10, 90, 90), radii, radii, radii, radii, opaque);
+    EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.setCompositeOperation(CompositeSourceIn);
+    context.setShouldAntialias(false);
+
+    context.fillRoundedRect(IntRect(10, 10, 50, 30), radii, radii, radii, radii, opaque);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRoundedRect(IntRect(10, 10, 30, 50), radii, radii, radii, radii, alpha);
+    EXPECT_EQ_RECT(IntRect(40, 10, 60, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRoundedRect(IntRect(10, 0, 50, 30), radii, radii, radii, radii, alpha);
+    EXPECT_EQ_RECT(IntRect(40, 30, 60, 70), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRoundedRect(IntRect(30, 0, 70, 50), radii, radii, radii, radii, opaque);
+    EXPECT_EQ_RECT(IntRect(40, 30, 60, 70), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, trackOpaqueTextTest)
+{
+    int width = 200, height = 200;
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+    bitmap.allocPixels();
+    bitmap.eraseColor(0);
+    SkCanvas canvas(bitmap);
+    SkRect textRect = SkRect::MakeWH(width, height);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
+
+    SkPaint opaquePaint;
+    opaquePaint.setColor(opaque.rgb());
+    opaquePaint.setXfermodeMode(SkXfermode::kSrc_Mode);
+    SkPaint alphaPaint;
+    alphaPaint.setColor(alpha.rgb());
+    alphaPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
+
+    SkPoint point = SkPoint::Make(0, 0);
+    SkScalar pointX = 0;
+    SkPath path;
+    path.moveTo(SkPoint::Make(0, 0));
+    path.lineTo(SkPoint::Make(100, 0));
+
+    context.fillRect(FloatRect(50, 50, 50, 50), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(50, 50, 50, 50), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawPosText("A", 1, &point, textRect, opaquePaint);
+    EXPECT_EQ_RECT(IntRect(50, 50, 50, 50), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawPosText("A", 1, &point, textRect, alphaPaint);
+    EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(50, 50, 50, 50), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(50, 50, 50, 50), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawPosTextH("A", 1, &pointX, 0, textRect, opaquePaint);
+    EXPECT_EQ_RECT(IntRect(50, 50, 50, 50), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawPosTextH("A", 1, &pointX, 0, textRect, alphaPaint);
+    EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(50, 50, 50, 50), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(50, 50, 50, 50), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawTextOnPath("A", 1, path, textRect, 0, opaquePaint);
+    EXPECT_EQ_RECT(IntRect(50, 50, 50, 50), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawTextOnPath("A", 1, path, textRect, 0, alphaPaint);
+    EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, trackOpaqueWritePixelsTest)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 200, 200);
+    bitmap.allocPixels();
+    bitmap.eraseColor(0);
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+
+    SkBitmap opaqueBitmap;
+    opaqueBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
+    opaqueBitmap.allocPixels();
+    opaqueBitmap.setIsOpaque(true);
+    for (int y = 0; y < opaqueBitmap.height(); ++y)
+        for (int x = 0; x < opaqueBitmap.width(); ++x)
+            *opaqueBitmap.getAddr32(x, y) = 0xFFFFFFFF;
+
+    SkBitmap alphaBitmap;
+    alphaBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
+    alphaBitmap.allocPixels();
+    alphaBitmap.setIsOpaque(false);
+    for (int y = 0; y < alphaBitmap.height(); ++y)
+        for (int x = 0; x < alphaBitmap.width(); ++x)
+            *alphaBitmap.getAddr32(x, y) = 0x00000000;
+
+    SkPaint paint;
+    paint.setXfermodeMode(SkXfermode::kSrc_Mode);
+
+    context.writePixels(opaqueBitmap, 50, 50);
+    EXPECT_EQ_RECT(IntRect(50, 50, 10, 10), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.writePixels(alphaBitmap, 10, 0);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.writePixels(alphaBitmap, 10, 1);
+    EXPECT_EQ_RECT(IntRect(10, 11, 90, 89), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.writePixels(alphaBitmap, 0, 10);
+    EXPECT_EQ_RECT(IntRect(10, 11, 90, 89), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.writePixels(alphaBitmap, 1, 10);
+    EXPECT_EQ_RECT(IntRect(11, 11, 89, 89), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, trackOpaqueDrawBitmapTest)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 200, 200);
+    bitmap.allocPixels();
+    bitmap.eraseColor(0);
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+
+    SkBitmap opaqueBitmap;
+    opaqueBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
+    opaqueBitmap.allocPixels();
+    opaqueBitmap.setIsOpaque(true);
+    for (int y = 0; y < opaqueBitmap.height(); ++y)
+        for (int x = 0; x < opaqueBitmap.width(); ++x)
+            *opaqueBitmap.getAddr32(x, y) = 0xFFFFFFFF;
+
+    SkBitmap alphaBitmap;
+    alphaBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
+    alphaBitmap.allocPixels();
+    alphaBitmap.setIsOpaque(false);
+    for (int y = 0; y < alphaBitmap.height(); ++y)
+        for (int x = 0; x < alphaBitmap.width(); ++x)
+            *alphaBitmap.getAddr32(x, y) = 0x00000000;
+
+    SkPaint paint;
+    paint.setXfermodeMode(SkXfermode::kSrc_Mode);
+
+    context.drawBitmap(opaqueBitmap, 10, 10, &paint);
+    EXPECT_EQ_RECT(IntRect(10, 10, 10, 10), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawBitmap(alphaBitmap, 10, 0, &paint);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawBitmap(alphaBitmap, 10, 1, &paint);
+    EXPECT_EQ_RECT(IntRect(10, 11, 90, 89), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawBitmap(alphaBitmap, 0, 10, &paint);
+    EXPECT_EQ_RECT(IntRect(10, 11, 90, 89), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawBitmap(alphaBitmap, 1, 10, &paint);
+    EXPECT_EQ_RECT(IntRect(11, 11, 89, 89), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, trackOpaqueDrawBitmapRectTest)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 200, 200);
+    bitmap.allocPixels();
+    bitmap.eraseColor(0);
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+
+    SkBitmap opaqueBitmap;
+    opaqueBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
+    opaqueBitmap.allocPixels();
+    opaqueBitmap.setIsOpaque(true);
+    for (int y = 0; y < opaqueBitmap.height(); ++y)
+        for (int x = 0; x < opaqueBitmap.width(); ++x)
+            *opaqueBitmap.getAddr32(x, y) = 0xFFFFFFFF;
+
+    SkBitmap alphaBitmap;
+    alphaBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
+    alphaBitmap.allocPixels();
+    alphaBitmap.setIsOpaque(false);
+    for (int y = 0; y < alphaBitmap.height(); ++y)
+        for (int x = 0; x < alphaBitmap.width(); ++x)
+            *alphaBitmap.getAddr32(x, y) = 0x00000000;
+
+    SkPaint paint;
+    paint.setXfermodeMode(SkXfermode::kSrc_Mode);
+
+    context.drawBitmapRect(opaqueBitmap, 0, SkRect::MakeXYWH(10, 10, 90, 90), &paint);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawBitmapRect(alphaBitmap, 0, SkRect::MakeXYWH(10, 0, 10, 10), &paint);
+    EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawBitmapRect(alphaBitmap, 0, SkRect::MakeXYWH(10, 0, 10, 11), &paint);
+    EXPECT_EQ_RECT(IntRect(10, 11, 90, 89), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawBitmapRect(alphaBitmap, 0, SkRect::MakeXYWH(0, 10, 10, 10), &paint);
+    EXPECT_EQ_RECT(IntRect(10, 11, 90, 89), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.drawBitmapRect(alphaBitmap, 0, SkRect::MakeXYWH(0, 10, 11, 10), &paint);
+    EXPECT_EQ_RECT(IntRect(11, 11, 89, 89), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, contextTransparencyLayerTest)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400);
+    bitmap.allocPixels();
+    bitmap.eraseColor(0);
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    context.fillRect(FloatRect(20, 20, 10, 10), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(20, 20, 10, 10), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+
+    context.clearRect(FloatRect(20, 20, 10, 10));
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+
+    context.beginTransparencyLayer(0.5);
+    context.save();
+    context.fillRect(FloatRect(20, 20, 10, 10), opaque, CompositeSourceOver);
+    context.restore();
+    context.endTransparencyLayer();
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+
+    context.clearRect(FloatRect(20, 20, 10, 10));
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+
+    context.beginTransparencyLayer(0.5);
+    context.fillRect(FloatRect(20, 20, 10, 10), opaque, CompositeSourceOver);
+    context.endTransparencyLayer();
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, UnboundedDrawsAreClipped)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400);
+    bitmap.allocPixels();
+    bitmap.eraseColor(0);
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
+
+    Path path;
+    context.setShouldAntialias(false);
+    context.setMiterLimit(1);
+    context.setStrokeThickness(5);
+    context.setLineCap(SquareCap);
+    context.setStrokeStyle(SolidStroke);
+
+    // Make skia unable to compute fast bounds for our paths.
+    DashArray dashArray;
+    dashArray.append(1);
+    dashArray.append(0);
+    context.setLineDash(dashArray, 0);
+
+    // Make the device opaque in 10,10 40x40.
+    context.fillRect(FloatRect(10, 10, 40, 40), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 40, 40), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect());
+
+    // Clip to the left edge of the opaque area.
+    context.clip(IntRect(10, 10, 10, 40));
+
+    // Draw a path that gets clipped. This should destroy the opaque area but only inside the clip.
+    context.setCompositeOperation(CompositeSourceOut);
+    context.setFillColor(alpha);
+    path.moveTo(FloatPoint(10, 10));
+    path.addLineTo(FloatPoint(40, 40));
+    context.strokePath(path);
+
+    EXPECT_EQ_RECT(IntRect(20, 10, 30, 40), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
+}
+
+TEST(GraphicsContextTest, PreserveOpaqueOnlyMattersForFirstLayer)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400);
+    bitmap.allocPixels();
+    bitmap.eraseColor(0);
+    SkCanvas canvas(bitmap);
+
+    GraphicsContext context(&canvas);
+    context.setTrackOpaqueRegion(true);
+
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
+
+    Path path;
+    context.setShouldAntialias(false);
+    context.setMiterLimit(1);
+    context.setStrokeThickness(5);
+    context.setLineCap(SquareCap);
+    context.setStrokeStyle(SolidStroke);
+
+    // Make skia unable to compute fast bounds for our paths.
+    DashArray dashArray;
+    dashArray.append(1);
+    dashArray.append(0);
+    context.setLineDash(dashArray, 0);
+
+    // Make the device opaque in 10,10 40x40.
+    context.fillRect(FloatRect(10, 10, 40, 40), opaque, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(10, 10, 40, 40), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect());
+
+    // Begin a layer that preserves opaque.
+    context.setCompositeOperation(CompositeSourceOver);
+    context.beginTransparencyLayer(0.5);
+
+    // Begin a layer that does not preserve opaque.
+    context.setCompositeOperation(CompositeSourceOut);
+    context.beginTransparencyLayer(0.5);
+
+    // This should not destroy the device opaqueness.
+    context.fillRect(FloatRect(10, 10, 40, 40), opaque, CompositeSourceOver);
+
+    // This should not destroy the device opaqueness either.
+    context.setFillColor(opaque);
+    path.moveTo(FloatPoint(10, 10));
+    path.addLineTo(FloatPoint(40, 40));
+    context.strokePath(path);
+
+    context.endTransparencyLayer();
+    context.endTransparencyLayer();
+    EXPECT_EQ_RECT(IntRect(10, 10, 40, 40), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect());
+
+    // Now begin a layer that does not preserve opaque and draw through it to the device.
+    context.setCompositeOperation(CompositeSourceOut);
+    context.beginTransparencyLayer(0.5);
+
+    // This should destroy the device opaqueness.
+    context.fillRect(FloatRect(10, 10, 40, 40), opaque, CompositeSourceOver);
+
+    context.endTransparencyLayer();
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect());
+
+    // Now we draw with a path for which it cannot compute fast bounds. This should destroy the entire opaque region.
+
+    context.setCompositeOperation(CompositeSourceOut);
+    context.beginTransparencyLayer(0.5);
+
+    // This should nuke the device opaqueness.
+    context.setFillColor(opaque);
+    path.moveTo(FloatPoint(10, 10));
+    path.addLineTo(FloatPoint(40, 40));
+    context.strokePath(path);
+
+    context.endTransparencyLayer();
+    EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect());
+}
+
+} // namespace
diff --git a/Source/core/platform/graphics/GraphicsLayer.cpp b/Source/core/platform/graphics/GraphicsLayer.cpp
index 53ba337..5e56df4 100644
--- a/Source/core/platform/graphics/GraphicsLayer.cpp
+++ b/Source/core/platform/graphics/GraphicsLayer.cpp
@@ -783,7 +783,7 @@
         ts << ")\n";
     }
 
-    if (m_backgroundColor.isValid() && m_backgroundColor != Color::transparent) {
+    if (m_backgroundColor != Color::transparent) {
         writeIndent(ts, indent + 1);
         ts << "(backgroundColor " << m_backgroundColor.nameForRenderTreeAsText() << ")\n";
     }
diff --git a/Source/core/platform/graphics/Icon.h b/Source/core/platform/graphics/Icon.h
deleted file mode 100644
index bd4bb98..0000000
--- a/Source/core/platform/graphics/Icon.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef Icon_h
-#define Icon_h
-
-#include "wtf/Forward.h"
-#include "wtf/PassRefPtr.h"
-#include "wtf/RefCounted.h"
-#include "wtf/Vector.h"
-
-#include "core/platform/graphics/Image.h"
-#include "core/platform/graphics/chromium/PlatformIcon.h"
-
-namespace WebCore {
-
-class GraphicsContext;
-class IntRect;
-    
-class Icon : public RefCounted<Icon> {
-public:
-    static PassRefPtr<Icon> createIconForFiles(const Vector<String>& filenames);
-
-    ~Icon();
-
-    void paint(GraphicsContext*, const IntRect&);
-
-    static PassRefPtr<Icon> create(PassRefPtr<PlatformIcon> icon) { return adoptRef(new Icon(icon)); }
-
-private:
-    Icon(PassRefPtr<PlatformIcon>);
-    RefPtr<PlatformIcon> m_icon;
-};
-
-}
-
-#endif
diff --git a/Source/core/platform/graphics/Path.cpp b/Source/core/platform/graphics/Path.cpp
index fd913d6..015788d 100644
--- a/Source/core/platform/graphics/Path.cpp
+++ b/Source/core/platform/graphics/Path.cpp
@@ -69,9 +69,7 @@
 
 bool Path::contains(const FloatPoint& point, WindRule rule) const
 {
-    // After crbug.com/236559 is fixed, SkPathContainsPoint should take a const path so this will be unnecessary.
-    SkPath* path = const_cast<SkPath*>(&m_path);
-    return SkPathContainsPoint(path, point, rule == RULE_NONZERO ? SkPath::kWinding_FillType : SkPath::kEvenOdd_FillType);
+    return SkPathContainsPoint(m_path, point, rule == RULE_NONZERO ? SkPath::kWinding_FillType : SkPath::kEvenOdd_FillType);
 }
 
 bool Path::strokeContains(const FloatPoint& point, const StrokeData& strokeData) const
@@ -81,7 +79,7 @@
     SkPath strokePath;
     paint.getFillPath(m_path, &strokePath);
 
-    return SkPathContainsPoint(&strokePath, point, SkPath::kWinding_FillType);
+    return SkPathContainsPoint(strokePath, point, SkPath::kWinding_FillType);
 }
 
 FloatRect Path::boundingRect() const
diff --git a/Source/core/platform/graphics/ShadowBlur.cpp b/Source/core/platform/graphics/ShadowBlur.cpp
index 652d13a..9f2ee07 100644
--- a/Source/core/platform/graphics/ShadowBlur.cpp
+++ b/Source/core/platform/graphics/ShadowBlur.cpp
@@ -55,7 +55,7 @@
     m_blurRadius = m_blurRadius.shrunkTo(FloatSize(128, 128));
 
     // The type of shadow is decided by the blur radius, shadow offset, and shadow color.
-    if (!m_color.isValid() || !m_color.alpha()) {
+    if (!m_color.alpha()) {
         // Can't paint the shadow with invalid or invisible color.
         m_type = NoShadow;
     } else if (m_blurRadius.width() > 0 || m_blurRadius.height() > 0) {
diff --git a/Source/core/platform/graphics/chromium/Canvas2DLayerBridge.cpp b/Source/core/platform/graphics/chromium/Canvas2DLayerBridge.cpp
index a720654..e708983 100644
--- a/Source/core/platform/graphics/chromium/Canvas2DLayerBridge.cpp
+++ b/Source/core/platform/graphics/chromium/Canvas2DLayerBridge.cpp
@@ -60,6 +60,7 @@
     m_canvas->setNotificationClient(this);
     m_layer = adoptPtr(WebKit::Platform::current()->compositorSupport()->createExternalTextureLayer(this));
     m_layer->setOpaque(opacityMode == Opaque);
+    m_layer->setBlendBackgroundColor(opacityMode != Opaque);
     GraphicsLayer::registerContentsLayer(m_layer->layer());
     m_layer->setRateLimitContext(m_rateLimitingEnabled);
 }
diff --git a/Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp b/Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp
index eb3c197..20b7b6d 100644
--- a/Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp
+++ b/Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp
@@ -220,7 +220,8 @@
     if (!s_enabled
         || !m_actualDecoder
         || !m_actualDecoder->isSizeAvailable()
-        || m_actualDecoder->filenameExtension() == "ico")
+        || m_actualDecoder->filenameExtension() == "ico"
+        || m_actualDecoder->filenameExtension() == "gif")
         return;
 
     activateLazyDecoding();
diff --git a/Source/core/platform/graphics/chromium/IconChromiumAndroid.cpp b/Source/core/platform/graphics/chromium/IconChromiumAndroid.cpp
deleted file mode 100644
index 91b7bc6..0000000
--- a/Source/core/platform/graphics/chromium/IconChromiumAndroid.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2011 Google 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 AND ITS CONTRIBUTORS "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 OR ITS 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/platform/graphics/Icon.h"
-
-#include "core/platform/NotImplemented.h"
-#include "core/platform/graphics/GraphicsContext.h"
-#include "wtf/text/WTFString.h"
-
-namespace WebCore {
-
-Icon::Icon(PassRefPtr<PlatformIcon> icon)
-    : m_icon(icon)
-{
-}
-
-Icon::~Icon()
-{
-}
-
-void Icon::paint(GraphicsContext*, const IntRect&)
-{
-    notImplemented();
-}
-
-} // namespace WebCore
diff --git a/Source/core/platform/graphics/chromium/PlatformIcon.h b/Source/core/platform/graphics/chromium/PlatformIcon.h
deleted file mode 100644
index b485917..0000000
--- a/Source/core/platform/graphics/chromium/PlatformIcon.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Google 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:
- * 
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * 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.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 THE COPYRIGHT
- * OWNER 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.
- */
-
-#ifndef PlatformIcon_h
-#define PlatformIcon_h
-
-namespace WebCore {
-
-class Image;
-
-typedef Image PlatformIcon;
-
-}  // namespace WebCore
-
-#endif  // PlatformIcon_h
diff --git a/Source/core/platform/graphics/chromium/UniscribeHelper.cpp b/Source/core/platform/graphics/chromium/UniscribeHelper.cpp
index 5fd554c..d74037f 100644
--- a/Source/core/platform/graphics/chromium/UniscribeHelper.cpp
+++ b/Source/core/platform/graphics/chromium/UniscribeHelper.cpp
@@ -1040,7 +1040,7 @@
         // is not a zero width whitespace.
         if (glyph == properties->wgDefault
             || (glyph == properties->wgInvalid && glyph != properties->wgBlank)
-            || (glyph == properties->wgBlank && shaping.m_visualAttributes[glyphIndex].fZeroWidth))
+            || (glyph == properties->wgBlank && shaping.m_visualAttributes[glyphIndex].fZeroWidth && !Font::treatAsZeroWidthSpace(c)))
             return true;
     }
     return false;
diff --git a/Source/core/platform/graphics/gpu/DrawingBuffer.cpp b/Source/core/platform/graphics/gpu/DrawingBuffer.cpp
index a862bf4..0ffa0b0 100644
--- a/Source/core/platform/graphics/gpu/DrawingBuffer.cpp
+++ b/Source/core/platform/graphics/gpu/DrawingBuffer.cpp
@@ -306,6 +306,7 @@
         m_layer = adoptPtr(WebKit::Platform::current()->compositorSupport()->createExternalTextureLayer(this));
 
         m_layer->setOpaque(!m_attributes.alpha);
+        m_layer->setBlendBackgroundColor(m_attributes.alpha);
         m_layer->setPremultipliedAlpha(m_attributes.premultipliedAlpha);
         GraphicsLayer::registerContentsLayer(m_layer->layer());
     }
diff --git a/Source/core/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp b/Source/core/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp
index 1c0af7d..1857d7d 100644
--- a/Source/core/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp
+++ b/Source/core/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp
@@ -84,32 +84,32 @@
 }
 
 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
-    : m_typeface(hashTableDeletedFontValue())
-    , m_textSize(0)
+    : m_textSize(0)
     , m_emSizeInFontUnits(0)
     , m_fakeBold(false)
     , m_fakeItalic(false)
     , m_orientation(Horizontal)
+    , m_isHashTableDeletedValue(true)
 {
 }
 
 FontPlatformData::FontPlatformData()
-    : m_typeface(0)
-    , m_textSize(0)
+    : m_textSize(0)
     , m_emSizeInFontUnits(0)
     , m_fakeBold(false)
     , m_fakeItalic(false)
     , m_orientation(Horizontal)
+    , m_isHashTableDeletedValue(false)
 {
 }
 
 FontPlatformData::FontPlatformData(float textSize, bool fakeBold, bool fakeItalic)
-    : m_typeface(0)
-    , m_textSize(textSize)
+    : m_textSize(textSize)
     , m_emSizeInFontUnits(0)
     , m_fakeBold(fakeBold)
     , m_fakeItalic(fakeItalic)
     , m_orientation(Horizontal)
+    , m_isHashTableDeletedValue(false)
 {
 }
 
@@ -123,8 +123,8 @@
     , m_orientation(src.m_orientation)
     , m_style(src.m_style)
     , m_harfBuzzFace(src.m_harfBuzzFace)
+    , m_isHashTableDeletedValue(false)
 {
-    SkSafeRef(m_typeface);
 }
 
 FontPlatformData::FontPlatformData(SkTypeface* tf, const char* family, float textSize, bool fakeBold, bool fakeItalic, FontOrientation orientation)
@@ -135,8 +135,8 @@
     , m_fakeBold(fakeBold)
     , m_fakeItalic(fakeItalic)
     , m_orientation(orientation)
+    , m_isHashTableDeletedValue(false)
 {
-    SkSafeRef(m_typeface);
     querySystemForRenderStyle();
 }
 
@@ -149,14 +149,13 @@
     , m_fakeItalic(src.m_fakeItalic)
     , m_orientation(src.m_orientation)
     , m_harfBuzzFace(src.m_harfBuzzFace)
+    , m_isHashTableDeletedValue(false)
 {
-    SkSafeRef(m_typeface);
     querySystemForRenderStyle();
 }
 
 FontPlatformData::~FontPlatformData()
 {
-    SkSafeUnref(m_typeface);
 }
 
 int FontPlatformData::emSizeInFontUnits() const
@@ -170,8 +169,7 @@
 
 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src)
 {
-    SkRefCnt_SafeAssign(m_typeface, src.m_typeface);
-
+    m_typeface = src.m_typeface;
     m_family = src.m_family;
     m_textSize = src.m_textSize;
     m_fakeBold = src.m_fakeBold;
@@ -203,7 +201,7 @@
 
     const float ts = m_textSize >= 0 ? m_textSize : 12;
     paint->setTextSize(SkFloatToScalar(ts));
-    paint->setTypeface(m_typeface);
+    paint->setTypeface(m_typeface.get());
     paint->setFakeBoldText(m_fakeBold);
     paint->setTextSkewX(m_fakeItalic ? -SK_Scalar1 / 4 : 0);
 }
@@ -215,29 +213,26 @@
 
 bool FontPlatformData::operator==(const FontPlatformData& a) const
 {
-    // If either of the typeface pointers are invalid (either 0 or the
-    // special deleted value) then we test for pointer equality. Otherwise, we
-    // call SkTypeface::Equal on the valid pointers.
+    // If either of the typeface pointers are null then we test for pointer
+    // equality. Otherwise, we call SkTypeface::Equal on the valid pointers.
     bool typefacesEqual;
-    if (m_typeface == hashTableDeletedFontValue()
-        || a.m_typeface == hashTableDeletedFontValue()
-        || !m_typeface
-        || !a.m_typeface)
+    if (!m_typeface || !a.m_typeface)
         typefacesEqual = m_typeface == a.m_typeface;
     else
-        typefacesEqual = SkTypeface::Equal(m_typeface, a.m_typeface);
+        typefacesEqual = SkTypeface::Equal(m_typeface.get(), a.m_typeface.get());
 
     return typefacesEqual
         && m_textSize == a.m_textSize
         && m_fakeBold == a.m_fakeBold
         && m_fakeItalic == a.m_fakeItalic
         && m_orientation == a.m_orientation
-        && m_style == a.m_style;
+        && m_style == a.m_style
+        && m_isHashTableDeletedValue == a.m_isHashTableDeletedValue;
 }
 
 unsigned FontPlatformData::hash() const
 {
-    unsigned h = SkTypeface::UniqueID(m_typeface);
+    unsigned h = SkTypeface::UniqueID(m_typeface.get());
     h ^= 0x01010101 * ((static_cast<int>(m_orientation) << 2) | (static_cast<int>(m_fakeBold) << 1) | static_cast<int>(m_fakeItalic));
 
     // This memcpy is to avoid a reinterpret_cast that breaks strict-aliasing
diff --git a/Source/core/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h b/Source/core/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h
index e660548..9d9ea6a 100644
--- a/Source/core/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h
+++ b/Source/core/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h
@@ -86,7 +86,7 @@
     // the font's file name so refers to a single face.
     // -------------------------------------------------------------------------
     SkFontID uniqueID() const;
-    SkTypeface* typeface() const { return m_typeface; }
+    SkTypeface* typeface() const { return m_typeface.get(); }
 
     unsigned hash() const;
     float size() const { return m_textSize; }
@@ -98,7 +98,7 @@
     void setFakeItalic(bool fakeItalic) { m_fakeItalic = fakeItalic; }
     bool operator==(const FontPlatformData&) const;
     FontPlatformData& operator=(const FontPlatformData&);
-    bool isHashTableDeletedValue() const { return m_typeface == hashTableDeletedFontValue(); }
+    bool isHashTableDeletedValue() const { return m_isHashTableDeletedValue; }
 
 #if ENABLE(OPENTYPE_VERTICAL)
     PassRefPtr<OpenTypeVerticalData> verticalData() const;
@@ -128,8 +128,7 @@
     void getRenderStyleForStrike(const char*, int);
     void querySystemForRenderStyle();
 
-    // FIXME: Could SkAutoUnref be used here?
-    SkTypeface* m_typeface;
+    RefPtr<SkTypeface> m_typeface;
     CString m_family;
     float m_textSize;
     mutable int m_emSizeInFontUnits;
@@ -138,8 +137,7 @@
     FontOrientation m_orientation;
     FontRenderStyle m_style;
     mutable RefPtr<HarfBuzzFace> m_harfBuzzFace;
-
-    SkTypeface* hashTableDeletedFontValue() const { return reinterpret_cast<SkTypeface*>(-1); }
+    bool m_isHashTableDeletedValue;
 };
 
 } // namespace WebCore
diff --git a/Source/core/platform/graphics/skia/SkiaUtils.cpp b/Source/core/platform/graphics/skia/SkiaUtils.cpp
index 7c2bfdd..77ed53c 100644
--- a/Source/core/platform/graphics/skia/SkiaUtils.cpp
+++ b/Source/core/platform/graphics/skia/SkiaUtils.cpp
@@ -139,9 +139,9 @@
         destRect->setEmpty();
 }
 
-bool SkPathContainsPoint(SkPath* originalPath, const FloatPoint& point, SkPath::FillType ft)
+bool SkPathContainsPoint(const SkPath& originalPath, const FloatPoint& point, SkPath::FillType ft)
 {
-    SkRect bounds = originalPath->getBounds();
+    SkRect bounds = originalPath.getBounds();
 
     // We can immediately return false if the point is outside the bounding
     // rect.  We don't use bounds.contains() here, since it would exclude
@@ -167,21 +167,17 @@
     SkRegion rgn;  
     SkRegion clip;
     SkMatrix m;
-    SkPath scaledPath;
+    SkPath scaledPath(originalPath);
 
-    SkPath::FillType originalFillType = originalPath->getFillType();
-    originalPath->setFillType(ft);
-
+    scaledPath.setFillType(ft);
     m.setScale(scale, scale);
-    originalPath->transform(m, &scaledPath);
+    scaledPath.transform(m, 0);
 
     int x = static_cast<int>(floorf(0.5f + point.x() * scale));
     int y = static_cast<int>(floorf(0.5f + point.y() * scale));
     clip.setRect(x - 1, y - 1, x + 1, y + 1);
 
-    bool contains = rgn.setPath(scaledPath, clip);
-    originalPath->setFillType(originalFillType);
-    return contains;
+    return rgn.setPath(scaledPath, clip);
 }
 
 }  // namespace WebCore
diff --git a/Source/core/platform/graphics/skia/SkiaUtils.h b/Source/core/platform/graphics/skia/SkiaUtils.h
index 757f4e2..b56e5c8 100644
--- a/Source/core/platform/graphics/skia/SkiaUtils.h
+++ b/Source/core/platform/graphics/skia/SkiaUtils.h
@@ -76,7 +76,7 @@
 void ClipRectToCanvas(const GraphicsContext*, const SkRect& srcRect, SkRect* destRect);
 
 // Determine if a given WebKit point is contained in a path
-bool SkPathContainsPoint(SkPath*, const FloatPoint&, SkPath::FillType);
+bool SkPathContainsPoint(const SkPath&, const FloatPoint&, SkPath::FillType);
 
 }  // namespace WebCore
 
diff --git a/Source/core/platform/mac/ScrollAnimatorMac.mm b/Source/core/platform/mac/ScrollAnimatorMac.mm
index 89d55f2..b2aee69 100644
--- a/Source/core/platform/mac/ScrollAnimatorMac.mm
+++ b/Source/core/platform/mac/ScrollAnimatorMac.mm
@@ -1026,7 +1026,9 @@
 
     bool didHandleEvent = m_scrollElasticityController.handleWheelEvent(wheelEvent);
 
-    if (didHandleEvent)
+    // The elasticity controller can return false on a phase end event if rubber banding wasn't in progress.
+    // In this case, the wheel phase must still be handled so that that overlay scroll bars get hidden.
+    if (didHandleEvent || wheelEvent.phase() == PlatformWheelEventPhaseEnded || wheelEvent.phase() == PlatformWheelEventPhaseCancelled)
         handleWheelEventPhase(wheelEvent.phase());
 
     return didHandleEvent;
diff --git a/Source/core/platform/network/ResourceHandle.cpp b/Source/core/platform/network/ResourceHandle.cpp
deleted file mode 100644
index 5633ae8..0000000
--- a/Source/core/platform/network/ResourceHandle.cpp
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (C) 2009 Google 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:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * 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.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 THE COPYRIGHT
- * OWNER 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/platform/network/ResourceHandle.h"
-
-#include "core/platform/chromium/support/WrappedResourceRequest.h"
-#include "core/platform/chromium/support/WrappedResourceResponse.h"
-#include "core/platform/network/ResourceError.h"
-#include "core/platform/network/ResourceHandleClient.h"
-#include "core/platform/network/ResourceHandleInternal.h"
-#include "core/platform/network/ResourceRequest.h"
-#include "core/platform/network/ResourceResponse.h"
-#include "public/platform/Platform.h"
-#include "public/platform/WebURLError.h"
-#include "public/platform/WebURLLoader.h"
-#include "public/platform/WebURLLoaderClient.h"
-#include "public/platform/WebURLRequest.h"
-#include "public/platform/WebURLResponse.h"
-
-using namespace WebKit;
-
-namespace WebCore {
-
-// ResourceHandleInternal -----------------------------------------------------
-ResourceHandleInternal::ResourceHandleInternal(const ResourceRequest& request, ResourceHandleClient* client)
-    : m_request(request)
-    , m_owner(0)
-    , m_client(client)
-    , m_state(ConnectionStateNew)
-{
-}
-
-void ResourceHandleInternal::start(StoredCredentials storedCredentials)
-{
-    if (m_state != ConnectionStateNew)
-        CRASH();
-    m_state = ConnectionStateStarted;
-
-    m_loader = adoptPtr(Platform::current()->createURLLoader());
-    ASSERT(m_loader);
-
-    WrappedResourceRequest wrappedRequest(m_request);
-    wrappedRequest.setAllowStoredCredentials(storedCredentials == AllowStoredCredentials);
-    m_loader->loadAsynchronously(wrappedRequest, this);
-}
-
-void ResourceHandleInternal::cancel()
-{
-    m_state = ConnectionStateCanceled;
-    m_loader->cancel();
-
-    // Do not make any further calls to the client.
-    m_client = 0;
-}
-
-void ResourceHandleInternal::setDefersLoading(bool value)
-{
-    m_loader->setDefersLoading(value);
-}
-
-void ResourceHandleInternal::didChangePriority(WebURLRequest::Priority newPriority)
-{
-    m_loader->didChangePriority(newPriority);
-}
-
-void ResourceHandleInternal::willSendRequest(
-    WebURLLoader*, WebURLRequest& request, const WebURLResponse& response)
-{
-    ASSERT(m_client);
-    ASSERT(!request.isNull());
-    ASSERT(!response.isNull());
-    m_client->willSendRequest(m_owner, request.toMutableResourceRequest(), response.toResourceResponse());
-}
-
-void ResourceHandleInternal::didSendData(
-    WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
-{
-    ASSERT(m_client);
-    m_client->didSendData(m_owner, bytesSent, totalBytesToBeSent);
-}
-
-void ResourceHandleInternal::didReceiveResponse(WebURLLoader*, const WebURLResponse& response)
-{
-    ASSERT(m_client);
-    ASSERT(!response.isNull());
-    bool isMultipart = response.isMultipartPayload();
-    bool isValidStateTransition = (m_state == ConnectionStateStarted || m_state == ConnectionStateReceivedResponse);
-    // In the case of multipart loads, calls to didReceiveData & didReceiveResponse can be interleaved.
-    if (!isMultipart && !isValidStateTransition)
-        CRASH();
-    m_state = ConnectionStateReceivedResponse;
-    m_client->didReceiveResponse(m_owner, response.toResourceResponse());
-}
-
-void ResourceHandleInternal::didDownloadData(WebURLLoader*, int dataLength)
-{
-    ASSERT(m_client);
-    if (m_state != ConnectionStateReceivedResponse)
-        CRASH();
-
-    m_client->didDownloadData(m_owner, dataLength);
-}
-
-void ResourceHandleInternal::didReceiveData(WebURLLoader*, const char* data, int dataLength, int encodedDataLength)
-{
-    ASSERT(m_client);
-    if (m_state != ConnectionStateReceivedResponse && m_state != ConnectionStateReceivingData)
-        CRASH();
-    m_state = ConnectionStateReceivingData;
-
-    m_client->didReceiveData(m_owner, data, dataLength, encodedDataLength);
-}
-
-void ResourceHandleInternal::didReceiveCachedMetadata(WebURLLoader*, const char* data, int dataLength)
-{
-    ASSERT(m_client);
-    if (m_state != ConnectionStateReceivedResponse && m_state != ConnectionStateReceivingData)
-        CRASH();
-
-    m_client->didReceiveCachedMetadata(m_owner, data, dataLength);
-}
-
-void ResourceHandleInternal::didFinishLoading(WebURLLoader*, double finishTime)
-{
-    ASSERT(m_client);
-    if (m_state != ConnectionStateReceivedResponse && m_state != ConnectionStateReceivingData)
-        CRASH();
-    m_state = ConnectionStateFinishedLoading;
-    m_client->didFinishLoading(m_owner, finishTime);
-}
-
-void ResourceHandleInternal::didFail(WebURLLoader*, const WebURLError& error)
-{
-    ASSERT(m_client);
-    m_state = ConnectionStateFailed;
-    m_client->didFail(m_owner, error);
-}
-
-ResourceHandleInternal* ResourceHandleInternal::FromResourceHandle(ResourceHandle* handle)
-{
-    return handle->d.get();
-}
-
-// ResourceHandle -------------------------------------------------------------
-
-ResourceHandle::ResourceHandle(const ResourceRequest& request, ResourceHandleClient* client, bool defersLoading, bool shouldContentSniff)
-    : d(adoptPtr(new ResourceHandleInternal(request, client)))
-{
-    d->setOwner(this);
-
-    // FIXME: Figure out what to do with the bool params.
-}
-
-PassRefPtr<ResourceHandle> ResourceHandle::create(const ResourceRequest& request,
-                                                  ResourceHandleClient* client,
-                                                  bool defersLoading,
-                                                  bool shouldContentSniff,
-                                                  StoredCredentials storedCredentials)
-{
-    RefPtr<ResourceHandle> newHandle = adoptRef(new ResourceHandle(request, client, defersLoading, shouldContentSniff));
-
-    newHandle->start(storedCredentials);
-    return newHandle.release();
-}
-
-ResourceRequest& ResourceHandle::firstRequest()
-{
-    return d->request();
-}
-
-ResourceHandleClient* ResourceHandle::client() const
-{
-    return d->client();
-}
-
-void ResourceHandle::setClient(ResourceHandleClient* client)
-{
-    d->setClient(client);
-}
-
-void ResourceHandle::setDefersLoading(bool value)
-{
-    d->setDefersLoading(value);
-}
-
-void ResourceHandle::start(StoredCredentials storedCredentials)
-{
-    d->start(storedCredentials);
-}
-
-void ResourceHandle::cancel()
-{
-    d->cancel();
-}
-
-ResourceHandle::~ResourceHandle()
-{
-    d->setOwner(0);
-}
-
-// static
-void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request,
-                                               StoredCredentials storedCredentials,
-                                               ResourceError& error,
-                                               ResourceResponse& response,
-                                               Vector<char>& data)
-{
-    OwnPtr<WebURLLoader> loader = adoptPtr(Platform::current()->createURLLoader());
-    ASSERT(loader);
-
-    WrappedResourceRequest requestIn(request);
-    requestIn.setAllowStoredCredentials(storedCredentials == AllowStoredCredentials);
-    WrappedResourceResponse responseOut(response);
-    WebURLError errorOut;
-    WebData dataOut;
-
-    loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut);
-
-    error = errorOut;
-    data.clear();
-    data.append(dataOut.data(), dataOut.size());
-}
-
-void ResourceHandle::didChangePriority(ResourceLoadPriority newPriority)
-{
-    d->didChangePriority(static_cast<WebURLRequest::Priority>(newPriority));
-}
-
-// static
-void ResourceHandle::cacheMetadata(const ResourceResponse& response, const Vector<char>& data)
-{
-    WebKit::Platform::current()->cacheMetadata(response.url(), response.responseTime(), data.data(), data.size());
-}
-
-} // namespace WebCore
diff --git a/Source/core/platform/network/ResourceHandle.h b/Source/core/platform/network/ResourceHandle.h
deleted file mode 100644
index d05eab5..0000000
--- a/Source/core/platform/network/ResourceHandle.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2011 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. 
- */
-
-#ifndef ResourceHandle_h
-#define ResourceHandle_h
-
-#include "core/platform/network/ResourceHandleTypes.h"
-#include "core/platform/network/ResourceLoadPriority.h"
-#include "wtf/Forward.h"
-#include "wtf/OwnPtr.h"
-#include "wtf/RefCounted.h"
-#include "wtf/Vector.h"
-
-namespace WebCore {
-class KURL;
-class ResourceError;
-class ResourceHandleClient;
-class ResourceHandleInternal;
-class ResourceRequest;
-class ResourceResponse;
-
-template <typename T> class Timer;
-
-class ResourceHandle : public RefCounted<ResourceHandle> {
-public:
-    static PassRefPtr<ResourceHandle> create(const ResourceRequest&, ResourceHandleClient*, bool defersLoading, bool shouldContentSniff, StoredCredentials);
-    static void loadResourceSynchronously(const ResourceRequest&, StoredCredentials, ResourceError&, ResourceResponse&, Vector<char>& data);
-
-    static void cacheMetadata(const ResourceResponse&, const Vector<char>&);
-
-    virtual ~ResourceHandle();
-
-    virtual void cancel();
-
-    // The client may be 0, in which case no callbacks will be made.
-    ResourceHandleClient* client() const;
-    void setClient(ResourceHandleClient*);
-
-    void setDefersLoading(bool);
-
-    void didChangePriority(ResourceLoadPriority);
-
-    ResourceRequest& firstRequest();
-
-protected:
-    ResourceHandle(const ResourceRequest&, ResourceHandleClient*, bool defersLoading, bool shouldContentSniff);
-
-private:
-    void start(StoredCredentials);
-    friend class ResourceHandleInternal;
-    OwnPtr<ResourceHandleInternal> d;
-};
-
-}
-
-#endif // ResourceHandle_h
diff --git a/Source/core/platform/network/ResourceHandleClient.cpp b/Source/core/platform/network/ResourceHandleClient.cpp
deleted file mode 100644
index 1591dfd..0000000
--- a/Source/core/platform/network/ResourceHandleClient.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2013 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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/platform/network/ResourceHandleClient.h"
-
-namespace WebCore {
-
-ResourceHandleClient::ResourceHandleClient()
-{
-}
-
-ResourceHandleClient::~ResourceHandleClient()
-{
-}
-
-}
diff --git a/Source/core/platform/network/ResourceHandleClient.h b/Source/core/platform/network/ResourceHandleClient.h
deleted file mode 100644
index 38de7a2..0000000
--- a/Source/core/platform/network/ResourceHandleClient.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
- * Copyright (C) 2013 Apple Computer, 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. 
- */
-
-#ifndef ResourceHandleClient_h
-#define ResourceHandleClient_h
-
-#include "wtf/PassRefPtr.h"
-
-namespace WebCore {
-    class ResourceHandle;
-    class ResourceError;
-    class ResourceRequest;
-    class ResourceResponse;
-
-    enum CacheStoragePolicy {
-        StorageAllowed,
-        StorageAllowedInMemoryOnly,
-        StorageNotAllowed
-    };
-    
-    class ResourceHandleClient {
-    public:
-        ResourceHandleClient();
-        virtual ~ResourceHandleClient();
-
-        // Request may be modified.
-        virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse& /*redirectResponse*/) { }
-        virtual void didSendData(ResourceHandle*, unsigned long long /*bytesSent*/, unsigned long long /*totalBytesToBeSent*/) { }
-
-        virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) { }
-        
-        virtual void didReceiveData(ResourceHandle*, const char*, int, int /*encodedDataLength*/) { }
-        
-        virtual void didReceiveCachedMetadata(ResourceHandle*, const char*, int) { }
-        virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/) { }
-        virtual void didFail(ResourceHandle*, const ResourceError&) { }
-
-        virtual void didDownloadData(ResourceHandle*, int /*dataLength*/) { }
-    };
-
-}
-
-#endif
diff --git a/Source/core/platform/network/ResourceHandleInternal.h b/Source/core/platform/network/ResourceHandleInternal.h
deleted file mode 100644
index 8fd9668..0000000
--- a/Source/core/platform/network/ResourceHandleInternal.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2011 Google 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:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * 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.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 THE COPYRIGHT
- * OWNER 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.
- */
-
-#ifndef ResourceHandleInternal_h
-#define ResourceHandleInternal_h
-
-#include "core/platform/network/ResourceRequest.h"
-#include "public/platform/WebCommon.h"
-#include "public/platform/WebURLLoader.h"
-#include "public/platform/WebURLLoaderClient.h"
-#include "public/platform/WebURLRequest.h"
-
-namespace WebCore {
-
-class ResourceHandle;
-class ResourceHandleClient;
-
-class ResourceHandleInternal : public WebKit::WebURLLoaderClient {
-public:
-    ResourceHandleInternal(const ResourceRequest&, ResourceHandleClient*);
-
-    virtual ~ResourceHandleInternal() { }
-
-    void start(StoredCredentials);
-    void cancel();
-    void setDefersLoading(bool);
-    void didChangePriority(WebKit::WebURLRequest::Priority);
-
-    // WebURLLoaderClient methods:
-    virtual void willSendRequest(WebKit::WebURLLoader*, WebKit::WebURLRequest&, const WebKit::WebURLResponse&);
-    virtual void didSendData(WebKit::WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
-    virtual void didReceiveResponse(WebKit::WebURLLoader*, const WebKit::WebURLResponse&);
-    virtual void didDownloadData(WebKit::WebURLLoader*, int dataLength);
-    virtual void didReceiveData(WebKit::WebURLLoader*, const char* data, int dataLength, int encodedDataLength);
-
-    virtual void didReceiveCachedMetadata(WebKit::WebURLLoader*, const char* data, int dataLength);
-    virtual void didFinishLoading(WebKit::WebURLLoader*, double finishTime);
-    virtual void didFail(WebKit::WebURLLoader*, const WebKit::WebURLError&);
-
-    enum ConnectionState {
-        ConnectionStateNew,
-        ConnectionStateStarted,
-        ConnectionStateReceivedResponse,
-        ConnectionStateReceivingData,
-        ConnectionStateFinishedLoading,
-        ConnectionStateCanceled,
-        ConnectionStateFailed,
-    };
-
-    void setOwner(ResourceHandle* owner) { m_owner = owner; }
-    ResourceRequest& request() { return m_request; }
-    ResourceHandleClient* client() const { return m_client; }
-    void setClient(ResourceHandleClient* client) { m_client = client; }
-    WebKit::WebURLLoader* loader() const { return m_loader.get(); }
-
-    static ResourceHandleInternal* FromResourceHandle(ResourceHandle*);
-
-private:
-    ResourceRequest m_request;
-    ResourceHandle* m_owner;
-    ResourceHandleClient* m_client;
-    OwnPtr<WebKit::WebURLLoader> m_loader;
-
-    // Used for sanity checking to make sure we don't experience illegal state
-    // transitions.
-    ConnectionState m_state;
-};
-
-} // namespace WebCore
-
-#endif
diff --git a/Source/core/platform/network/ResourceHandleTypes.h b/Source/core/platform/network/ResourceHandleTypes.h
deleted file mode 100644
index 4dde871..0000000
--- a/Source/core/platform/network/ResourceHandleTypes.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2013 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
- */
-
-#ifndef ResourceHandleTypes_h
-#define ResourceHandleTypes_h
-
-namespace WebCore {
-
-enum StoredCredentials {
-    AllowStoredCredentials,
-    DoNotAllowStoredCredentials
-};
-
-// APIs like XMLHttpRequest and EventSource let the user decide
-// whether to send credentials, but they're always sent for
-// same-origin requests. Additional information is needed to handle
-// cross-origin redirects correctly.
-enum CredentialRequest {
-    ClientRequestedCredentials,
-    ClientDidNotRequestCredentials
-};
-
-} // namespace WebCore
-
-#endif // ResourceHandleTypes_h
diff --git a/Source/core/platform/text/LocaleICU.cpp b/Source/core/platform/text/LocaleICU.cpp
index a0f05dd..e94fed9 100644
--- a/Source/core/platform/text/LocaleICU.cpp
+++ b/Source/core/platform/text/LocaleICU.cpp
@@ -36,6 +36,7 @@
 #include <limits>
 #include "wtf/DateMath.h"
 #include "wtf/PassOwnPtr.h"
+#include "wtf/text/StringBuffer.h"
 #include "wtf/text/StringBuilder.h"
 
 using namespace icu;
@@ -83,9 +84,9 @@
     ASSERT(U_SUCCESS(status) || status == U_BUFFER_OVERFLOW_ERROR);
     if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR)
         return String();
-    Vector<UChar> buffer(bufferLength);
+    StringBuffer<UChar> buffer(bufferLength);
     status = U_ZERO_ERROR;
-    unum_getSymbol(m_numberFormat, symbol, buffer.data(), bufferLength, &status);
+    unum_getSymbol(m_numberFormat, symbol, buffer.characters(), bufferLength, &status);
     if (U_FAILURE(status))
         return String();
     return String::adopt(buffer);
@@ -98,9 +99,9 @@
     ASSERT(U_SUCCESS(status) || status == U_BUFFER_OVERFLOW_ERROR);
     if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR)
         return String();
-    Vector<UChar> buffer(bufferLength);
+    StringBuffer<UChar> buffer(bufferLength);
     status = U_ZERO_ERROR;
-    unum_getTextAttribute(m_numberFormat, tag, buffer.data(), bufferLength, &status);
+    unum_getTextAttribute(m_numberFormat, tag, buffer.characters(), bufferLength, &status);
     ASSERT(U_SUCCESS(status));
     if (U_FAILURE(status))
         return String();
@@ -159,9 +160,9 @@
     int32_t length = udat_toPattern(dateFormat, TRUE, 0, 0, &status);
     if (status != U_BUFFER_OVERFLOW_ERROR || !length)
         return emptyString();
-    Vector<UChar> buffer(length);
+    StringBuffer<UChar> buffer(length);
     status = U_ZERO_ERROR;
-    udat_toPattern(dateFormat, TRUE, buffer.data(), length, &status);
+    udat_toPattern(dateFormat, TRUE, buffer.characters(), length, &status);
     if (U_FAILURE(status))
         return emptyString();
     return String::adopt(buffer);
@@ -181,9 +182,9 @@
         int32_t length = udat_getSymbols(dateFormat, type, startIndex + i, 0, 0, &status);
         if (status != U_BUFFER_OVERFLOW_ERROR)
             return PassOwnPtr<Vector<String> >();
-        Vector<UChar> buffer(length);
+        StringBuffer<UChar> buffer(length);
         status = U_ZERO_ERROR;
-        udat_getSymbols(dateFormat, type, startIndex + i, buffer.data(), length, &status);
+        udat_getSymbols(dateFormat, type, startIndex + i, buffer.characters(), length, &status);
         if (U_FAILURE(status))
             return PassOwnPtr<Vector<String> >();
         labels->append(String::adopt(buffer));
@@ -327,9 +328,9 @@
     skeleton.appendTo(skeletonCharacters);
     int32_t length = udatpg_getBestPattern(patternGenerator, skeletonCharacters.data(), skeletonCharacters.size(), 0, 0, &status);
     if (status == U_BUFFER_OVERFLOW_ERROR && length) {
-        Vector<UChar> buffer(length);
+        StringBuffer<UChar> buffer(length);
         status = U_ZERO_ERROR;
-        udatpg_getBestPattern(patternGenerator, skeletonCharacters.data(), skeletonCharacters.size(), buffer.data(), length, &status);
+        udatpg_getBestPattern(patternGenerator, skeletonCharacters.data(), skeletonCharacters.size(), buffer.characters(), length, &status);
         if (U_SUCCESS(status))
             format = String::adopt(buffer);
     }
diff --git a/Source/core/rendering/EllipsisBox.cpp b/Source/core/rendering/EllipsisBox.cpp
index c5cb7cf..7dcc2a9 100644
--- a/Source/core/rendering/EllipsisBox.cpp
+++ b/Source/core/rendering/EllipsisBox.cpp
@@ -48,7 +48,7 @@
 
         // Select the correct color for painting the text.
         Color foreground = paintInfo.forceBlackText() ? Color::black : renderer()->selectionForegroundColor();
-        if (foreground.isValid() && foreground != styleTextColor)
+        if (foreground != Color::transparent && foreground != styleTextColor)
             context->setFillColor(foreground);
     }
 
@@ -61,7 +61,8 @@
             int shadowX = isHorizontal() ? shadow->x() : shadow->y();
             int shadowY = isHorizontal() ? shadow->y() : -shadow->x();
             FloatSize offset(shadowX, shadowY);
-            drawLooper.addShadow(offset, shadow->blur(), m_renderer->resolveColor(shadow->color()),
+            drawLooper.addShadow(offset, shadow->blur(),
+                m_renderer->resolveColor(shadow->color(), Color::stdShadowColor),
                 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha);
         } while ((shadow = shadow->next()));
         drawLooper.addUnmodifiedContent();
@@ -131,7 +132,7 @@
 {
     Color textColor = m_renderer->resolveColor(style, CSSPropertyColor);
     Color c = m_renderer->selectionBackgroundColor();
-    if (!c.isValid() || !c.alpha())
+    if (!c.alpha())
         return;
 
     // If the text color ends up being the same as the selection background, invert the selection
diff --git a/Source/core/rendering/InlineTextBox.cpp b/Source/core/rendering/InlineTextBox.cpp
index 5b36f6d..64045a8 100644
--- a/Source/core/rendering/InlineTextBox.cpp
+++ b/Source/core/rendering/InlineTextBox.cpp
@@ -409,7 +409,8 @@
             int shadowX = horizontal ? shadow->x() : shadow->y();
             int shadowY = horizontal ? shadow->y() : -shadow->x();
             FloatSize offset(shadowX, shadowY);
-            drawLooper.addShadow(offset, shadow->blur(), renderer->resolveColor(shadow->color()),
+            drawLooper.addShadow(offset, shadow->blur(),
+                renderer->resolveColor(shadow->color(), Color::stdShadowColor),
                 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha);
         } while ((shadow = shadow->next()));
         drawLooper.addUnmodifiedContent();
@@ -599,14 +600,14 @@
     if (haveSelection) {
         // Check foreground color first.
         Color foreground = paintInfo.forceBlackText() ? Color::black : renderer()->selectionForegroundColor();
-        if (foreground.isValid() && foreground != selectionFillColor) {
+        if (foreground != Color::transparent && foreground != selectionFillColor) {
             if (!paintSelectedTextOnly)
                 paintSelectedTextSeparately = true;
             selectionFillColor = foreground;
         }
 
         Color emphasisMarkForeground = paintInfo.forceBlackText() ? Color::black : renderer()->selectionEmphasisMarkColor();
-        if (emphasisMarkForeground.isValid() && emphasisMarkForeground != selectionEmphasisMarkColor) {
+        if (emphasisMarkForeground != Color::transparent && emphasisMarkForeground != selectionEmphasisMarkColor) {
             if (!paintSelectedTextOnly)
                 paintSelectedTextSeparately = true;
             selectionEmphasisMarkColor = emphasisMarkForeground;
@@ -845,7 +846,7 @@
         return;
 
     Color c = renderer()->selectionBackgroundColor();
-    if (!c.isValid() || c.alpha() == 0)
+    if (!c.alpha())
         return;
 
     // If the text color ends up being the same as the selection background, invert the selection
@@ -1139,7 +1140,8 @@
             }
             int shadowX = isHorizontal() ? shadow->x() : shadow->y();
             int shadowY = isHorizontal() ? shadow->y() : -shadow->x();
-            context->setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow->blur(), shadow->color());
+            context->setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow->blur(),
+                renderer()->resolveColor(shadow->color(), Color::stdShadowColor));
             shadow = shadow->next();
         }
 
diff --git a/Source/core/rendering/OrderIterator.cpp b/Source/core/rendering/OrderIterator.cpp
index 4d19918..d55779c 100644
--- a/Source/core/rendering/OrderIterator.cpp
+++ b/Source/core/rendering/OrderIterator.cpp
@@ -38,8 +38,7 @@
 OrderIterator::OrderIterator(const RenderBox* containerBox)
     : m_containerBox(containerBox)
     , m_currentChild(0)
-    , m_currentOrderIndex(0)
-    , m_currentChildIndex(0)
+    , m_orderValuesIterator(0)
 {
 }
 
@@ -51,60 +50,73 @@
 
 RenderBox* OrderIterator::next()
 {
-    for (; m_currentOrderIndex < m_orderValues.size(); ++m_currentOrderIndex) {
-        const Vector<RenderBox*>& currentOrderChildren = m_orderedValues.get(m_orderValues[m_currentOrderIndex]);
-        ASSERT(!currentOrderChildren.isEmpty());
-        for (; m_currentChildIndex < currentOrderChildren.size(); ++m_currentChildIndex) {
-            m_currentChild = currentOrderChildren[m_currentChildIndex];
-            ++m_currentChildIndex;
-            return m_currentChild;
+    do {
+        if (!m_currentChild) {
+            if (m_orderValuesIterator == m_orderValues.end())
+                return 0;
+            if (m_orderValuesIterator) {
+                ++m_orderValuesIterator;
+                if (m_orderValuesIterator == m_orderValues.end())
+                    return 0;
+            } else {
+                m_orderValuesIterator = m_orderValues.begin();
+            }
+
+            m_currentChild = m_containerBox->firstChildBox();
+        } else {
+            m_currentChild = m_currentChild->nextSiblingBox();
         }
+    } while (!m_currentChild || m_currentChild->style()->order() != *m_orderValuesIterator);
 
-        m_currentChildIndex = 0;
-    }
-
-    m_currentChild = 0;
     return m_currentChild;
 }
 
 void OrderIterator::reset()
 {
-    m_currentOrderIndex = 0;
-    m_currentChildIndex = 0;
     m_currentChild = 0;
-}
-
-void OrderIterator::invalidate()
-{
-    // Note that we don't release the memory here, we only invalidate the size.
-    // This avoids unneeded reallocation if the size ends up not changing.
-    m_orderValues.shrink(0);
-    m_orderedValues.clear();
-
-    reset();
+    m_orderValuesIterator = 0;
 }
 
 OrderIteratorPopulator::~OrderIteratorPopulator()
 {
     m_iterator.reset();
 
-    std::sort(m_iterator.m_orderValues.begin(), m_iterator.m_orderValues.end());
+    if (m_anyChildHasDefaultOrderValue)
+        m_iterator.m_orderValues.append(0);
+
+    if (m_iterator.m_orderValues.size() > 1)
+        removeDuplicatedOrderValues();
 
     // Ensure that we release any extra memory we hold onto.
     m_iterator.m_orderValues.shrinkToFit();
 }
 
-void OrderIteratorPopulator::collectChild(RenderBox* child)
+void OrderIteratorPopulator::removeDuplicatedOrderValues()
 {
-    int order = child->style()->order();
+    OrderIterator::OrderValues& orderValues = m_iterator.m_orderValues;
 
-    // FIXME: Ideally we would want to avoid inserting into the HashMap for the common case where there are only items
-    // with the default 'order' 0. The current API is designed to blend into a single iteration which makes having a
-    // slower fallback difficult without having to store the children (grid items may not be contiguous in DOM order).
-    OrderIterator::OrderedValuesMap::AddResult result = m_iterator.m_orderedValues.add(order, Vector<RenderBox*>());
-    result.iterator->value.append(child);
-    if (result.isNewEntry)
+    std::sort(orderValues.begin(), orderValues.end());
+
+    int previous = orderValues[0];
+    size_t uniqueItemIndex = 0;
+    for (size_t i = 1; i < orderValues.size(); ++i) {
+        int current = orderValues[i];
+        if (current == previous)
+            continue;
+        ++uniqueItemIndex;
+        std::swap(orderValues[i], orderValues[uniqueItemIndex]);
+        previous = current;
+    }
+    orderValues.shrink(uniqueItemIndex + 1);
+}
+
+void OrderIteratorPopulator::collectChild(const RenderBox* child)
+{
+    // Avoid growing the vector for the common-case default value of 0.
+    if (int order = child->style()->order())
         m_iterator.m_orderValues.append(order);
+    else
+        m_anyChildHasDefaultOrderValue = true;
 }
 
 } // namespace WebCore
diff --git a/Source/core/rendering/OrderIterator.h b/Source/core/rendering/OrderIterator.h
index ad1f795..8639bdc 100644
--- a/Source/core/rendering/OrderIterator.h
+++ b/Source/core/rendering/OrderIterator.h
@@ -31,7 +31,6 @@
 #ifndef OrderIterator_h
 #define OrderIterator_h
 
-#include "wtf/HashMap.h"
 #include "wtf/Noncopyable.h"
 #include "wtf/Vector.h"
 
@@ -39,16 +38,6 @@
 
 class RenderBox;
 
-// Normally, -1 and 0 are not valid in a HashSet, but these are relatively likel y order: values. Instead,
-// we make the two smallest int values invalid order: values (in the css parser code we clamp them to
-// int min + 2).
-struct OrdererValueMapKeyHashTraits : WTF::GenericHashTraits<int> {
-    static const bool emptyValueIsZero = false;
-    static int emptyValue() { return std::numeric_limits<int>::min(); }
-    static void constructDeletedValue(int& slot) { slot = std::numeric_limits<int>::min() + 1; }
-    static bool isDeletedValue(int value) { return value == std::numeric_limits<int>::min() + 1; }
-};
-
 class OrderIterator {
     WTF_MAKE_NONCOPYABLE(OrderIterator);
 public:
@@ -61,39 +50,36 @@
     RenderBox* next();
     void reset();
 
-    void invalidate();
-
 private:
     const RenderBox* m_containerBox;
-
+    RenderBox* m_currentChild;
     // The inline capacity for a single item is used to cover the most
     // common case by far: if we only have the default 'order' value 0.
     typedef Vector<int, 1> OrderValues;
     OrderValues m_orderValues;
-
-    RenderBox* m_currentChild;
-    size_t m_currentOrderIndex;
-    size_t m_currentChildIndex;
-
-    // This HashMap is empty if there is only one value.
-    typedef HashMap<int, Vector<RenderBox*>, DefaultHash<int>::Hash, OrdererValueMapKeyHashTraits > OrderedValuesMap;
-    OrderedValuesMap m_orderedValues;
+    Vector<int>::const_iterator m_orderValuesIterator;
 };
 
 class OrderIteratorPopulator {
 public:
     OrderIteratorPopulator(OrderIterator& iterator)
         : m_iterator(iterator)
+        , m_anyChildHasDefaultOrderValue(false)
     {
-        m_iterator.invalidate();
+        // Note that we don't release the memory here, we only invalidate the size.
+        // This avoids unneeded reallocation if the size ends up not changing.
+        m_iterator.m_orderValues.shrink(0);
     }
 
     ~OrderIteratorPopulator();
 
-    void collectChild(RenderBox*);
+    void collectChild(const RenderBox*);
 
 private:
+    void removeDuplicatedOrderValues();
+
     OrderIterator& m_iterator;
+    bool m_anyChildHasDefaultOrderValue;
 };
 
 } // namespace WebCore
diff --git a/Source/core/rendering/RenderBlock.cpp b/Source/core/rendering/RenderBlock.cpp
index 3304856..ae65a06 100644
--- a/Source/core/rendering/RenderBlock.cpp
+++ b/Source/core/rendering/RenderBlock.cpp
@@ -5916,6 +5916,8 @@
     m_minPreferredLogicalWidth = 0;
     m_maxPreferredLogicalWidth = 0;
 
+    // FIXME: The isFixed() calls here should probably be checking for isSpecified since you
+    // should be able to use percentage, calc or viewport relative values for width.
     RenderStyle* styleToUse = style();
     if (!isTableCell() && styleToUse->logicalWidth().isFixed() && styleToUse->logicalWidth().value() >= 0 
         && !(isDeprecatedFlexItem() && !styleToUse->logicalWidth().intValue()))
diff --git a/Source/core/rendering/RenderBox.cpp b/Source/core/rendering/RenderBox.cpp
index f631c5c..12360ed 100644
--- a/Source/core/rendering/RenderBox.cpp
+++ b/Source/core/rendering/RenderBox.cpp
@@ -1171,7 +1171,7 @@
     ASSERT(hasBackground());
     LayoutRect backgroundRect = pixelSnappedIntRect(borderBoxRect());
 
-    Color backgroundColor = resolveColor(CSSPropertyBackgroundColor);
+    StyleColor backgroundColor = resolveStyleColor(CSSPropertyBackgroundColor);
     if (backgroundColor.isValid() && backgroundColor.alpha())
         return backgroundRect;
     if (!style()->backgroundLayers()->image() || style()->backgroundLayers()->next())
@@ -1186,7 +1186,7 @@
     if (isBody() && skipBodyBackground(this))
         return false;
 
-    Color backgroundColor = resolveColor(CSSPropertyBackgroundColor);
+    StyleColor backgroundColor = resolveStyleColor(CSSPropertyBackgroundColor);
     if (!backgroundColor.isValid() || backgroundColor.hasAlpha())
         return false;
 
@@ -1304,7 +1304,7 @@
 
     // If there is only one layer and no image, check whether the background color is opaque
     if (!fillLayer->next() && !fillLayer->hasImage()) {
-        Color bgColor = resolveColor(CSSPropertyBackgroundColor);
+        StyleColor bgColor = resolveStyleColor(CSSPropertyBackgroundColor);
         if (bgColor.isValid() && bgColor.alpha() == 255)
             return true;
     }
diff --git a/Source/core/rendering/RenderBoxModelObject.cpp b/Source/core/rendering/RenderBoxModelObject.cpp
index ff4cf63..e7b605f 100644
--- a/Source/core/rendering/RenderBoxModelObject.cpp
+++ b/Source/core/rendering/RenderBoxModelObject.cpp
@@ -556,14 +556,14 @@
     // while rendering.)
     if (forceBackgroundToWhite) {
         // Note that we can't reuse this variable below because the bgColor might be changed
-        bool shouldPaintBackgroundColor = !bgLayer->next() && bgColor.isValid() && bgColor.alpha();
+        bool shouldPaintBackgroundColor = !bgLayer->next() && bgColor.alpha();
         if (shouldPaintBackgroundImage || shouldPaintBackgroundColor) {
             bgColor = Color::white;
             shouldPaintBackgroundImage = false;
         }
     }
 
-    bool colorVisible = bgColor.isValid() && bgColor.alpha();
+    bool colorVisible = bgColor.alpha();
 
     // Fast path for drawing simple color backgrounds.
     if (!isRoot && !clippedWithLocalScrolling && !shouldPaintBackgroundImage && isBorderFill && !bgLayer->next()) {
@@ -673,7 +673,7 @@
     bool isOpaqueRoot = false;
     if (isRoot) {
         isOpaqueRoot = true;
-        if (!bgLayer->next() && !(bgColor.isValid() && bgColor.alpha() == 255) && view()->frameView()) {
+        if (!bgLayer->next() && !(bgColor.alpha() == 255) && view()->frameView()) {
             Element* ownerElement = document()->ownerElement();
             if (ownerElement) {
                 if (!ownerElement->hasTagName(frameTag)) {
@@ -2375,7 +2375,7 @@
         return false;
 
     Color backgroundColor = resolveColor(CSSPropertyBackgroundColor);
-    if (!backgroundColor.isValid() || backgroundColor.hasAlpha())
+    if (backgroundColor.hasAlpha())
         return false;
 
     const FillLayer* lastBackgroundLayer = style()->backgroundLayers();
@@ -2436,7 +2436,7 @@
         if (shadowOffset.isZero() && !shadowBlur && !shadowSpread)
             continue;
         
-        const Color& shadowColor = resolveColor(shadow->color());
+        const Color& shadowColor = resolveColor(shadow->color(), Color::stdShadowColor);
 
         if (shadow->style() == Normal) {
             RoundedRect fillRect = border;
diff --git a/Source/core/rendering/RenderButton.h b/Source/core/rendering/RenderButton.h
index 036cfb5..cca80bb 100644
--- a/Source/core/rendering/RenderButton.h
+++ b/Source/core/rendering/RenderButton.h
@@ -48,6 +48,9 @@
 
     void setupInnerStyle(RenderStyle*);
 
+    // <button> should allow whitespace even though RenderFlexibleBox doesn't.
+    virtual bool canHaveWhitespaceChildren() const OVERRIDE { return true; }
+
     virtual bool canHaveGeneratedChildren() const OVERRIDE;
     virtual bool hasControlClip() const { return true; }
     virtual LayoutRect controlClipRect(const LayoutPoint&) const;
diff --git a/Source/core/rendering/RenderFileUploadControl.cpp b/Source/core/rendering/RenderFileUploadControl.cpp
index ff4e5f1..b956709 100644
--- a/Source/core/rendering/RenderFileUploadControl.cpp
+++ b/Source/core/rendering/RenderFileUploadControl.cpp
@@ -30,7 +30,6 @@
 #include "core/html/HTMLInputElement.h"
 #include "core/platform/graphics/Font.h"
 #include "core/platform/graphics/GraphicsContextStateSaver.h"
-#include "core/platform/graphics/Icon.h"
 #include "core/platform/graphics/TextRun.h"
 #include "core/rendering/PaintInfo.h"
 #include "core/rendering/RenderButton.h"
@@ -43,9 +42,6 @@
 using namespace HTMLNames;
 
 const int afterButtonSpacing = 4;
-const int iconHeight = 16;
-const int iconWidth = 16;
-const int iconFilenameSpacing = 2;
 const int defaultWidthNumChars = 34;
 const int buttonShadowHeight = 2;
 
@@ -93,8 +89,7 @@
 int RenderFileUploadControl::maxFilenameWidth() const
 {
     HTMLInputElement* input = toHTMLInputElement(node());
-    return max(0, contentBoxRect().pixelSnappedWidth() - nodeWidth(uploadButton()) - afterButtonSpacing
-        - (input->icon() ? iconWidth + iconFilenameSpacing : 0));
+    return max(0, contentBoxRect().pixelSnappedWidth() - nodeWidth(uploadButton()) - afterButtonSpacing);
 }
 
 void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
@@ -127,14 +122,13 @@
 
         HTMLInputElement* input = toHTMLInputElement(node());
         LayoutUnit buttonWidth = nodeWidth(button);
-        LayoutUnit buttonAndIconWidth = buttonWidth + afterButtonSpacing
-            + (input->icon() ? iconWidth + iconFilenameSpacing : 0);
+        LayoutUnit buttonAndSpacingWidth = buttonWidth + afterButtonSpacing;
         float textWidth = font.width(textRun);
         LayoutUnit textX;
         if (style()->isLeftToRightDirection())
-            textX = contentLeft + buttonAndIconWidth;
+            textX = contentLeft + buttonAndSpacingWidth;
         else
-            textX = contentLeft + contentWidth() - buttonAndIconWidth - textWidth;
+            textX = contentLeft + contentWidth() - buttonAndSpacingWidth - textWidth;
 
         LayoutUnit textY = 0;
         // We want to match the button's baseline
@@ -153,19 +147,6 @@
 
         // Draw the filename
         paintInfo.context->drawBidiText(font, textRunPaintInfo, IntPoint(roundToInt(textX), roundToInt(textY)));
-
-        if (input->icon()) {
-            // Determine where the icon should be placed
-            LayoutUnit iconY = paintOffset.y() + borderTop() + paddingTop() + (contentHeight() - iconHeight) / 2;
-            LayoutUnit iconX;
-            if (style()->isLeftToRightDirection())
-                iconX = contentLeft + buttonWidth + afterButtonSpacing;
-            else
-                iconX = contentLeft + contentWidth() - buttonWidth - afterButtonSpacing - iconWidth;
-
-            // Draw the file icon
-            input->icon()->paint(paintInfo.context, IntRect(roundToInt(iconX), roundToInt(iconY), iconWidth, iconHeight));
-        }
     }
 
     // Paint the children.
diff --git a/Source/core/rendering/RenderFlexibleBox.cpp b/Source/core/rendering/RenderFlexibleBox.cpp
index 62f6d97..b544fd1 100644
--- a/Source/core/rendering/RenderFlexibleBox.cpp
+++ b/Source/core/rendering/RenderFlexibleBox.cpp
@@ -144,38 +144,6 @@
     minLogicalWidth += scrollbarWidth;
 }
 
-void RenderFlexibleBox::computePreferredLogicalWidths()
-{
-    ASSERT(preferredLogicalWidthsDirty());
-
-    m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = 0;
-
-    RenderStyle* styleToUse = style();
-    // FIXME: This should probably be checking for isSpecified since you should be able to use percentage, calc or viewport relative values for width.
-    if (styleToUse->logicalWidth().isFixed() && styleToUse->logicalWidth().value() > 0)
-        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalWidth().value());
-    else
-        computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
-
-    // FIXME: This should probably be checking for isSpecified since you should be able to use percentage, calc or viewport relative values for min-width.
-    if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth().value() > 0) {
-        m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value()));
-        m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value()));
-    }
-
-    // FIXME: This should probably be checking for isSpecified since you should be able to use percentage, calc or viewport relative values for maxWidth.
-    if (styleToUse->logicalMaxWidth().isFixed()) {
-        m_maxPreferredLogicalWidth = std::min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
-        m_minPreferredLogicalWidth = std::min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
-    }
-
-    LayoutUnit borderAndPadding = borderAndPaddingLogicalWidth();
-    m_minPreferredLogicalWidth += borderAndPadding;
-    m_maxPreferredLogicalWidth += borderAndPadding;
-
-    setPreferredLogicalWidthsDirty(false);
-}
-
 static int synthesizedBaselineFromContentBox(const RenderBox* box, LineDirectionMode direction)
 {
     return direction == HorizontalLine ? box->borderTop() + box->paddingTop() + box->contentHeight() : box->borderRight() + box->paddingRight() + box->contentWidth();
@@ -265,13 +233,6 @@
     }
 }
 
-void RenderFlexibleBox::removeChild(RenderObject* child)
-{
-    m_orderIterator.invalidate();
-
-    RenderBlock::removeChild(child);
-}
-
 void RenderFlexibleBox::layoutBlock(bool relayoutChildren, LayoutUnit)
 {
     ASSERT(needsLayout());
diff --git a/Source/core/rendering/RenderFlexibleBox.h b/Source/core/rendering/RenderFlexibleBox.h
index a1c21be..b147b24 100644
--- a/Source/core/rendering/RenderFlexibleBox.h
+++ b/Source/core/rendering/RenderFlexibleBox.h
@@ -60,12 +60,9 @@
 
 protected:
     virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE;
-    virtual void computePreferredLogicalWidths() OVERRIDE;
 
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
 
-    virtual void removeChild(RenderObject* child) OVERRIDE;
-
 private:
     enum FlexSign {
         PositiveFlexibility,
diff --git a/Source/core/rendering/RenderGrid.cpp b/Source/core/rendering/RenderGrid.cpp
index a93d2f8..837e189 100644
--- a/Source/core/rendering/RenderGrid.cpp
+++ b/Source/core/rendering/RenderGrid.cpp
@@ -33,7 +33,7 @@
 
 namespace WebCore {
 
-static const int infinity = intMaxForLayoutUnit;
+static const int infinity = -1;
 
 class GridTrack {
 public:
@@ -252,13 +252,6 @@
     setPreferredLogicalWidthsDirty(false);
 }
 
-void RenderGrid::removeChild(RenderObject* child)
-{
-    m_orderIterator.invalidate();
-
-    RenderBlock::removeChild(child);
-}
-
 LayoutUnit RenderGrid::computePreferredTrackWidth(const GridLength& gridLength, size_t trackIndex) const
 {
     if (gridLength.isFlex())
@@ -361,8 +354,7 @@
     ASSERT(!trackLength.isAuto());
     if (trackLength.isFixed() || trackLength.isPercent() || trackLength.isViewportPercentage()) {
         LayoutUnit computedBreadth = computeUsedBreadthOfSpecifiedLength(direction, trackLength);
-        // FIXME: We should ASSERT that computedBreadth cannot return infinity but it's currently
-        // possible. See https://bugs.webkit.org/show_bug.cgi?id=107053
+        ASSERT(computedBreadth != infinity);
         return computedBreadth;
     }
 
diff --git a/Source/core/rendering/RenderGrid.h b/Source/core/rendering/RenderGrid.h
index 894f4f5..eddf270 100644
--- a/Source/core/rendering/RenderGrid.h
+++ b/Source/core/rendering/RenderGrid.h
@@ -59,8 +59,6 @@
     virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE;
     virtual void computePreferredLogicalWidths() OVERRIDE;
 
-    virtual void removeChild(RenderObject* child) OVERRIDE FINAL;
-
     LayoutUnit computePreferredTrackWidth(const GridLength&, size_t) const;
 
     class GridIterator;
diff --git a/Source/core/rendering/RenderLayer.cpp b/Source/core/rendering/RenderLayer.cpp
index 04e4a26..a7133a9 100644
--- a/Source/core/rendering/RenderLayer.cpp
+++ b/Source/core/rendering/RenderLayer.cpp
@@ -176,23 +176,12 @@
     // there is no need to dirty / recompute these lists.
     m_zOrderListsDirty = isStackingContainer();
 
-    ScrollableArea::setConstrainsScrollingToContentEdge(false);
-
     if (!renderer->firstChild() && renderer->style()) {
         m_visibleContentStatusDirty = false;
         m_hasVisibleContent = renderer->style()->visibility() == VISIBLE;
     }
 
-    Node* node = renderer->node();
-    if (node && node->isElementNode()) {
-        // We save and restore only the scrollOffset as the other scroll values are recalculated.
-        Element* element = toElement(node);
-        m_scrollOffset = element->savedLayerScrollOffset();
-        if (!m_scrollOffset.isZero())
-            scrollAnimator()->setCurrentPosition(FloatPoint(m_scrollOffset.width(), m_scrollOffset.height()));
-        element->setSavedLayerScrollOffset(IntSize());
-    }
-
+    updateScrollableArea();
     updateResizerAreaSet();
 }
 
@@ -204,10 +193,8 @@
     }
 
     if (Frame* frame = renderer()->frame()) {
-        if (FrameView* frameView = frame->view()) {
-            frameView->removeScrollableArea(this);
+        if (FrameView* frameView = frame->view())
             frameView->removeResizerArea(this);
-        }
     }
 
     if (!m_renderer->documentBeingDestroyed()) {
@@ -222,11 +209,6 @@
     destroyScrollbar(HorizontalScrollbar);
     destroyScrollbar(VerticalScrollbar);
 
-    if (renderer()->frame() && renderer()->frame()->page()) {
-        if (ScrollingCoordinator* scrollingCoordinator = renderer()->frame()->page()->scrollingCoordinator())
-            scrollingCoordinator->willDestroyScrollableArea(this);
-    }
-
     if (m_reflection)
         removeReflection();
 
@@ -515,7 +497,7 @@
         return;
 
     FrameView* frameView = renderer()->view()->frameView();
-    if (!frameView || !frameView->containsScrollableArea(this))
+    if (!frameView || !frameView->containsScrollableArea(scrollableArea()))
         return;
 
     RenderLayer* ancestorStackingContext = this->ancestorStackingContext();
@@ -1960,7 +1942,7 @@
     updateCanBeStackingContainer();
     updateDescendantDependentFlags();
 
-    ASSERT(renderer()->view()->frameView() && renderer()->view()->frameView()->containsScrollableArea(this));
+    ASSERT(renderer()->view()->frameView() && renderer()->view()->frameView()->containsScrollableArea(scrollableArea()));
     bool needsCompositedScrolling = acceleratedCompositingForOverflowScrollEnabled()
         && canBeStackingContainer()
         && !hasUnclippedDescendant();
@@ -2108,7 +2090,7 @@
 {
     IntSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffset(scrollOffset) : scrollOffset;
     if (newScrollOffset != adjustedScrollOffset())
-        scrollToOffsetWithoutAnimation(-scrollOrigin() + newScrollOffset);
+        m_scrollableArea->scrollToOffsetWithoutAnimation(-scrollOrigin() + newScrollOffset);
 }
 
 void RenderLayer::setScrollOffset(const IntPoint& newScrollOffset)
@@ -2446,23 +2428,23 @@
     if (resize != RESIZE_VERTICAL && difference.width()) {
         if (element->isFormControlElement()) {
             // Make implicit margins from the theme explicit (see <http://bugs.webkit.org/show_bug.cgi?id=9547>).
-            element->setInlineStyleProperty(CSSPropertyMarginLeft, String::number(renderer->marginLeft() / zoomFactor) + "px", false);
-            element->setInlineStyleProperty(CSSPropertyMarginRight, String::number(renderer->marginRight() / zoomFactor) + "px", false);
+            element->setInlineStyleProperty(CSSPropertyMarginLeft, renderer->marginLeft() / zoomFactor, CSSPrimitiveValue::CSS_PX);
+            element->setInlineStyleProperty(CSSPropertyMarginRight, renderer->marginRight() / zoomFactor, CSSPrimitiveValue::CSS_PX);
         }
         LayoutUnit baseWidth = renderer->width() - (isBoxSizingBorder ? LayoutUnit() : renderer->borderAndPaddingWidth());
         baseWidth = baseWidth / zoomFactor;
-        element->setInlineStyleProperty(CSSPropertyWidth, String::number(roundToInt(baseWidth + difference.width())) + "px", false);
+        element->setInlineStyleProperty(CSSPropertyWidth, roundToInt(baseWidth + difference.width()), CSSPrimitiveValue::CSS_PX);
     }
 
     if (resize != RESIZE_HORIZONTAL && difference.height()) {
         if (element->isFormControlElement()) {
             // Make implicit margins from the theme explicit (see <http://bugs.webkit.org/show_bug.cgi?id=9547>).
-            element->setInlineStyleProperty(CSSPropertyMarginTop, String::number(renderer->marginTop() / zoomFactor) + "px", false);
-            element->setInlineStyleProperty(CSSPropertyMarginBottom, String::number(renderer->marginBottom() / zoomFactor) + "px", false);
+            element->setInlineStyleProperty(CSSPropertyMarginTop, renderer->marginTop() / zoomFactor, CSSPrimitiveValue::CSS_PX);
+            element->setInlineStyleProperty(CSSPropertyMarginBottom, renderer->marginBottom() / zoomFactor, CSSPrimitiveValue::CSS_PX);
         }
         LayoutUnit baseHeight = renderer->height() - (isBoxSizingBorder ? LayoutUnit() : renderer->borderAndPaddingHeight());
         baseHeight = baseHeight / zoomFactor;
-        element->setInlineStyleProperty(CSSPropertyHeight, String::number(roundToInt(baseHeight + difference.height())) + "px", false);
+        element->setInlineStyleProperty(CSSPropertyHeight, roundToInt(baseHeight + difference.height()), CSSPrimitiveValue::CSS_PX);
     }
 
     document->updateLayout();
@@ -2506,11 +2488,11 @@
     return -scrollOrigin() + enclosingIntRect(overflowRect).size() - enclosingIntRect(box->clientBoxRect()).size();
 }
 
-IntRect RenderLayer::visibleContentRect(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
+IntRect RenderLayer::visibleContentRect(ScrollableArea::VisibleContentRectIncludesScrollbars scrollbarInclusion) const
 {
     int verticalScrollbarWidth = 0;
     int horizontalScrollbarHeight = 0;
-    if (scrollbarInclusion == IncludeScrollbars) {
+    if (scrollbarInclusion == ScrollableArea::IncludeScrollbars) {
         verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar()) ? verticalScrollbar()->width() : 0;
         horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0;
     }
@@ -2813,13 +2795,13 @@
     RenderObject* actualRenderer = rendererForScrollbar(renderer());
     bool hasCustomScrollbarStyle = actualRenderer->isBox() && actualRenderer->style()->hasPseudoStyle(SCROLLBAR);
     if (hasCustomScrollbarStyle)
-        widget = RenderScrollbar::createCustomScrollbar(this, orientation, actualRenderer->node());
+        widget = RenderScrollbar::createCustomScrollbar(scrollableArea(), orientation, actualRenderer->node());
     else {
-        widget = Scrollbar::createNativeScrollbar(this, orientation, RegularScrollbar);
+        widget = Scrollbar::createNativeScrollbar(scrollableArea(), orientation, RegularScrollbar);
         if (orientation == HorizontalScrollbar)
-            didAddHorizontalScrollbar(widget.get());
+            scrollableArea()->didAddHorizontalScrollbar(widget.get());
         else 
-            didAddVerticalScrollbar(widget.get());
+            scrollableArea()->didAddVerticalScrollbar(widget.get());
     }
     renderer()->document()->view()->addChild(widget.get());        
     return widget.release();
@@ -2833,9 +2815,9 @@
 
     if (!scrollbar->isCustomScrollbar()) {
         if (orientation == HorizontalScrollbar)
-            willRemoveHorizontalScrollbar(scrollbar.get());
+            scrollableArea()->willRemoveHorizontalScrollbar(scrollbar.get());
         else
-            willRemoveVerticalScrollbar(scrollbar.get());
+            scrollableArea()->willRemoveVerticalScrollbar(scrollbar.get());
     }
 
     scrollbar->removeFromParent();
@@ -2896,7 +2878,7 @@
 ScrollableArea* RenderLayer::enclosingScrollableArea() const
 {
     if (RenderLayer* scrollableLayer = enclosingScrollableLayer())
-        return scrollableLayer;
+        return scrollableLayer->scrollableArea();
 
     // FIXME: We should return the frame view here (or possibly an ancestor frame view,
     // if the frame view isn't scrollable.
@@ -3027,7 +3009,7 @@
 
     int scrollableLeftOverflow = overflowLeft() - box->borderLeft();
     int scrollableTopOverflow = overflowTop() - box->borderTop();
-    setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow));
+    m_scrollableArea->setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow));
 }
 
 bool RenderLayer::hasScrollableHorizontalOverflow() const
@@ -3145,7 +3127,7 @@
     updateScrollbarsAfterLayout();
 
     if (originalScrollOffset != adjustedScrollOffset())
-        scrollToOffsetWithoutAnimation(-scrollOrigin() + adjustedScrollOffset());
+        scrollableArea()->scrollToOffsetWithoutAnimation(-scrollOrigin() + adjustedScrollOffset());
 
     // Composited scrolling may need to be enabled or disabled if the amount of overflow changed.
     if (renderer()->view() && compositor()->updateLayerCompositingState(this))
@@ -3389,7 +3371,10 @@
 
 bool RenderLayer::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
 {
-    return ScrollableArea::scroll(direction, granularity, multiplier);
+    if (ScrollableArea* scrollableArea = this->scrollableArea())
+        return scrollableArea->scroll(direction, granularity, multiplier);
+
+    return false;
 }
 
 void RenderLayer::paint(GraphicsContext* context, const LayoutRect& damageRect, PaintBehavior paintBehavior, RenderObject* paintingRoot, RenderRegion* region, PaintLayerFlags paintFlags)
@@ -6061,6 +6046,7 @@
 {
     updateIsNormalFlowOnly();
 
+    updateScrollableArea();
     updateResizerAreaSet();
     updateScrollbarsAfterStyleChange(oldStyle);
     updateStackingContextsAfterStyleChange(oldStyle);
@@ -6110,6 +6096,16 @@
         backing()->updateGraphicsLayerGeometry();
 }
 
+void RenderLayer::updateScrollableArea()
+{
+    // FIXME: We could lazily allocate our ScrollableArea (e.g. for overflow: auto) but for now we go with this safer approach.
+    bool requiresScrollableArea = this->requiresScrollableArea();
+    if (requiresScrollableArea && !m_scrollableArea)
+        m_scrollableArea = adoptPtr(new RenderLayerScrollableArea(this));
+    else if (!requiresScrollableArea && m_scrollableArea)
+        m_scrollableArea = nullptr;
+}
+
 void RenderLayer::updateResizerAreaSet() {
     Frame* frame = renderer()->frame();
     if (!frame)
@@ -6138,10 +6134,10 @@
         isVisibleToHitTest &= owner->renderer() && owner->renderer()->visibleToHitTesting();
 
     if (hasOverflow && isVisibleToHitTest) {
-        if (frameView->addScrollableArea(this))
+        if (frameView->addScrollableArea(scrollableArea()))
             compositor()->setNeedsUpdateCompositingRequirementsState();
     } else {
-        if (frameView->removeScrollableArea(this))
+        if (frameView->removeScrollableArea(scrollableArea()))
             setNeedsCompositedScrolling(false);
     }
 }
@@ -6355,6 +6351,21 @@
         renderer()->repaint();
 }
 
+const IntPoint& RenderLayer::scrollOrigin() const
+{
+    if (!m_scrollableArea) {
+        static IntPoint emptyPoint = IntPoint::zero();
+        return emptyPoint;
+    }
+
+    return m_scrollableArea->scrollOrigin();
+}
+
+bool RenderLayer::hasOverlayScrollbars() const
+{
+    return m_scrollableArea && m_scrollableArea->hasOverlayScrollbars();
+}
+
 } // namespace WebCore
 
 #ifndef NDEBUG
diff --git a/Source/core/rendering/RenderLayer.h b/Source/core/rendering/RenderLayer.h
index 1d11d8e..528b4ce 100644
--- a/Source/core/rendering/RenderLayer.h
+++ b/Source/core/rendering/RenderLayer.h
@@ -44,10 +44,10 @@
 #ifndef RenderLayer_h
 #define RenderLayer_h
 
-#include "core/platform/ScrollableArea.h"
 #include "core/rendering/CompositingReasons.h"
 #include "core/rendering/PaintInfo.h"
 #include "core/rendering/RenderBox.h"
+#include "core/rendering/RenderLayerScrollableArea.h"
 
 #include <wtf/OwnPtr.h>
 
@@ -310,9 +310,11 @@
 
 typedef Vector<LayerFragment, 1> LayerFragments;
 
-class RenderLayer : public ScrollableArea {
+class RenderLayer {
 public:
     friend class RenderReplica;
+    // FIXME: Needed until we move all the necessary bits to the new class.
+    friend class RenderLayerScrollableArea;
 
     RenderLayer(RenderLayerModelObject*);
     ~RenderLayer();
@@ -375,13 +377,8 @@
 
     LayoutRect rect() const { return LayoutRect(location(), size()); }
 
-    enum ResizerHitTestType {
-        ResizerForPointer,
-        ResizerForTouch
-    };
-
     // See comments on isPointInResizeControl.
-    virtual IntRect resizerCornerRect(const IntRect& bounds, ResizerHitTestType resizerHitTestType) const;
+    IntRect resizerCornerRect(const IntRect& bounds, ResizerHitTestType) const;
 
     int scrollWidth() const;
     int scrollHeight() const;
@@ -418,11 +415,6 @@
     bool hasHorizontalScrollbar() const { return horizontalScrollbar(); }
     bool hasVerticalScrollbar() const { return verticalScrollbar(); }
 
-    // ScrollableArea overrides
-    virtual Scrollbar* horizontalScrollbar() const { return m_hBar.get(); }
-    virtual Scrollbar* verticalScrollbar() const { return m_vBar.get(); }
-    virtual ScrollableArea* enclosingScrollableArea() const;
-
     int verticalScrollbarWidth(OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
     int horizontalScrollbarHeight(OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
 
@@ -724,7 +716,7 @@
     bool preserves3D() const { return renderer()->style()->transformStyle3D() == TransformStyle3DPreserve3D; }
     bool has3DTransform() const { return m_transform && !m_transform->isAffine(); }
 
-    virtual void filterNeedsRepaint();
+    void filterNeedsRepaint();
     bool hasFilter() const { return renderer()->hasFilter(); }
 
     bool hasBlendMode() const;
@@ -741,11 +733,6 @@
     RenderLayerBacking* backing() const { return m_backing.get(); }
     RenderLayerBacking* ensureBacking();
     void clearBacking(bool layerBeingDestroyed = false);
-    virtual GraphicsLayer* layerForScrolling() const;
-    virtual GraphicsLayer* layerForHorizontalScrollbar() const;
-    virtual GraphicsLayer* layerForVerticalScrollbar() const;
-    virtual GraphicsLayer* layerForScrollCorner() const;
-    virtual bool usesCompositedScrolling() const OVERRIDE;
     bool needsCompositedScrolling() const;
     bool needsCompositingLayersRebuiltForClip(const RenderStyle* oldStyle, const RenderStyle* newStyle) const;
     bool needsCompositingLayersRebuiltForOverflow(const RenderStyle* oldStyle, const RenderStyle* newStyle) const;
@@ -823,7 +810,15 @@
 
     void setForceNeedsCompositedScrolling(ForceNeedsCompositedScrollingMode);
 
+    ScrollableArea* scrollableArea() const { return m_scrollableArea.get(); }
+
 private:
+    bool requiresScrollableArea() const
+    {
+        // We don't use hasOverflowClip as it is not set on a lot of cases (e.g. non-block and root).
+        return renderer()->style()->overflowX() != OVISIBLE || canResize() || usesCompositedScrolling();
+    }
+
     enum CollectLayersBehavior {
         ForceLayerToStackingContainer,
         OverflowScrollCanBeStackingContainers,
@@ -879,7 +874,6 @@
 
     void updateOutOfFlowPositioned(const RenderStyle* oldStyle);
 
-    virtual void updateNeedsCompositedScrolling() OVERRIDE;
     void setNeedsCompositedScrolling(bool);
     void didUpdateNeedsCompositedScrolling();
 
@@ -1006,32 +1000,53 @@
 
     bool shouldBeSelfPaintingLayer() const;
 
+    // Start of ScrollableArea interface
+    // To be moved to RenderLayerScrollableArea
     int scrollPosition(Scrollbar*) const;
-    
-    // ScrollableArea interface
-    virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&);
-    virtual void invalidateScrollCornerRect(const IntRect&);
-    virtual bool isActive() const;
-    virtual bool isScrollCornerVisible() const;
-    virtual IntRect scrollCornerRect() const;
-    virtual IntRect convertFromScrollbarToContainingView(const Scrollbar*, const IntRect&) const;
-    virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect&) const;
-    virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, const IntPoint&) const;
-    virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoint&) const;
-    virtual int scrollSize(ScrollbarOrientation) const;
-    virtual void setScrollOffset(const IntPoint&);
-    virtual IntPoint scrollPosition() const;
-    virtual IntPoint minimumScrollPosition() const;
-    virtual IntPoint maximumScrollPosition() const;
-    virtual IntRect visibleContentRect(VisibleContentRectIncludesScrollbars) const;
-    virtual int visibleHeight() const;
-    virtual int visibleWidth() const;
-    virtual IntSize contentsSize() const;
-    virtual IntSize overhangAmount() const;
-    virtual IntPoint lastKnownMousePosition() const;
-    virtual bool shouldSuspendScrollAnimations() const;
-    virtual bool scrollbarsCanBeActive() const;
-    virtual IntRect scrollableAreaBoundingBox() const OVERRIDE;
+
+    ScrollableArea* enclosingScrollableArea() const;
+
+    void updateNeedsCompositedScrolling();
+
+    GraphicsLayer* layerForScrolling() const;
+    GraphicsLayer* layerForHorizontalScrollbar() const;
+    GraphicsLayer* layerForVerticalScrollbar() const;
+    GraphicsLayer* layerForScrollCorner() const;
+public:
+    Scrollbar* horizontalScrollbar() const { return m_hBar.get(); }
+    Scrollbar* verticalScrollbar() const { return m_vBar.get(); }
+    bool usesCompositedScrolling() const;
+
+    bool hasOverlayScrollbars() const;
+
+private:
+    void invalidateScrollbarRect(Scrollbar*, const IntRect&);
+    void invalidateScrollCornerRect(const IntRect&);
+    bool isActive() const;
+    bool isScrollCornerVisible() const;
+    IntRect scrollCornerRect() const;
+    IntRect convertFromScrollbarToContainingView(const Scrollbar*, const IntRect&) const;
+    IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect&) const;
+    IntPoint convertFromScrollbarToContainingView(const Scrollbar*, const IntPoint&) const;
+    IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoint&) const;
+    int scrollSize(ScrollbarOrientation) const;
+    void setScrollOffset(const IntPoint&);
+    IntPoint scrollPosition() const;
+    IntPoint minimumScrollPosition() const;
+    IntPoint maximumScrollPosition() const;
+    IntRect visibleContentRect(ScrollableArea::VisibleContentRectIncludesScrollbars) const;
+    int visibleHeight() const;
+    int visibleWidth() const;
+    IntSize contentsSize() const;
+    IntSize overhangAmount() const;
+    IntPoint lastKnownMousePosition() const;
+    bool shouldSuspendScrollAnimations() const;
+    bool scrollbarsCanBeActive() const;
+    IntRect scrollableAreaBoundingBox() const;
+    // End of ScrollableArea interface
+
+    // FIXME: This should be removed once we have transitioned to RenderLayerScrollableArea.
+    const IntPoint& scrollOrigin() const;
 
     // Rectangle encompassing the scroll corner and resizer rect.
     IntRect scrollCornerAndResizerRect() const;
@@ -1039,7 +1054,8 @@
     void updateCompositingLayersAfterScroll();
 
     IntSize scrollbarOffset(const Scrollbar*) const;
-    
+
+    void updateScrollableArea();
     void updateResizerAreaSet();
     void updateScrollableAreaSet(bool hasOverflow);
 
@@ -1117,8 +1133,6 @@
     bool overflowControlsIntersectRect(const IntRect& localRect) const;
 
 protected:
-    // The bitfields are up here so they will fall into the padding from ScrollableArea on 64-bit.
-
     // Keeps track of whether the layer is currently resizing, so events can cause resizing to start and stop.
     unsigned m_inResizeMode : 1;
 
@@ -1274,6 +1288,7 @@
     IntRect m_blockSelectionGapsBounds;
 
     OwnPtr<RenderLayerBacking> m_backing;
+    OwnPtr<RenderLayerScrollableArea> m_scrollableArea;
 };
 
 inline void RenderLayer::clearZOrderLists()
diff --git a/Source/core/rendering/RenderLayerBacking.cpp b/Source/core/rendering/RenderLayerBacking.cpp
index 1843f66..ca15213 100644
--- a/Source/core/rendering/RenderLayerBacking.cpp
+++ b/Source/core/rendering/RenderLayerBacking.cpp
@@ -67,10 +67,44 @@
 
 using namespace HTMLNames;
 
-static bool hasBoxDecorationsOrBackgroundImage(const RenderStyle*);
 static IntRect clipBox(RenderBox* renderer);
 
-static inline bool isAcceleratedCanvas(RenderObject* renderer)
+static IntRect contentsRect(const RenderObject* renderer)
+{
+    if (!renderer->isBox())
+        return IntRect();
+
+    return renderer->isVideo() ?
+        toRenderVideo(renderer)->videoBox() :
+        pixelSnappedIntRect(toRenderBox(renderer)->contentBoxRect());
+}
+
+static IntRect backgroundRect(const RenderObject* renderer)
+{
+    if (!renderer->isBox())
+        return IntRect();
+
+    LayoutRect rect;
+    const RenderBox* box = toRenderBox(renderer);
+    EFillBox clip = box->style()->backgroundClip();
+    switch (clip) {
+    case BorderFillBox:
+        rect = box->borderBoxRect();
+        break;
+    case PaddingFillBox:
+        rect = box->paddingBoxRect();
+        break;
+    case ContentFillBox:
+        rect = box->contentBoxRect();
+        break;
+    case TextFillBox:
+        break;
+    }
+
+    return pixelSnappedIntRect(rect);
+}
+
+static inline bool isAcceleratedCanvas(const RenderObject* renderer)
 {
     if (renderer->isCanvas()) {
         HTMLCanvasElement* canvas = toHTMLCanvasElement(renderer->node());
@@ -80,6 +114,31 @@
     return false;
 }
 
+static bool hasBoxDecorations(const RenderStyle* style)
+{
+    return style->hasBorder() || style->hasBorderRadius() || style->hasOutline() || style->hasAppearance() || style->boxShadow() || style->hasFilter();
+}
+
+static bool hasBoxDecorationsOrBackgroundImage(const RenderStyle* style)
+{
+    return hasBoxDecorations(style) || style->hasBackgroundImage();
+}
+
+static bool contentLayerSupportsDirectBackgroundComposition(const RenderObject* renderer)
+{
+    // No support for decorations - border, border-radius or outline.
+    // Only simple background - solid color or transparent.
+    if (hasBoxDecorationsOrBackgroundImage(renderer->style()))
+        return false;
+
+    // If there is no background, there is nothing to support.
+    if (!renderer->style()->hasBackground())
+        return true;
+
+    // Simple background that is contained within the contents rect.
+    return contentsRect(renderer).contains(backgroundRect(renderer));
+}
+
 // Get the scrolling coordinator in a way that works inside RenderLayerBacking's destructor.
 static ScrollingCoordinator* scrollingCoordinatorFromLayer(RenderLayer* layer)
 {
@@ -766,6 +825,19 @@
     }
 
     bool hasPaintedContent = containsPaintedContent(isSimpleContainer);
+    if (hasPaintedContent && isAcceleratedCanvas(renderer())) {
+        HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(renderer()->node());
+        CanvasRenderingContext* context = canvas->renderingContext();
+        // Content layer may be null if context is lost.
+        if (WebKit::WebLayer* contentLayer = context->platformLayer()) {
+            Color bgColor;
+            if (contentLayerSupportsDirectBackgroundComposition(renderer())) {
+                bgColor = rendererBackgroundColor();
+                hasPaintedContent = false;
+            }
+            contentLayer->setBackgroundColor(bgColor.rgb());
+        }
+    }
 
     // FIXME: we could refine this to only allocate backing for one of these layers if possible.
     m_graphicsLayer->setDrawsContent(hasPaintedContent);
@@ -852,9 +924,9 @@
 
     if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m_owningLayer)) {
         if (horizontalScrollbarLayerChanged)
-            scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_owningLayer, HorizontalScrollbar);
+            scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_owningLayer->scrollableArea(), HorizontalScrollbar);
         if (verticalScrollbarLayerChanged)
-            scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_owningLayer, VerticalScrollbar);
+            scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_owningLayer->scrollableArea(), VerticalScrollbar);
     }
 
     return horizontalScrollbarLayerChanged || verticalScrollbarLayerChanged || scrollCornerLayerChanged;
@@ -1016,14 +1088,14 @@
 
             layerChanged = true;
             if (scrollingCoordinator)
-                scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_owningLayer);
+                scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_owningLayer->scrollableArea());
         }
     } else if (m_scrollingLayer) {
         m_scrollingLayer = nullptr;
         m_scrollingContentsLayer = nullptr;
         layerChanged = true;
         if (scrollingCoordinator)
-            scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_owningLayer);
+            scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_owningLayer->scrollableArea());
     }
 
     if (layerChanged) {
@@ -1076,16 +1148,6 @@
     return finalOpacity;
 }
 
-static bool hasBoxDecorations(const RenderStyle* style)
-{
-    return style->hasBorder() || style->hasBorderRadius() || style->hasOutline() || style->hasAppearance() || style->boxShadow() || style->hasFilter();
-}
-
-static bool hasBoxDecorationsOrBackgroundImage(const RenderStyle* style)
-{
-    return hasBoxDecorations(style) || style->hasBackgroundImage();
-}
-
 Color RenderLayerBacking::rendererBackgroundColor() const
 {
     RenderObject* backgroundRenderer = renderer();
@@ -1269,9 +1331,6 @@
     if (renderer()->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo())
         return m_owningLayer->hasBoxDecorationsOrBackground();
 
-    if (isAcceleratedCanvas(renderer()))
-        return m_owningLayer->hasBoxDecorationsOrBackground();
-
     return true;
 }
 
@@ -1380,46 +1439,16 @@
 
 IntRect RenderLayerBacking::contentsBox() const
 {
-    if (!renderer()->isBox())
-        return IntRect();
-
-    IntRect contentsRect;
-    if (renderer()->isVideo()) {
-        RenderVideo* videoRenderer = toRenderVideo(renderer());
-        contentsRect = videoRenderer->videoBox();
-    } else
-        contentsRect = pixelSnappedIntRect(toRenderBox(renderer())->contentBoxRect());
-
-    contentsRect.move(contentOffsetInCompostingLayer());
-    return contentsRect;
-}
-
-static LayoutRect backgroundRectForBox(const RenderBox* box)
-{
-    EFillBox clip = box->style()->backgroundClip();
-    switch (clip) {
-    case BorderFillBox:
-        return box->borderBoxRect();
-    case PaddingFillBox:
-        return box->paddingBoxRect();
-    case ContentFillBox:
-        return box->contentBoxRect();
-    case TextFillBox:
-        break;
-    }
-
-    ASSERT_NOT_REACHED();
-    return LayoutRect();
+    IntRect contentsBox = contentsRect(renderer());
+    contentsBox.move(contentOffsetInCompostingLayer());
+    return contentsBox;
 }
 
 IntRect RenderLayerBacking::backgroundBox() const
 {
-    if (!renderer()->isBox())
-        return IntRect();
-
-    IntRect pixelSnappedBackgroundBox = pixelSnappedIntRect(backgroundRectForBox(toRenderBox(renderer())));
-    pixelSnappedBackgroundBox.move(contentOffsetInCompostingLayer());
-    return pixelSnappedBackgroundBox;
+    IntRect backgroundBox = backgroundRect(renderer());
+    backgroundBox.move(contentOffsetInCompostingLayer());
+    return backgroundBox;
 }
 
 GraphicsLayer* RenderLayerBacking::parentForSublayers() const
diff --git a/Source/core/rendering/RenderLayerCompositor.cpp b/Source/core/rendering/RenderLayerCompositor.cpp
index a5ebd96..f736740 100644
--- a/Source/core/rendering/RenderLayerCompositor.cpp
+++ b/Source/core/rendering/RenderLayerCompositor.cpp
@@ -1197,7 +1197,7 @@
 bool RenderLayerCompositor::scrollingLayerDidChange(RenderLayer* layer)
 {
     if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
-        return scrollingCoordinator->scrollableAreaScrollLayerDidChange(layer);
+        return scrollingCoordinator->scrollableAreaScrollLayerDidChange(layer->scrollableArea());
     return false;
 }
 
@@ -1989,7 +1989,7 @@
 
     RenderLayer* ancestor = layer->parent();
     while (ancestor && !hasScrollableAncestor) {
-        if (frameView->containsScrollableArea(ancestor))
+        if (frameView->containsScrollableArea(ancestor->scrollableArea()))
             hasScrollableAncestor = true;
         if (ancestor->renderer() == m_renderView)
             break;
diff --git a/Source/core/rendering/RenderLayerScrollableArea.cpp b/Source/core/rendering/RenderLayerScrollableArea.cpp
new file mode 100644
index 0000000..75e0ef9
--- /dev/null
+++ b/Source/core/rendering/RenderLayerScrollableArea.cpp
@@ -0,0 +1,251 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
+ *
+ * Portions are Copyright (C) 1998 Netscape Communications Corporation.
+ *
+ * Other contributors:
+ *   Robert O'Callahan <roc+@cs.cmu.edu>
+ *   David Baron <dbaron@fas.harvard.edu>
+ *   Christian Biesinger <cbiesinger@web.de>
+ *   Randall Jesup <rjesup@wgate.com>
+ *   Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
+ *   Josh Soref <timeless@mac.com>
+ *   Boris Zbarsky <bzbarsky@mit.edu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of either the Mozilla Public License Version 1.1, found at
+ * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
+ * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
+ * (the "GPL"), in which case the provisions of the MPL or the GPL are
+ * applicable instead of those above.  If you wish to allow use of your
+ * version of this file only under the terms of one of those two
+ * licenses (the MPL or the GPL) and not to allow others to use your
+ * version of this file under the LGPL, indicate your decision by
+ * deletingthe provisions above and replace them with the notice and
+ * other provisions required by the MPL or the GPL, as the case may be.
+ * If you do not delete the provisions above, a recipient may use your
+ * version of this file under any of the LGPL, the MPL or the GPL.
+ */
+
+#include "config.h"
+#include "core/rendering/RenderLayer.h"
+
+#include "core/page/Frame.h"
+#include "core/page/FrameView.h"
+#include "core/page/Page.h"
+#include "core/page/scrolling/ScrollingCoordinator.h"
+#include "core/platform/ScrollAnimator.h"
+
+namespace WebCore {
+
+RenderLayerScrollableArea::RenderLayerScrollableArea(RenderLayer* layer)
+    : m_layer(layer)
+{
+    ScrollableArea::setConstrainsScrollingToContentEdge(false);
+
+    Node* node = m_layer->renderer()->node();
+    if (node && node->isElementNode()) {
+        // We save and restore only the scrollOffset as the other scroll values are recalculated.
+        Element* element = toElement(node);
+        m_layer->m_scrollOffset = element->savedLayerScrollOffset();
+        if (!m_layer->m_scrollOffset.isZero())
+            scrollAnimator()->setCurrentPosition(FloatPoint(m_layer->m_scrollOffset.width(), m_layer->m_scrollOffset.height()));
+        element->setSavedLayerScrollOffset(IntSize());
+    }
+
+}
+
+RenderLayerScrollableArea::~RenderLayerScrollableArea()
+{
+    if (Frame* frame = m_layer->renderer()->frame()) {
+        if (FrameView* frameView = frame->view()) {
+            frameView->removeScrollableArea(this);
+        }
+    }
+
+    if (m_layer->renderer()->frame() && m_layer->renderer()->frame()->page()) {
+        if (ScrollingCoordinator* scrollingCoordinator = m_layer->renderer()->frame()->page()->scrollingCoordinator())
+            scrollingCoordinator->willDestroyScrollableArea(this);
+    }
+}
+
+Scrollbar* RenderLayerScrollableArea::horizontalScrollbar() const
+{
+    return m_layer->horizontalScrollbar();
+}
+
+Scrollbar* RenderLayerScrollableArea::verticalScrollbar() const
+{
+    return m_layer->verticalScrollbar();
+}
+
+ScrollableArea* RenderLayerScrollableArea::enclosingScrollableArea() const
+{
+    return m_layer->enclosingScrollableArea();
+}
+
+void RenderLayerScrollableArea::updateNeedsCompositedScrolling()
+{
+    m_layer->updateNeedsCompositedScrolling();
+}
+
+int RenderLayerScrollableArea::scrollPosition(Scrollbar* scrollbar) const
+{
+    return m_layer->scrollPosition(scrollbar);
+}
+
+GraphicsLayer* RenderLayerScrollableArea::layerForScrolling() const
+{
+    return m_layer->layerForScrolling();
+}
+
+GraphicsLayer* RenderLayerScrollableArea::layerForHorizontalScrollbar() const
+{
+    return m_layer->layerForHorizontalScrollbar();
+}
+
+GraphicsLayer* RenderLayerScrollableArea::layerForVerticalScrollbar() const
+{
+    return m_layer->layerForVerticalScrollbar();
+}
+
+GraphicsLayer* RenderLayerScrollableArea::layerForScrollCorner() const
+{
+    return m_layer->layerForScrollCorner();
+}
+
+bool RenderLayerScrollableArea::usesCompositedScrolling() const
+{
+    return m_layer->usesCompositedScrolling();
+}
+
+void RenderLayerScrollableArea::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
+{
+    m_layer->invalidateScrollbarRect(scrollbar, rect);
+}
+
+void RenderLayerScrollableArea::invalidateScrollCornerRect(const IntRect& rect)
+{
+    m_layer->invalidateScrollCornerRect(rect);
+}
+
+bool RenderLayerScrollableArea::isActive() const
+{
+    return m_layer->isActive();
+}
+
+bool RenderLayerScrollableArea::isScrollCornerVisible() const
+{
+    return m_layer->isScrollCornerVisible();
+}
+
+IntRect RenderLayerScrollableArea::scrollCornerRect() const
+{
+    return m_layer->scrollCornerRect();
+}
+
+IntRect RenderLayerScrollableArea::convertFromScrollbarToContainingView(const Scrollbar* scrollbar, const IntRect& rect) const
+{
+    return m_layer->convertFromScrollbarToContainingView(scrollbar, rect);
+}
+
+IntRect RenderLayerScrollableArea::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntRect& rect) const
+{
+    return m_layer->convertFromContainingViewToScrollbar(scrollbar, rect);
+}
+
+IntPoint RenderLayerScrollableArea::convertFromScrollbarToContainingView(const Scrollbar* scrollbar, const IntPoint& point) const
+{
+    return m_layer->convertFromScrollbarToContainingView(scrollbar, point);
+}
+
+IntPoint RenderLayerScrollableArea::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntPoint& point) const
+{
+    return m_layer->convertFromContainingViewToScrollbar(scrollbar, point);
+}
+
+int RenderLayerScrollableArea::scrollSize(ScrollbarOrientation orientation) const
+{
+    return m_layer->scrollSize(orientation);
+}
+
+void RenderLayerScrollableArea::setScrollOffset(const IntPoint& offset)
+{
+    m_layer->setScrollOffset(offset);
+}
+
+IntPoint RenderLayerScrollableArea::scrollPosition() const
+{
+    return m_layer->scrollPosition();
+}
+
+IntPoint RenderLayerScrollableArea::minimumScrollPosition() const
+{
+    return m_layer->minimumScrollPosition();
+}
+
+IntPoint RenderLayerScrollableArea::maximumScrollPosition() const
+{
+    return m_layer->maximumScrollPosition();
+}
+
+IntRect RenderLayerScrollableArea::visibleContentRect(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
+{
+    return m_layer->visibleContentRect(scrollbarInclusion);
+}
+
+int RenderLayerScrollableArea::visibleHeight() const
+{
+    return m_layer->visibleHeight();
+}
+
+int RenderLayerScrollableArea::visibleWidth() const
+{
+    return m_layer->visibleWidth();
+}
+
+IntSize RenderLayerScrollableArea::contentsSize() const
+{
+    return m_layer->contentsSize();
+}
+
+IntSize RenderLayerScrollableArea::overhangAmount() const
+{
+    return m_layer->overhangAmount();
+}
+
+IntPoint RenderLayerScrollableArea::lastKnownMousePosition() const
+{
+    return m_layer->lastKnownMousePosition();
+}
+
+bool RenderLayerScrollableArea::shouldSuspendScrollAnimations() const
+{
+    return m_layer->shouldSuspendScrollAnimations();
+}
+
+bool RenderLayerScrollableArea::scrollbarsCanBeActive() const
+{
+    return m_layer->scrollbarsCanBeActive();
+}
+
+IntRect RenderLayerScrollableArea::scrollableAreaBoundingBox() const
+{
+    return m_layer->scrollableAreaBoundingBox();
+}
+
+} // Namespace WebCore
diff --git a/Source/core/rendering/RenderLayerScrollableArea.h b/Source/core/rendering/RenderLayerScrollableArea.h
new file mode 100644
index 0000000..d735fea
--- /dev/null
+++ b/Source/core/rendering/RenderLayerScrollableArea.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved.
+ *
+ * Portions are Copyright (C) 1998 Netscape Communications Corporation.
+ *
+ * Other contributors:
+ *   Robert O'Callahan <roc+@cs.cmu.edu>
+ *   David Baron <dbaron@fas.harvard.edu>
+ *   Christian Biesinger <cbiesinger@web.de>
+ *   Randall Jesup <rjesup@wgate.com>
+ *   Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
+ *   Josh Soref <timeless@mac.com>
+ *   Boris Zbarsky <bzbarsky@mit.edu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Alternatively, the contents of this file may be used under the terms
+ * of either the Mozilla Public License Version 1.1, found at
+ * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
+ * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
+ * (the "GPL"), in which case the provisions of the MPL or the GPL are
+ * applicable instead of those above.  If you wish to allow use of your
+ * version of this file only under the terms of one of those two
+ * licenses (the MPL or the GPL) and not to allow others to use your
+ * version of this file under the LGPL, indicate your decision by
+ * deletingthe provisions above and replace them with the notice and
+ * other provisions required by the MPL or the GPL, as the case may be.
+ * If you do not delete the provisions above, a recipient may use your
+ * version of this file under any of the LGPL, the MPL or the GPL.
+ */
+
+#ifndef RenderLayerScrollableArea_h
+#define RenderLayerScrollableArea_h
+
+#include "core/platform/ScrollableArea.h"
+
+namespace WebCore {
+
+enum ResizerHitTestType {
+    ResizerForPointer,
+    ResizerForTouch
+};
+
+class RenderLayer;
+
+class RenderLayerScrollableArea FINAL : public ScrollableArea {
+    // FIXME: Remove once the bits from RenderLayer have been moved here.
+    friend class RenderLayer;
+public:
+    RenderLayerScrollableArea(RenderLayer*);
+    virtual ~RenderLayerScrollableArea();
+
+    virtual Scrollbar* horizontalScrollbar() const OVERRIDE;
+    virtual Scrollbar* verticalScrollbar() const OVERRIDE;
+    virtual ScrollableArea* enclosingScrollableArea() const OVERRIDE;
+
+    virtual void updateNeedsCompositedScrolling() OVERRIDE;
+
+    virtual int scrollPosition(Scrollbar*) const OVERRIDE;
+    virtual GraphicsLayer* layerForScrolling() const OVERRIDE;
+    virtual GraphicsLayer* layerForHorizontalScrollbar() const OVERRIDE;
+    virtual GraphicsLayer* layerForVerticalScrollbar() const OVERRIDE;
+    virtual GraphicsLayer* layerForScrollCorner() const OVERRIDE;
+    virtual bool usesCompositedScrolling() const OVERRIDE;
+    virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE;
+    virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE;
+    virtual bool isActive() const OVERRIDE;
+    virtual bool isScrollCornerVisible() const OVERRIDE;
+    virtual IntRect scrollCornerRect() const OVERRIDE;
+    virtual IntRect convertFromScrollbarToContainingView(const Scrollbar*, const IntRect&) const OVERRIDE;
+    virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect&) const OVERRIDE;
+    virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, const IntPoint&) const OVERRIDE;
+    virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoint&) const OVERRIDE;
+    virtual int scrollSize(ScrollbarOrientation) const OVERRIDE;
+    virtual void setScrollOffset(const IntPoint&) OVERRIDE;
+    virtual IntPoint scrollPosition() const OVERRIDE;
+    virtual IntPoint minimumScrollPosition() const OVERRIDE;
+    virtual IntPoint maximumScrollPosition() const OVERRIDE;
+    virtual IntRect visibleContentRect(VisibleContentRectIncludesScrollbars) const OVERRIDE;
+    virtual int visibleHeight() const OVERRIDE;
+    virtual int visibleWidth() const OVERRIDE;
+    virtual IntSize contentsSize() const OVERRIDE;
+    virtual IntSize overhangAmount() const OVERRIDE;
+    virtual IntPoint lastKnownMousePosition() const OVERRIDE;
+    virtual bool shouldSuspendScrollAnimations() const OVERRIDE;
+    virtual bool scrollbarsCanBeActive() const OVERRIDE;
+    virtual IntRect scrollableAreaBoundingBox() const OVERRIDE;
+private:
+    RenderLayer* m_layer;
+};
+
+} // Namespace WebCore
+
+#endif // RenderLayerScrollableArea_h
diff --git a/Source/core/rendering/RenderMenuList.cpp b/Source/core/rendering/RenderMenuList.cpp
index b984d7e..241185f 100644
--- a/Source/core/rendering/RenderMenuList.cpp
+++ b/Source/core/rendering/RenderMenuList.cpp
@@ -491,9 +491,13 @@
     HTMLElement* element = listItems[listIndex];
 
     Color backgroundColor;
-    if (element->renderStyle())
+    if (element->renderStyle()) {
         backgroundColor = resolveColor(element->renderStyle(), CSSPropertyBackgroundColor);
-    itemHasCustomBackgroundColor = backgroundColor.isValid() && backgroundColor.alpha();
+        itemHasCustomBackgroundColor = backgroundColor.alpha();
+    } else {
+        itemHasCustomBackgroundColor = false;
+    }
+
     // If the item has an opaque background color, return that.
     if (!backgroundColor.hasAlpha()) {
         itemBackgroundColor = backgroundColor;
diff --git a/Source/core/rendering/RenderObject.cpp b/Source/core/rendering/RenderObject.cpp
index 28e058a..1f43a15 100644
--- a/Source/core/rendering/RenderObject.cpp
+++ b/Source/core/rendering/RenderObject.cpp
@@ -1654,32 +1654,35 @@
 
 Color RenderObject::selectionBackgroundColor() const
 {
-    Color color;
+    Color backgroundColor= Color::transparent;
     if (shouldUseSelectionColor(*style())) {
         RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
-        if (pseudoStyle && resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColor).isValid())
-            color = resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColor).blendWithWhite();
-        else
-            color = frame()->selection()->isFocusedAndActive() ?
-                    theme()->activeSelectionBackgroundColor() :
-                    theme()->inactiveSelectionBackgroundColor();
+        if (pseudoStyle) {
+            StyleColor styleColor = resolveCurrentColor(pseudoStyle.get(), CSSPropertyBackgroundColor);
+            if (styleColor.isValid())
+                return styleColor.color().blendWithWhite();
+        }
+
+        backgroundColor = frame()->selection()->isFocusedAndActive() ?
+            theme()->activeSelectionBackgroundColor() :
+            theme()->inactiveSelectionBackgroundColor();
     }
 
-    return color;
+    return backgroundColor;
 }
 
 Color RenderObject::selectionColor(int colorProperty) const
 {
-    Color color;
     // If the element is unselectable, or we are only painting the selection,
     // don't override the foreground color with the selection foreground color.
     if (!shouldUseSelectionColor(*style())
         || (frame()->view()->paintBehavior() & PaintBehaviorSelectionOnly))
-        return color;
+        return Color::transparent;
 
+    Color color;
     if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequest(SELECTION))) {
-        Color selectionColor = resolveColor(pseudoStyle.get(), colorProperty);
-        color = selectionColor.isValid() ? selectionColor : resolveColor(pseudoStyle.get(), CSSPropertyColor);
+        StyleColor styleColor = resolveCurrentColor(pseudoStyle.get(), colorProperty);
+        color = styleColor.isValid() ? styleColor.color() : resolveColor(pseudoStyle.get(), CSSPropertyColor);
     } else
         color = frame()->selection()->isFocusedAndActive() ?
                 theme()->activeSelectionForegroundColor() :
@@ -2870,20 +2873,20 @@
 
 static Color decorationColor(const RenderObject* object, RenderStyle* style)
 {
-    Color result;
+    StyleColor result;
     // Check for text decoration color first.
-    result = object->resolveColor(style, CSSPropertyTextDecorationColor);
+    result = object->resolveStyleColor(style, CSSPropertyTextDecorationColor);
     if (result.isValid())
-        return result;
+        return result.color();
     if (style->textStrokeWidth() > 0) {
         // Prefer stroke color if possible but not if it's fully transparent.
         result = object->resolveColor(style, CSSPropertyWebkitTextStrokeColor);
         if (result.alpha())
-            return result;
+            return result.color();
     }
     
     result = object->resolveColor(style, CSSPropertyWebkitTextFillColor);
-    return result;
+    return result.color();
 }
 
 void RenderObject::getTextDecorationColors(int decorations, Color& underline, Color& overline,
diff --git a/Source/core/rendering/RenderObject.h b/Source/core/rendering/RenderObject.h
index 4555529..05df7a9 100644
--- a/Source/core/rendering/RenderObject.h
+++ b/Source/core/rendering/RenderObject.h
@@ -495,6 +495,13 @@
     // rest of the rendering tree will move to a similar model.
     virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
 
+    virtual bool canHaveWhitespaceChildren() const
+    {
+        if (isTable() || isTableRow() || isTableSection() || isRenderTableCol() || isFrameSet() || isFlexibleBox() || isRenderGrid())
+            return false;
+        return true;
+    }
+
     bool isAnonymous() const { return m_bitfields.isAnonymous(); }
     bool isAnonymousBlock() const
     {
@@ -541,7 +548,13 @@
     bool backgroundIsKnownToBeObscured();
     bool borderImageIsLoadedAndCanBeRendered() const;
     bool mustRepaintBackgroundOrBorder() const;
-    bool hasBackground() const { return style()->hasBackground(); }
+    bool hasBackground() const
+    {
+        StyleColor color = resolveColor(CSSPropertyBackgroundColor);
+        if (color.isValid() && color.alpha())
+            return true;
+        return style()->hasBackgroundImage();
+    }
     bool hasEntirelyFixedBackground() const;
 
     bool needsLayout() const
@@ -759,23 +772,41 @@
 
     inline Color resolveColor(const RenderStyle* styleToUse, int colorProperty) const
     {
-        return styleToUse->visitedDependentColor(colorProperty);
+        StyleColor styleColor = resolveCurrentColor(styleToUse, colorProperty);
+        return styleColor.color();
     }
 
     inline Color resolveColor(int colorProperty) const
     {
-        return style()->visitedDependentColor(colorProperty);
+        StyleColor styleColor = resolveCurrentColor(style(), colorProperty);
+        return styleColor.color();
     }
 
-    inline Color resolveColor(int colorProperty, Color fallback) const
+    inline Color resolveColor(int colorProperty, Color fallbackIfInvalid) const
     {
-        Color color = resolveColor(colorProperty);
-        return color.isValid() ? color : fallback;
+        StyleColor styleColor = resolveCurrentColor(style(), colorProperty);
+        return styleColor.isValid() ? styleColor.color() : fallbackIfInvalid;
     }
 
-    inline Color resolveColor(Color color) const
+    inline Color resolveColor(StyleColor color) const
     {
-        return color;
+        return resolveCurrentColor(color).color();
+    }
+
+    inline Color resolveColor(StyleColor color, Color fallbackIfInvalid) const
+    {
+        StyleColor styleColor = resolveCurrentColor(color);
+        return styleColor.isValid() ? styleColor.color() : fallbackIfInvalid;
+    }
+
+    inline StyleColor resolveStyleColor(int colorProperty) const
+    {
+        return resolveCurrentColor(style(), colorProperty);
+    }
+
+    inline StyleColor resolveStyleColor(const RenderStyle* styleToUse, int colorProperty) const
+    {
+        return resolveCurrentColor(styleToUse, colorProperty);
     }
 
     // Used only by Element::pseudoStyleCacheIsInvalid to get a first line style based off of a
@@ -1021,6 +1052,28 @@
 
     Color selectionColor(int colorProperty) const;
 
+    inline StyleColor resolveCurrentColor(const RenderStyle* styleToUse, int colorProperty) const
+    {
+        StyleColor styleColor = styleToUse->visitedDependentColor(colorProperty);
+        if (UNLIKELY(styleColor.isCurrentColor()))
+            styleColor = styleToUse->visitedDependentColor(CSSPropertyColor);
+
+        // In the unlikely case that CSSPropertyColor is also 'currentColor'
+        // the color of the nearest ancestor with a valid color is used.
+        for (const RenderObject* object = this; UNLIKELY(styleColor.isCurrentColor()) && object && object->style(); object = object->parent())
+            styleColor = object->style()->visitedDependentColor(CSSPropertyColor);
+
+        return styleColor;
+    }
+
+    inline StyleColor resolveCurrentColor(StyleColor color) const
+    {
+        StyleColor styleColor = color;
+        for (const RenderObject* object = this; UNLIKELY(styleColor.isCurrentColor()) && object && object->style(); object = object->parent())
+            styleColor = object->style()->visitedDependentColor(CSSPropertyColor);
+        return styleColor;
+    }
+
 #ifndef NDEBUG
     void checkBlockPositionedObjectsNeedLayout();
 #endif
diff --git a/Source/core/rendering/RenderTableCell.cpp b/Source/core/rendering/RenderTableCell.cpp
index f13dc0a..429d521 100644
--- a/Source/core/rendering/RenderTableCell.cpp
+++ b/Source/core/rendering/RenderTableCell.cpp
@@ -1168,7 +1168,7 @@
     if (backgroundObject != this)
         adjustedPaintOffset.moveBy(location());
 
-    Color c = backgroundObject->resolveColor(CSSPropertyBackgroundColor);
+    StyleColor c = backgroundObject->resolveStyleColor(CSSPropertyBackgroundColor);
     const FillLayer* bgLayer = backgroundObject->style()->backgroundLayers();
 
     if (bgLayer->hasImage() || c.isValid()) {
@@ -1181,7 +1181,7 @@
                 width() - borderLeft() - borderRight(), height() - borderTop() - borderBottom());
             paintInfo.context->clip(clipRect);
         }
-        paintFillLayers(paintInfo, c, bgLayer, LayoutRect(adjustedPaintOffset, pixelSnappedSize()), BackgroundBleedNone, CompositeSourceOver, backgroundObject);
+        paintFillLayers(paintInfo, c.color(), bgLayer, LayoutRect(adjustedPaintOffset, pixelSnappedSize()), BackgroundBleedNone, CompositeSourceOver, backgroundObject);
     }
 }
 
diff --git a/Source/core/rendering/RenderTheme.cpp b/Source/core/rendering/RenderTheme.cpp
index 790b9ed..e182a4d 100644
--- a/Source/core/rendering/RenderTheme.cpp
+++ b/Source/core/rendering/RenderTheme.cpp
@@ -68,9 +68,9 @@
 
 using namespace HTMLNames;
 
-static Color& customFocusRingColor()
+static StyleColor& customFocusRingColor()
 {
-    DEFINE_STATIC_LOCAL(Color, color, ());
+    DEFINE_STATIC_LOCAL(StyleColor, color, ());
     return color;
 }
 
@@ -91,6 +91,7 @@
     : m_theme(platformTheme())
 #endif
 {
+    m_selectionColorsValid = 0;
 }
 
 void RenderTheme::adjustStyle(RenderStyle* style, Element* e, const CachedUAStyle& uaStyle)
@@ -525,59 +526,88 @@
     return formatMediaControlsTime(currentTime);
 }
 
+namespace SelectionColors {
+enum {
+    ActiveBackground = 1,
+    InactiveBackground = 2,
+    ActiveForeground = 4,
+    InactiveForeground = 8,
+    ActiveListBoxBackground = 16,
+    InactiveListBoxBackground = 32,
+    ActiveListBoxForeground = 64,
+    InactiveListBoxForeground = 128
+};
+};
+
 Color RenderTheme::activeSelectionBackgroundColor() const
 {
-    if (!m_activeSelectionBackgroundColor.isValid())
+    if (!(m_selectionColorsValid & SelectionColors::ActiveBackground)) {
         m_activeSelectionBackgroundColor = platformActiveSelectionBackgroundColor().blendWithWhite();
+        m_selectionColorsValid |= SelectionColors::ActiveBackground;
+    }
     return m_activeSelectionBackgroundColor;
 }
 
 Color RenderTheme::inactiveSelectionBackgroundColor() const
 {
-    if (!m_inactiveSelectionBackgroundColor.isValid())
+    if (!(m_selectionColorsValid & SelectionColors::InactiveBackground)) {
         m_inactiveSelectionBackgroundColor = platformInactiveSelectionBackgroundColor().blendWithWhite();
+        m_selectionColorsValid |= SelectionColors::InactiveBackground;
+    }
     return m_inactiveSelectionBackgroundColor;
 }
 
 Color RenderTheme::activeSelectionForegroundColor() const
 {
-    if (!m_activeSelectionForegroundColor.isValid() && supportsSelectionForegroundColors())
+    if (!(m_selectionColorsValid & SelectionColors::ActiveForeground) && supportsSelectionForegroundColors()) {
         m_activeSelectionForegroundColor = platformActiveSelectionForegroundColor();
+        m_selectionColorsValid |= SelectionColors::ActiveForeground;
+    }
     return m_activeSelectionForegroundColor;
 }
 
 Color RenderTheme::inactiveSelectionForegroundColor() const
 {
-    if (!m_inactiveSelectionForegroundColor.isValid() && supportsSelectionForegroundColors())
+    if (!(m_selectionColorsValid & SelectionColors::InactiveForeground) && supportsSelectionForegroundColors()) {
         m_inactiveSelectionForegroundColor = platformInactiveSelectionForegroundColor();
+        m_selectionColorsValid |= SelectionColors::InactiveForeground;
+    }
     return m_inactiveSelectionForegroundColor;
 }
 
 Color RenderTheme::activeListBoxSelectionBackgroundColor() const
 {
-    if (!m_activeListBoxSelectionBackgroundColor.isValid())
+    if (!(m_selectionColorsValid & SelectionColors::ActiveListBoxBackground)) {
         m_activeListBoxSelectionBackgroundColor = platformActiveListBoxSelectionBackgroundColor();
+        m_selectionColorsValid |= SelectionColors::ActiveListBoxBackground;
+    }
     return m_activeListBoxSelectionBackgroundColor;
 }
 
 Color RenderTheme::inactiveListBoxSelectionBackgroundColor() const
 {
-    if (!m_inactiveListBoxSelectionBackgroundColor.isValid())
+    if (!(m_selectionColorsValid & SelectionColors::InactiveListBoxBackground)) {
         m_inactiveListBoxSelectionBackgroundColor = platformInactiveListBoxSelectionBackgroundColor();
+        m_selectionColorsValid |= SelectionColors::InactiveListBoxBackground;
+    }
     return m_inactiveListBoxSelectionBackgroundColor;
 }
 
 Color RenderTheme::activeListBoxSelectionForegroundColor() const
 {
-    if (!m_activeListBoxSelectionForegroundColor.isValid() && supportsListBoxSelectionForegroundColors())
+    if (!(m_selectionColorsValid & SelectionColors::ActiveListBoxForeground) && supportsListBoxSelectionForegroundColors()) {
         m_activeListBoxSelectionForegroundColor = platformActiveListBoxSelectionForegroundColor();
+        m_selectionColorsValid |= SelectionColors::ActiveListBoxForeground;
+    }
     return m_activeListBoxSelectionForegroundColor;
 }
 
 Color RenderTheme::inactiveListBoxSelectionForegroundColor() const
 {
-    if (!m_inactiveListBoxSelectionForegroundColor.isValid() && supportsListBoxSelectionForegroundColors())
+    if (!(m_selectionColorsValid & SelectionColors::InactiveListBoxForeground) && supportsListBoxSelectionForegroundColors()) {
         m_inactiveListBoxSelectionForegroundColor = platformInactiveListBoxSelectionForegroundColor();
+        m_selectionColorsValid |= SelectionColors::InactiveListBoxForeground;
+    }
     return m_inactiveListBoxSelectionForegroundColor;
 }
 
@@ -659,7 +689,7 @@
     // Test the style to see if the UA border and background match.
     return style.border() != uaStyle.border
         || backgroundLayersCopy != backgroundCopy
-        || style.visitedDependentColor(CSSPropertyBackgroundColor) != uaStyle.backgroundColor;
+        || style.visitedDependentColor(CSSPropertyBackgroundColor).color() != uaStyle.backgroundColor;
 }
 
 bool RenderTheme::isControlStyled(const RenderStyle* style, const CachedUAStyle& uaStyle) const
@@ -1092,16 +1122,7 @@
 
 void RenderTheme::platformColorsDidChange()
 {
-    m_activeSelectionForegroundColor = Color();
-    m_inactiveSelectionForegroundColor = Color();
-    m_activeSelectionBackgroundColor = Color();
-    m_inactiveSelectionBackgroundColor = Color();
-
-    m_activeListBoxSelectionForegroundColor = Color();
-    m_inactiveListBoxSelectionForegroundColor = Color();
-    m_activeListBoxSelectionBackgroundColor = Color();
-    m_inactiveListBoxSelectionForegroundColor = Color();
-
+    m_selectionColorsValid = 0;
     Page::scheduleForcedStyleRecalcForAllPages();
 }
 
@@ -1206,7 +1227,7 @@
 
 Color RenderTheme::focusRingColor()
 {
-    return customFocusRingColor().isValid() ? customFocusRingColor() : defaultTheme()->platformFocusRingColor();
+    return customFocusRingColor().isValid() ? customFocusRingColor().color() : defaultTheme()->platformFocusRingColor();
 }
 
 String RenderTheme::fileListDefaultLabel(bool multipleFilesAllowed) const
diff --git a/Source/core/rendering/RenderTheme.h b/Source/core/rendering/RenderTheme.h
index 899a954..057b53f 100644
--- a/Source/core/rendering/RenderTheme.h
+++ b/Source/core/rendering/RenderTheme.h
@@ -349,6 +349,8 @@
     mutable Color m_activeListBoxSelectionForegroundColor;
     mutable Color m_inactiveListBoxSelectionForegroundColor;
 
+    mutable unsigned m_selectionColorsValid;
+
     // This color is expected to be drawn on a semi-transparent overlay,
     // making it more transparent than its alpha value indicates.
     static const RGBA32 defaultTapHighlightColor = 0x66000000;
diff --git a/Source/core/rendering/RenderThemeChromiumMac.mm b/Source/core/rendering/RenderThemeChromiumMac.mm
index 82a723f..e6c7b27 100644
--- a/Source/core/rendering/RenderThemeChromiumMac.mm
+++ b/Source/core/rendering/RenderThemeChromiumMac.mm
@@ -394,7 +394,7 @@
             return it->value;
     }
 
-    Color color;
+    Color color = Color::transparent;
     switch (cssValueId) {
         case CSSValueActiveborder:
             color = convertNSColorToColor([NSColor keyboardFocusIndicatorColor]);
@@ -495,10 +495,10 @@
             break;
     }
 
-    if (!color.isValid())
+    if (!color.alpha())
         color = RenderTheme::systemColor(cssValueId);
 
-    if (color.isValid())
+    if (color.alpha())
         m_systemColorCache.set(cssValueId, color.rgb());
 
     return color;
@@ -1247,7 +1247,7 @@
 
     GraphicsContextStateSaver stateSaver(*paintInfo.context);
 
-    paintInfo.context->setFillColor(o->style()->visitedDependentColor(CSSPropertyColor));
+    paintInfo.context->setFillColor(o->resolveColor(CSSPropertyColor));
     paintInfo.context->setStrokeStyle(NoStroke);
 
     FloatPoint arrow1[3];
diff --git a/Source/core/rendering/RenderThemeChromiumWin.cpp b/Source/core/rendering/RenderThemeChromiumWin.cpp
index 2a25607..e9df8e0 100644
--- a/Source/core/rendering/RenderThemeChromiumWin.cpp
+++ b/Source/core/rendering/RenderThemeChromiumWin.cpp
@@ -552,7 +552,7 @@
     // Fallback to white if the specified color object is invalid.
     Color backgroundColor(Color::white);
     if (o->style()->visitedDependentColor(CSSPropertyBackgroundColor).isValid())
-        backgroundColor = o->style()->visitedDependentColor(CSSPropertyBackgroundColor);
+        backgroundColor = o->resolveColor(CSSPropertyBackgroundColor);
 
     // If we have background-image, don't fill the content area to expose the
     // parent's background. Also, we shouldn't fill the content area if the
diff --git a/Source/core/rendering/RenderTreeAsText.cpp b/Source/core/rendering/RenderTreeAsText.cpp
index 83f5e5e..aa917e8 100644
--- a/Source/core/rendering/RenderTreeAsText.cpp
+++ b/Source/core/rendering/RenderTreeAsText.cpp
@@ -199,11 +199,6 @@
     return result.toString();
 }
 
-static inline Color colorWithFallback(const RenderObject& o, const Color& color)
-{
-    return color.isValid() ? color : o.resolveColor(CSSPropertyColor);
-}
-
 void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o, RenderAsTextBehavior behavior)
 {
     ts << o.renderName();
@@ -274,17 +269,17 @@
             // Do not dump invalid or transparent backgrounds, since that is the default.
             Color backgroundColor = o.resolveColor(CSSPropertyBackgroundColor);
             if (o.parent()->resolveColor(CSSPropertyBackgroundColor) != backgroundColor
-                && backgroundColor.isValid() && backgroundColor.rgb())
+                && backgroundColor.rgb())
                 ts << " [bgcolor=" << backgroundColor.nameForRenderTreeAsText() << "]";
             
             Color textFillColor = o.resolveColor(CSSPropertyWebkitTextFillColor);
             if (o.parent()->resolveColor(CSSPropertyWebkitTextFillColor) != textFillColor
-                && textFillColor.isValid() && textFillColor != color && textFillColor.rgb())
+                && textFillColor != color && textFillColor.rgb())
                 ts << " [textFillColor=" << textFillColor.nameForRenderTreeAsText() << "]";
 
             Color textStrokeColor = o.resolveColor(CSSPropertyWebkitTextStrokeColor);
             if (o.parent()->resolveColor(CSSPropertyWebkitTextStrokeColor) != textStrokeColor
-                && textStrokeColor.isValid() && textStrokeColor != color && textStrokeColor.rgb())
+                && textStrokeColor != color && textStrokeColor.rgb())
                 ts << " [textStrokeColor=" << textStrokeColor.nameForRenderTreeAsText() << "]";
 
             if (o.parent()->style()->textStrokeWidth() != o.style()->textStrokeWidth() && o.style()->textStrokeWidth() > 0)
@@ -304,7 +299,7 @@
             else {
                 ts << " (" << box.borderTop() << "px ";
                 printBorderStyle(ts, o.style()->borderTopStyle());
-                Color col = colorWithFallback(o, o.style()->borderTopColor());
+                Color col = o.resolveColor(CSSPropertyBorderTopColor);
                 ts << col.nameForRenderTreeAsText() << ")";
             }
 
@@ -315,7 +310,7 @@
                 else {
                     ts << " (" << box.borderRight() << "px ";
                     printBorderStyle(ts, o.style()->borderRightStyle());
-                    Color col = colorWithFallback(o, o.style()->borderRightColor());
+                    Color col = o.resolveColor(CSSPropertyBorderRightColor);
                     ts << col.nameForRenderTreeAsText() << ")";
                 }
             }
@@ -327,7 +322,7 @@
                 else {
                     ts << " (" << box.borderBottom() << "px ";
                     printBorderStyle(ts, o.style()->borderBottomStyle());
-                    Color col = colorWithFallback(o, o.style()->borderBottomColor());
+                    Color col = o.resolveColor(CSSPropertyBorderBottomColor);
                     ts << col.nameForRenderTreeAsText() << ")";
                 }
             }
@@ -339,7 +334,7 @@
                 else {
                     ts << " (" << box.borderLeft() << "px ";
                     printBorderStyle(ts, o.style()->borderLeftStyle());
-                    Color col = colorWithFallback(o, o.style()->borderLeftColor());
+                    Color col = o.resolveColor(CSSPropertyBorderLeftColor);
                     ts << col.nameForRenderTreeAsText() << ")";
                 }
             }
diff --git a/Source/core/rendering/RenderVideo.h b/Source/core/rendering/RenderVideo.h
index ee71683..53b7380 100644
--- a/Source/core/rendering/RenderVideo.h
+++ b/Source/core/rendering/RenderVideo.h
@@ -85,6 +85,12 @@
     return static_cast<RenderVideo*>(object);
 }
 
+inline const RenderVideo* toRenderVideo(const RenderObject* object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isVideo());
+    return static_cast<const RenderVideo*>(object);
+}
+
 // This will catch anyone doing an unnecessary cast.
 void toRenderVideo(const RenderVideo*);
 
diff --git a/Source/core/rendering/style/BorderValue.h b/Source/core/rendering/style/BorderValue.h
index fb8c61c..689f17e 100644
--- a/Source/core/rendering/style/BorderValue.h
+++ b/Source/core/rendering/style/BorderValue.h
@@ -25,7 +25,7 @@
 #ifndef BorderValue_h
 #define BorderValue_h
 
-#include "core/platform/graphics/Color.h"
+#include "core/css/StyleColor.h"
 #include "core/rendering/style/RenderStyleConstants.h"
 
 namespace WebCore {
@@ -36,6 +36,7 @@
     BorderValue()
         : m_color(0)
         , m_colorIsValid(false)
+        , m_currentColor(false)
         , m_width(3)
         , m_style(BNONE)
         , m_isAuto(AUTO_OFF)
@@ -49,7 +50,7 @@
 
     bool isTransparent() const
     {
-        return m_colorIsValid && !alphaChannel(m_color);
+        return m_colorIsValid && !m_currentColor && !m_color.alpha();
     }
 
     bool isVisible(bool checkStyle = true) const
@@ -59,7 +60,7 @@
 
     bool operator==(const BorderValue& o) const
     {
-        return m_width == o.m_width && m_style == o.m_style && m_color == o.m_color && m_colorIsValid == o.m_colorIsValid;
+        return m_width == o.m_width && m_style == o.m_style && m_color == o.m_color && m_colorIsValid == o.m_colorIsValid && m_currentColor == o.m_currentColor;
     }
 
     bool operator!=(const BorderValue& o) const
@@ -67,22 +68,24 @@
         return !(*this == o);
     }
 
-    void setColor(const Color& color)
+    void setColor(const StyleColor& color)
     {
-        m_color = color.rgb();
+        m_color = color.color();
         m_colorIsValid = color.isValid();
+        m_currentColor = color.isCurrentColor();
     }
 
-    Color color() const { return Color(m_color, m_colorIsValid); }
+    StyleColor color() const { return StyleColor(m_color, m_colorIsValid, m_currentColor); }
 
     unsigned width() const { return m_width; }
     EBorderStyle style() const { return static_cast<EBorderStyle>(m_style); }
 
 protected:
-    RGBA32 m_color;
+    Color m_color;
     unsigned m_colorIsValid : 1;
+    unsigned m_currentColor : 1;
 
-    unsigned m_width : 26;
+    unsigned m_width : 25;
     unsigned m_style : 4; // EBorderStyle
 
     // This is only used by OutlineValue but moved here to keep the bits packed.
diff --git a/Source/core/rendering/style/CachedUAStyle.h b/Source/core/rendering/style/CachedUAStyle.h
index f56d66f..863212b 100644
--- a/Source/core/rendering/style/CachedUAStyle.h
+++ b/Source/core/rendering/style/CachedUAStyle.h
@@ -54,7 +54,7 @@
     bool hasAppearance;
     BorderData border;
     FillLayer backgroundLayers;
-    Color backgroundColor;
+    StyleColor backgroundColor;
 };
 
 
diff --git a/Source/core/rendering/style/CollapsedBorderValue.h b/Source/core/rendering/style/CollapsedBorderValue.h
index ef16dba..30716ec 100644
--- a/Source/core/rendering/style/CollapsedBorderValue.h
+++ b/Source/core/rendering/style/CollapsedBorderValue.h
@@ -34,6 +34,7 @@
     CollapsedBorderValue()
         : m_color(0)
         , m_colorIsValid(false)
+        , m_currentColor(false)
         , m_width(0)
         , m_style(BNONE)
         , m_precedence(BOFF)
@@ -41,9 +42,10 @@
     {
     }
 
-    CollapsedBorderValue(const BorderValue& border, const Color& color, EBorderPrecedence precedence)
-        : m_color(color.rgb())
+    CollapsedBorderValue(const BorderValue& border, const StyleColor& color, EBorderPrecedence precedence)
+        : m_color(color.color())
         , m_colorIsValid(color.isValid())
+        , m_currentColor(color.isCurrentColor())
         , m_width(border.nonZero() ? border.width() : 0)
         , m_style(border.style())
         , m_precedence(precedence)
@@ -54,7 +56,7 @@
     unsigned width() const { return m_style > BHIDDEN ? m_width : 0; }
     EBorderStyle style() const { return static_cast<EBorderStyle>(m_style); }
     bool exists() const { return m_precedence != BOFF; }
-    Color color() const { return Color(m_color, m_colorIsValid); }
+    StyleColor color() const { return StyleColor(m_color, m_colorIsValid, m_currentColor); }
     bool isTransparent() const { return m_transparent; }
     EBorderPrecedence precedence() const { return static_cast<EBorderPrecedence>(m_precedence); }
 
@@ -64,9 +66,10 @@
     }
 
 private:
-    RGBA32 m_color;
+    Color m_color;
     unsigned m_colorIsValid : 1;
-    unsigned m_width : 23;
+    unsigned m_currentColor : 1;
+    unsigned m_width : 22;
     unsigned m_style : 4; // EBorderStyle
     unsigned m_precedence : 3; // EBorderPrecedence
     unsigned m_transparent : 1;
diff --git a/Source/core/rendering/style/RenderStyle.cpp b/Source/core/rendering/style/RenderStyle.cpp
index b833659..53979e2 100644
--- a/Source/core/rendering/style/RenderStyle.cpp
+++ b/Source/core/rendering/style/RenderStyle.cpp
@@ -186,7 +186,6 @@
     noninherited_flags._page_break_after = other->noninherited_flags._page_break_after;
     noninherited_flags._page_break_inside = other->noninherited_flags._page_break_inside;
     noninherited_flags.explicitInheritance = other->noninherited_flags.explicitInheritance;
-    noninherited_flags.currentColor = other->noninherited_flags.currentColor;
     if (m_svgStyle != other->m_svgStyle)
         m_svgStyle.access()->copyNonInheritedFrom(other->m_svgStyle.get());
     ASSERT(zoom() == initialZoom());
@@ -918,10 +917,10 @@
         rareInheritedData.access()->listStyleImage = v;
 }
 
-Color RenderStyle::color() const { return inherited->color; }
-Color RenderStyle::visitedLinkColor() const { return inherited->visitedLinkColor; }
-void RenderStyle::setColor(const Color& v) { SET_VAR(inherited, color, v); }
-void RenderStyle::setVisitedLinkColor(const Color& v) { SET_VAR(inherited, visitedLinkColor, v); }
+StyleColor RenderStyle::color() const { return inherited->color; }
+StyleColor RenderStyle::visitedLinkColor() const { return inherited->visitedLinkColor; }
+void RenderStyle::setColor(const StyleColor& v) { SET_VAR(inherited, color, v); }
+void RenderStyle::setVisitedLinkColor(const StyleColor& v) { SET_VAR(inherited, visitedLinkColor, v); }
 
 short RenderStyle::horizontalBorderSpacing() const { return inherited->horizontal_border_spacing; }
 short RenderStyle::verticalBorderSpacing() const { return inherited->vertical_border_spacing; }
@@ -1295,9 +1294,9 @@
     }
 }
 
-Color RenderStyle::colorIncludingFallback(int colorProperty, bool visitedLink) const
+StyleColor RenderStyle::colorIncludingFallback(int colorProperty, bool visitedLink) const
 {
-    Color result;
+    StyleColor result;
     EBorderStyle borderStyle = BNONE;
     switch (colorProperty) {
     case CSSPropertyBackgroundColor:
@@ -1339,12 +1338,24 @@
     case CSSPropertyWebkitTextStrokeColor:
         result = visitedLink ? visitedLinkTextStrokeColor() : textStrokeColor();
         break;
+    case CSSPropertyFloodColor:
+        result = floodColor();
+        break;
+    case CSSPropertyLightingColor:
+        result = lightingColor();
+        break;
+    case CSSPropertyStopColor:
+        result = stopColor();
+        break;
+    case CSSPropertyWebkitTapHighlightColor:
+        result = tapHighlightColor();
+        break;
     default:
         ASSERT_NOT_REACHED();
         break;
     }
 
-    if (!result.isValid()) {
+    if (!result.isValid() && !result.isCurrentColor()) {
         if (!visitedLink && (borderStyle == INSET || borderStyle == OUTSET || borderStyle == RIDGE || borderStyle == GROOVE))
             result.setRGB(238, 238, 238);
         else
@@ -1353,13 +1364,13 @@
     return result;
 }
 
-Color RenderStyle::visitedDependentColor(int colorProperty) const
+StyleColor RenderStyle::visitedDependentColor(int colorProperty) const
 {
-    Color unvisitedColor = colorIncludingFallback(colorProperty, false);
+    StyleColor unvisitedColor = colorIncludingFallback(colorProperty, false);
     if (insideLink() != InsideVisitedLink)
         return unvisitedColor;
 
-    Color visitedColor = colorIncludingFallback(colorProperty, true);
+    StyleColor visitedColor = colorIncludingFallback(colorProperty, true);
 
     // Text decoration color validity is preserved (checked in RenderObject::decorationColor).
     if (colorProperty == CSSPropertyTextDecorationColor)
@@ -1373,8 +1384,12 @@
     if (colorProperty == CSSPropertyBackgroundColor && visitedColor == Color::transparent)
         return unvisitedColor;
 
-    // Take the alpha from the unvisited color, but get the RGB values from the visited color.
-    return Color(visitedColor.red(), visitedColor.green(), visitedColor.blue(), unvisitedColor.alpha());
+    // Unless the visitied color is 'currentColor'; take the alpha from the unvisited color,
+    // but get the RGB values from the visited color.
+    if (visitedColor.isCurrentColor())
+        return visitedColor;
+
+    return StyleColor(visitedColor.red(), visitedColor.green(), visitedColor.blue(), unvisitedColor.alpha());
 }
 
 const BorderValue& RenderStyle::borderBefore() const
diff --git a/Source/core/rendering/style/RenderStyle.h b/Source/core/rendering/style/RenderStyle.h
index f4dd5f5..dc21479 100644
--- a/Source/core/rendering/style/RenderStyle.h
+++ b/Source/core/rendering/style/RenderStyle.h
@@ -29,6 +29,7 @@
 #include "core/css/CSSLineBoxContainValue.h"
 #include "core/css/CSSPrimitiveValue.h"
 #include "core/css/LengthFunctions.h"
+#include "core/css/StyleColor.h"
 #include "core/platform/Length.h"
 #include "core/platform/LengthBox.h"
 #include "core/platform/LengthSize.h"
@@ -114,12 +115,9 @@
     friend class EditingStyle; // Editing has to only reveal unvisited info.
     friend class CSSComputedStyleDeclaration; // Ignores visited styles, so needs to be able to see unvisited info.
     friend class PropertyWrapperMaybeInvalidColor; // Used by CSS animations. We can't allow them to animate based off visited colors.
-    friend class RenderSVGResource; // FIXME: Needs to alter the visited state by hand. Should clean the SVG code up and move it into RenderStyle perhaps.
-    friend class RenderTreeAsText; // FIXME: Only needed so the render tree can keep lying and dump the wrong colors.  Rebaselining would allow this to be yanked.
     friend class StyleBuilderFunctions; // Sets color styles
     friend class StyleBuilder; // FIXME: Revove this! StyleBuilder::oldApplyProperty reads color().
     friend class StyleResolver; // Sets members directly.
-    friend class StyleResolverState; // Needs to read color() to compute currentColor.
     friend class CachedUAStyle; // Saves Border/Background information for later comparison.
 protected:
 
@@ -217,7 +215,6 @@
                 && _pseudoBits == other._pseudoBits
                 && _unicodeBidi == other._unicodeBidi
                 && explicitInheritance == other.explicitInheritance
-                && currentColor == other.currentColor
                 && unique == other.unique
                 && emptyState == other.emptyState
                 && firstChildState == other.firstChildState
@@ -246,7 +243,6 @@
         unsigned _styleType : 6; // PseudoId
         unsigned _pseudoBits : 8;
         unsigned explicitInheritance : 1; // Explicitly inherits a non-inherited property
-        unsigned currentColor : 1; // At least one color has the value 'currentColor'
         unsigned unique : 1; // Style can not be shared.
         unsigned emptyState : 1;
         unsigned firstChildState : 1;
@@ -308,7 +304,6 @@
         noninherited_flags._styleType = NOPSEUDO;
         noninherited_flags._pseudoBits = 0;
         noninherited_flags.explicitInheritance = false;
-        noninherited_flags.currentColor = false;
         noninherited_flags.unique = false;
         noninherited_flags.emptyState = false;
         noninherited_flags.firstChildState = false;
@@ -378,8 +373,8 @@
 
     bool hasBackground() const
     {
-        Color color = visitedDependentColor(CSSPropertyBackgroundColor);
-        if (color.isValid() && color.alpha())
+        StyleColor color = visitedDependentColor(CSSPropertyBackgroundColor);
+        if ((color.isValid() && color.alpha()) || color.isCurrentColor())
             return true;
         return hasBackgroundImage();
     }
@@ -881,7 +876,7 @@
 
     LineBoxContain lineBoxContain() const { return rareInheritedData->m_lineBoxContain; }
     const LineClampValue& lineClamp() const { return rareNonInheritedData->lineClamp; }
-    Color tapHighlightColor() const { return rareInheritedData->tapHighlightColor; }
+    StyleColor tapHighlightColor() const { return rareInheritedData->tapHighlightColor; }
     ETextSecurity textSecurity() const { return static_cast<ETextSecurity>(rareInheritedData->textSecurity); }
 
     WritingMode writingMode() const { return static_cast<WritingMode>(inherited_flags.m_writingMode); }
@@ -958,7 +953,7 @@
     void resetBorderBottomLeftRadius() { SET_VAR(surround, border.m_bottomLeft, initialBorderRadius()); }
     void resetBorderBottomRightRadius() { SET_VAR(surround, border.m_bottomRight, initialBorderRadius()); }
 
-    void setBackgroundColor(const Color& v) { SET_VAR(m_background, m_color, v); }
+    void setBackgroundColor(const StyleColor& v) { SET_VAR(m_background, m_color, v); }
 
     void setBackgroundXPosition(Length length) { SET_VAR(m_background, m_background.m_xPosition, length); }
     void setBackgroundYPosition(Length length) { SET_VAR(m_background, m_background.m_yPosition, length); }
@@ -996,21 +991,21 @@
 
     void setBorderLeftWidth(unsigned v) { SET_VAR(surround, border.m_left.m_width, v); }
     void setBorderLeftStyle(EBorderStyle v) { SET_VAR(surround, border.m_left.m_style, v); }
-    void setBorderLeftColor(const Color& v) { SET_BORDERVALUE_COLOR(surround, border.m_left, v); }
+    void setBorderLeftColor(const StyleColor& v) { SET_BORDERVALUE_COLOR(surround, border.m_left, v); }
     void setBorderRightWidth(unsigned v) { SET_VAR(surround, border.m_right.m_width, v); }
     void setBorderRightStyle(EBorderStyle v) { SET_VAR(surround, border.m_right.m_style, v); }
-    void setBorderRightColor(const Color& v) { SET_BORDERVALUE_COLOR(surround, border.m_right, v); }
+    void setBorderRightColor(const StyleColor& v) { SET_BORDERVALUE_COLOR(surround, border.m_right, v); }
     void setBorderTopWidth(unsigned v) { SET_VAR(surround, border.m_top.m_width, v); }
     void setBorderTopStyle(EBorderStyle v) { SET_VAR(surround, border.m_top.m_style, v); }
-    void setBorderTopColor(const Color& v) { SET_BORDERVALUE_COLOR(surround, border.m_top, v); }
+    void setBorderTopColor(const StyleColor& v) { SET_BORDERVALUE_COLOR(surround, border.m_top, v); }
     void setBorderBottomWidth(unsigned v) { SET_VAR(surround, border.m_bottom.m_width, v); }
     void setBorderBottomStyle(EBorderStyle v) { SET_VAR(surround, border.m_bottom.m_style, v); }
-    void setBorderBottomColor(const Color& v) { SET_BORDERVALUE_COLOR(surround, border.m_bottom, v); }
+    void setBorderBottomColor(const StyleColor& v) { SET_BORDERVALUE_COLOR(surround, border.m_bottom, v); }
 
     void setOutlineWidth(unsigned short v) { SET_VAR(m_background, m_outline.m_width, v); }
     void setOutlineStyleIsAuto(OutlineIsAuto isAuto) { SET_VAR(m_background, m_outline.m_isAuto, isAuto); }
     void setOutlineStyle(EBorderStyle v) { SET_VAR(m_background, m_outline.m_style, v); }
-    void setOutlineColor(const Color& v) { SET_BORDERVALUE_COLOR(m_background, m_outline, v); }
+    void setOutlineColor(const StyleColor& v) { SET_BORDERVALUE_COLOR(m_background, m_outline, v); }
 
     void setOverflowX(EOverflow v) { noninherited_flags._overflowX = v; }
     void setOverflowY(EOverflow v) { noninherited_flags._overflowY = v; }
@@ -1041,7 +1036,7 @@
         setFontSize(fontDescription().specifiedSize());
     }
 
-    void setColor(const Color&);
+    void setColor(const StyleColor&);
     void setTextIndent(Length v) { SET_VAR(rareInheritedData, indent, v); }
 #if ENABLE(CSS3_TEXT)
     void setTextIndentLine(TextIndentLine v) { SET_VAR(rareInheritedData, m_textIndentLine, v); }
@@ -1158,9 +1153,9 @@
     // CSS3 Setters
     void setOutlineOffset(int v) { SET_VAR(m_background, m_outline.m_offset, v); }
     void setTextShadow(PassOwnPtr<ShadowData>, bool add = false);
-    void setTextStrokeColor(const Color& c) { SET_VAR(rareInheritedData, textStrokeColor, c); }
+    void setTextStrokeColor(const StyleColor& c) { SET_VAR(rareInheritedData, textStrokeColor, c); }
     void setTextStrokeWidth(float w) { SET_VAR(rareInheritedData, textStrokeWidth, w); }
-    void setTextFillColor(const Color& c) { SET_VAR(rareInheritedData, textFillColor, c); }
+    void setTextFillColor(const StyleColor& c) { SET_VAR(rareInheritedData, textFillColor, c); }
     void setOpacity(float f) { float v = clampTo<float>(f, 0, 1); SET_VAR(rareNonInheritedData, opacity, v); }
     void setAppearance(ControlPart a) { SET_VAR(rareNonInheritedData, m_appearance, a); }
     // For valid values of box-align see http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/#alignment
@@ -1230,7 +1225,7 @@
     void setHasAutoColumnCount() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoCount, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_count, 0); }
     void setColumnGap(float f) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_normalGap, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_gap, f); }
     void setHasNormalColumnGap() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_normalGap, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_gap, 0); }
-    void setColumnRuleColor(const Color& c) { SET_BORDERVALUE_COLOR(rareNonInheritedData.access()->m_multiCol, m_rule, c); }
+    void setColumnRuleColor(const StyleColor& c) { SET_BORDERVALUE_COLOR(rareNonInheritedData.access()->m_multiCol, m_rule, c); }
     void setColumnRuleStyle(EBorderStyle b) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.m_style, b); }
     void setColumnRuleWidth(unsigned short w) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.m_width, w); }
     void resetColumnRule() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule, BorderValue()); }
@@ -1249,8 +1244,8 @@
     void setTransformOriginZ(float f) { SET_VAR(rareNonInheritedData.access()->m_transform, m_z, f); }
     void setSpeak(ESpeak s) { SET_VAR(rareInheritedData, speak, s); }
     void setTextCombine(TextCombine v) { SET_VAR(rareNonInheritedData, m_textCombine, v); }
-    void setTextDecorationColor(const Color& c) { SET_VAR(rareNonInheritedData, m_textDecorationColor, c); }
-    void setTextEmphasisColor(const Color& c) { SET_VAR(rareInheritedData, textEmphasisColor, c); }
+    void setTextDecorationColor(const StyleColor& c) { SET_VAR(rareNonInheritedData, m_textDecorationColor, c); }
+    void setTextEmphasisColor(const StyleColor& c) { SET_VAR(rareInheritedData, textEmphasisColor, c); }
     void setTextEmphasisFill(TextEmphasisFill fill) { SET_VAR(rareInheritedData, textEmphasisFill, fill); }
     void setTextEmphasisMark(TextEmphasisMark mark) { SET_VAR(rareInheritedData, textEmphasisMark, mark); }
     void setTextEmphasisCustomMark(const AtomicString& mark) { SET_VAR(rareInheritedData, textEmphasisCustomMark, mark); }
@@ -1305,7 +1300,7 @@
 
     void setLineBoxContain(LineBoxContain c) { SET_VAR(rareInheritedData, m_lineBoxContain, c); }
     void setLineClamp(LineClampValue c) { SET_VAR(rareNonInheritedData, lineClamp, c); }
-    void setTapHighlightColor(const Color& c) { SET_VAR(rareInheritedData, tapHighlightColor, c); }
+    void setTapHighlightColor(const StyleColor& c) { SET_VAR(rareInheritedData, tapHighlightColor, c); }
     void setTextSecurity(ETextSecurity aTextSecurity) { SET_VAR(rareInheritedData, textSecurity, aTextSecurity); }
     void setTouchAction(TouchAction t) { SET_VAR(rareNonInheritedData, m_touchAction, t); }
 
@@ -1313,14 +1308,14 @@
     SVGRenderStyle* accessSVGStyle() { return m_svgStyle.access(); }
 
     const SVGPaint::SVGPaintType& fillPaintType() const { return svgStyle()->fillPaintType(); }
-    Color fillPaintColor() const { return svgStyle()->fillPaintColor(); }
-    void setFillPaintColor(const Color& c) { accessSVGStyle()->setFillPaint(SVGPaint::SVG_PAINTTYPE_RGBCOLOR, c, ""); }
+    StyleColor fillPaintColor() const { return svgStyle()->fillPaintColor(); }
+    void setFillPaintColor(const StyleColor& c) { accessSVGStyle()->setFillPaint(SVGPaint::SVG_PAINTTYPE_RGBCOLOR, c.color(), ""); }
     float fillOpacity() const { return svgStyle()->fillOpacity(); }
     void setFillOpacity(float f) { accessSVGStyle()->setFillOpacity(f); }
 
     const SVGPaint::SVGPaintType& strokePaintType() const { return svgStyle()->strokePaintType(); }
-    Color strokePaintColor() const { return svgStyle()->strokePaintColor(); }
-    void setStrokePaintColor(const Color& c) { accessSVGStyle()->setStrokePaint(SVGPaint::SVG_PAINTTYPE_RGBCOLOR, c, ""); }
+    StyleColor strokePaintColor() const { return svgStyle()->strokePaintColor(); }
+    void setStrokePaintColor(const StyleColor& c) { accessSVGStyle()->setStrokePaint(SVGPaint::SVG_PAINTTYPE_RGBCOLOR, c.color(), ""); }
     float strokeOpacity() const { return svgStyle()->strokeOpacity(); }
     void setStrokeOpacity(float f) { accessSVGStyle()->setStrokeOpacity(f); }
     SVGLength strokeWidth() const { return svgStyle()->strokeWidth(); }
@@ -1336,9 +1331,9 @@
     float stopOpacity() const { return svgStyle()->stopOpacity(); }
     void setStopOpacity(float f) { accessSVGStyle()->setStopOpacity(f); }
 
-    void setStopColor(const Color& c) { accessSVGStyle()->setStopColor(c); }
-    void setFloodColor(const Color& c) { accessSVGStyle()->setFloodColor(c); }
-    void setLightingColor(const Color& c) { accessSVGStyle()->setLightingColor(c); }
+    void setStopColor(const StyleColor& c) { accessSVGStyle()->setStopColor(c.color()); }
+    void setFloodColor(const StyleColor& c) { accessSVGStyle()->setFloodColor(c.color()); }
+    void setLightingColor(const StyleColor& c) { accessSVGStyle()->setLightingColor(c.color()); }
 
     SVGLength baselineShiftValue() const { return svgStyle()->baselineShiftValue(); }
     void setBaselineShiftValue(SVGLength s) { accessSVGStyle()->setBaselineShiftValue(s); }
@@ -1441,14 +1436,11 @@
     bool lastChildState() const { return noninherited_flags.lastChildState; }
     void setLastChildState() { setUnique(); noninherited_flags.lastChildState = true; }
 
-    Color visitedDependentColor(int colorProperty) const;
+    StyleColor visitedDependentColor(int colorProperty) const;
 
     void setHasExplicitlyInheritedProperties() { noninherited_flags.explicitInheritance = true; }
     bool hasExplicitlyInheritedProperties() const { return noninherited_flags.explicitInheritance; }
 
-    void setHasCurrentColor() { noninherited_flags.currentColor = true; }
-    bool hasCurrentColor() const { return noninherited_flags.currentColor; }
-
     // Initial values for all the properties
     static EBorderCollapse initialBorderCollapse() { return BSEPARATE; }
     static EBorderStyle initialBorderStyle() { return BNONE; }
@@ -1632,18 +1624,18 @@
     static const FilterOperations& initialFilter() { DEFINE_STATIC_LOCAL(FilterOperations, ops, ()); return ops; }
     static BlendMode initialBlendMode() { return BlendModeNormal; }
 private:
-    void setVisitedLinkColor(const Color&);
-    void setVisitedLinkBackgroundColor(const Color& v) { SET_VAR(rareNonInheritedData, m_visitedLinkBackgroundColor, v); }
-    void setVisitedLinkBorderLeftColor(const Color& v) { SET_VAR(rareNonInheritedData, m_visitedLinkBorderLeftColor, v); }
-    void setVisitedLinkBorderRightColor(const Color& v) { SET_VAR(rareNonInheritedData, m_visitedLinkBorderRightColor, v); }
-    void setVisitedLinkBorderBottomColor(const Color& v) { SET_VAR(rareNonInheritedData, m_visitedLinkBorderBottomColor, v); }
-    void setVisitedLinkBorderTopColor(const Color& v) { SET_VAR(rareNonInheritedData, m_visitedLinkBorderTopColor, v); }
-    void setVisitedLinkOutlineColor(const Color& v) { SET_VAR(rareNonInheritedData, m_visitedLinkOutlineColor, v); }
-    void setVisitedLinkColumnRuleColor(const Color& v) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_visitedLinkColumnRuleColor, v); }
-    void setVisitedLinkTextDecorationColor(const Color& v) { SET_VAR(rareNonInheritedData, m_visitedLinkTextDecorationColor, v); }
-    void setVisitedLinkTextEmphasisColor(const Color& v) { SET_VAR(rareInheritedData, visitedLinkTextEmphasisColor, v); }
-    void setVisitedLinkTextFillColor(const Color& v) { SET_VAR(rareInheritedData, visitedLinkTextFillColor, v); }
-    void setVisitedLinkTextStrokeColor(const Color& v) { SET_VAR(rareInheritedData, visitedLinkTextStrokeColor, v); }
+    void setVisitedLinkColor(const StyleColor&);
+    void setVisitedLinkBackgroundColor(const StyleColor& v) { SET_VAR(rareNonInheritedData, m_visitedLinkBackgroundColor, v); }
+    void setVisitedLinkBorderLeftColor(const StyleColor& v) { SET_VAR(rareNonInheritedData, m_visitedLinkBorderLeftColor, v); }
+    void setVisitedLinkBorderRightColor(const StyleColor& v) { SET_VAR(rareNonInheritedData, m_visitedLinkBorderRightColor, v); }
+    void setVisitedLinkBorderBottomColor(const StyleColor& v) { SET_VAR(rareNonInheritedData, m_visitedLinkBorderBottomColor, v); }
+    void setVisitedLinkBorderTopColor(const StyleColor& v) { SET_VAR(rareNonInheritedData, m_visitedLinkBorderTopColor, v); }
+    void setVisitedLinkOutlineColor(const StyleColor& v) { SET_VAR(rareNonInheritedData, m_visitedLinkOutlineColor, v); }
+    void setVisitedLinkColumnRuleColor(const StyleColor& v) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_visitedLinkColumnRuleColor, v); }
+    void setVisitedLinkTextDecorationColor(const StyleColor& v) { SET_VAR(rareNonInheritedData, m_visitedLinkTextDecorationColor, v); }
+    void setVisitedLinkTextEmphasisColor(const StyleColor& v) { SET_VAR(rareInheritedData, visitedLinkTextEmphasisColor, v); }
+    void setVisitedLinkTextFillColor(const StyleColor& v) { SET_VAR(rareInheritedData, visitedLinkTextFillColor, v); }
+    void setVisitedLinkTextStrokeColor(const StyleColor& v) { SET_VAR(rareInheritedData, visitedLinkTextStrokeColor, v); }
 
     void inheritUnicodeBidiFrom(const RenderStyle* parent) { noninherited_flags._unicodeBidi = parent->noninherited_flags._unicodeBidi; }
     void getShadowExtent(const ShadowData*, LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const;
@@ -1671,37 +1663,37 @@
     }
 
     // Color accessors are all private to make sure callers use visitedDependentColor instead to access them.
-    Color invalidColor() const { static Color invalid; return invalid; }
-    Color borderLeftColor() const { return surround->border.left().color(); }
-    Color borderRightColor() const { return surround->border.right().color(); }
-    Color borderTopColor() const { return surround->border.top().color(); }
-    Color borderBottomColor() const { return surround->border.bottom().color(); }
-    Color backgroundColor() const { return m_background->color(); }
-    Color color() const;
-    Color columnRuleColor() const { return rareNonInheritedData->m_multiCol->m_rule.color(); }
-    Color outlineColor() const { return m_background->outline().color(); }
-    Color textEmphasisColor() const { return rareInheritedData->textEmphasisColor; }
-    Color textFillColor() const { return rareInheritedData->textFillColor; }
-    Color textStrokeColor() const { return rareInheritedData->textStrokeColor; }
-    Color visitedLinkColor() const;
-    Color visitedLinkBackgroundColor() const { return rareNonInheritedData->m_visitedLinkBackgroundColor; }
-    Color visitedLinkBorderLeftColor() const { return rareNonInheritedData->m_visitedLinkBorderLeftColor; }
-    Color visitedLinkBorderRightColor() const { return rareNonInheritedData->m_visitedLinkBorderRightColor; }
-    Color visitedLinkBorderBottomColor() const { return rareNonInheritedData->m_visitedLinkBorderBottomColor; }
-    Color visitedLinkBorderTopColor() const { return rareNonInheritedData->m_visitedLinkBorderTopColor; }
-    Color visitedLinkOutlineColor() const { return rareNonInheritedData->m_visitedLinkOutlineColor; }
-    Color visitedLinkColumnRuleColor() const { return rareNonInheritedData->m_multiCol->m_visitedLinkColumnRuleColor; }
-    Color textDecorationColor() const { return rareNonInheritedData->m_textDecorationColor; }
-    Color visitedLinkTextDecorationColor() const { return rareNonInheritedData->m_visitedLinkTextDecorationColor; }
-    Color visitedLinkTextEmphasisColor() const { return rareInheritedData->visitedLinkTextEmphasisColor; }
-    Color visitedLinkTextFillColor() const { return rareInheritedData->visitedLinkTextFillColor; }
-    Color visitedLinkTextStrokeColor() const { return rareInheritedData->visitedLinkTextStrokeColor; }
+    StyleColor invalidColor() const { static Color invalid; return invalid; }
+    StyleColor borderLeftColor() const { return surround->border.left().color(); }
+    StyleColor borderRightColor() const { return surround->border.right().color(); }
+    StyleColor borderTopColor() const { return surround->border.top().color(); }
+    StyleColor borderBottomColor() const { return surround->border.bottom().color(); }
+    StyleColor backgroundColor() const { return m_background->color(); }
+    StyleColor color() const;
+    StyleColor columnRuleColor() const { return rareNonInheritedData->m_multiCol->m_rule.color(); }
+    StyleColor outlineColor() const { return m_background->outline().color(); }
+    StyleColor textEmphasisColor() const { return rareInheritedData->textEmphasisColor; }
+    StyleColor textFillColor() const { return rareInheritedData->textFillColor; }
+    StyleColor textStrokeColor() const { return rareInheritedData->textStrokeColor; }
+    StyleColor visitedLinkColor() const;
+    StyleColor visitedLinkBackgroundColor() const { return rareNonInheritedData->m_visitedLinkBackgroundColor; }
+    StyleColor visitedLinkBorderLeftColor() const { return rareNonInheritedData->m_visitedLinkBorderLeftColor; }
+    StyleColor visitedLinkBorderRightColor() const { return rareNonInheritedData->m_visitedLinkBorderRightColor; }
+    StyleColor visitedLinkBorderBottomColor() const { return rareNonInheritedData->m_visitedLinkBorderBottomColor; }
+    StyleColor visitedLinkBorderTopColor() const { return rareNonInheritedData->m_visitedLinkBorderTopColor; }
+    StyleColor visitedLinkOutlineColor() const { return rareNonInheritedData->m_visitedLinkOutlineColor; }
+    StyleColor visitedLinkColumnRuleColor() const { return rareNonInheritedData->m_multiCol->m_visitedLinkColumnRuleColor; }
+    StyleColor textDecorationColor() const { return rareNonInheritedData->m_textDecorationColor; }
+    StyleColor visitedLinkTextDecorationColor() const { return rareNonInheritedData->m_visitedLinkTextDecorationColor; }
+    StyleColor visitedLinkTextEmphasisColor() const { return rareInheritedData->visitedLinkTextEmphasisColor; }
+    StyleColor visitedLinkTextFillColor() const { return rareInheritedData->visitedLinkTextFillColor; }
+    StyleColor visitedLinkTextStrokeColor() const { return rareInheritedData->visitedLinkTextStrokeColor; }
 
-    Color colorIncludingFallback(int colorProperty, bool visitedLink) const;
+    StyleColor colorIncludingFallback(int colorProperty, bool visitedLink) const;
 
-    Color stopColor() const { return svgStyle()->stopColor(); }
-    Color floodColor() const { return svgStyle()->floodColor(); }
-    Color lightingColor() const { return svgStyle()->lightingColor(); }
+    StyleColor stopColor() const { return svgStyle()->stopColor(); }
+    StyleColor floodColor() const { return svgStyle()->floodColor(); }
+    StyleColor lightingColor() const { return svgStyle()->lightingColor(); }
 
     void appendContent(PassOwnPtr<ContentData>);
 };
diff --git a/Source/core/rendering/style/ShadowData.h b/Source/core/rendering/style/ShadowData.h
index 9c98c08..bd6bf3c 100644
--- a/Source/core/rendering/style/ShadowData.h
+++ b/Source/core/rendering/style/ShadowData.h
@@ -25,7 +25,7 @@
 #ifndef ShadowData_h
 #define ShadowData_h
 
-#include "core/platform/graphics/Color.h"
+#include "core/css/StyleColor.h"
 #include "core/platform/graphics/FloatRect.h"
 #include "core/platform/graphics/LayoutRect.h"
 #include <wtf/OwnPtr.h>
@@ -40,7 +40,7 @@
     WTF_MAKE_FAST_ALLOCATED;
 public:
     static PassOwnPtr<ShadowData> create() { return adoptPtr(new ShadowData); }
-    static PassOwnPtr<ShadowData> create(const IntPoint& location, int blur, int spread, ShadowStyle style, const Color& color)
+    static PassOwnPtr<ShadowData> create(const IntPoint& location, int blur, int spread, ShadowStyle style, const StyleColor& color)
     {
         return adoptPtr(new ShadowData(location, blur, spread, style, color));
     }
@@ -59,7 +59,7 @@
     int blur() const { return m_blur; }
     int spread() const { return m_spread; }
     ShadowStyle style() const { return m_style; }
-    const Color& color() const { return m_color; }
+    const StyleColor& color() const { return m_color; }
 
     const ShadowData* next() const { return m_next.get(); }
     void setNext(PassOwnPtr<ShadowData> shadow) { m_next = shadow; }
@@ -75,7 +75,7 @@
     {
     }
 
-    ShadowData(const IntPoint& location, int blur, int spread, ShadowStyle style, const Color& color)
+    ShadowData(const IntPoint& location, int blur, int spread, ShadowStyle style, const StyleColor& color)
         : m_location(location)
         , m_blur(blur)
         , m_spread(spread)
@@ -89,7 +89,7 @@
     IntPoint m_location;
     int m_blur;
     int m_spread;
-    Color m_color;
+    StyleColor m_color;
     ShadowStyle m_style;
     OwnPtr<ShadowData> m_next;
 };
diff --git a/Source/core/rendering/style/StyleBackgroundData.h b/Source/core/rendering/style/StyleBackgroundData.h
index d2d834a..6c58b02 100644
--- a/Source/core/rendering/style/StyleBackgroundData.h
+++ b/Source/core/rendering/style/StyleBackgroundData.h
@@ -25,7 +25,7 @@
 #ifndef StyleBackgroundData_h
 #define StyleBackgroundData_h
 
-#include "core/platform/graphics/Color.h"
+#include "core/css/StyleColor.h"
 #include "core/rendering/style/FillLayer.h"
 #include "core/rendering/style/OutlineValue.h"
 #include <wtf/PassRefPtr.h>
@@ -46,7 +46,7 @@
     }
 
     const FillLayer& background() const { return m_background; }
-    const Color& color() const { return m_color; }
+    const StyleColor& color() const { return m_color; }
     const OutlineValue& outline() const { return m_outline; }
 
 private:
@@ -56,7 +56,7 @@
     StyleBackgroundData(const StyleBackgroundData&); 
 
     FillLayer m_background;
-    Color m_color;
+    StyleColor m_color;
     OutlineValue m_outline;
 };
 
diff --git a/Source/core/rendering/style/StyleImage.h b/Source/core/rendering/style/StyleImage.h
index b2578b5..bea910e 100644
--- a/Source/core/rendering/style/StyleImage.h
+++ b/Source/core/rendering/style/StyleImage.h
@@ -73,7 +73,7 @@
     ALWAYS_INLINE bool isGeneratedImage() const { return m_isGeneratedImage; }
     ALWAYS_INLINE bool isCachedImageSet() const { return m_isCachedImageSet; }
     
-    static  bool imagesEquivalent(StyleImage* image1, StyleImage* image2)
+    static bool imagesEquivalent(const StyleImage* image1, const StyleImage* image2)
     {
         if (image1 != image2) {
             if (!image1 || !image2)
diff --git a/Source/core/rendering/style/StyleInheritedData.h b/Source/core/rendering/style/StyleInheritedData.h
index ac7a73f..3cb6674 100644
--- a/Source/core/rendering/style/StyleInheritedData.h
+++ b/Source/core/rendering/style/StyleInheritedData.h
@@ -25,8 +25,8 @@
 #ifndef StyleInheritedData_h
 #define StyleInheritedData_h
 
+#include "core/css/StyleColor.h"
 #include "core/platform/Length.h"
-#include "core/platform/graphics/Color.h"
 #include "core/platform/graphics/Font.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
@@ -54,8 +54,8 @@
     Length line_height;
 
     Font font;
-    Color color;
-    Color visitedLinkColor;
+    StyleColor color;
+    StyleColor visitedLinkColor;
 
 private:
     StyleInheritedData();
diff --git a/Source/core/rendering/style/StyleMultiColData.h b/Source/core/rendering/style/StyleMultiColData.h
index 1b50250..d4531b3 100644
--- a/Source/core/rendering/style/StyleMultiColData.h
+++ b/Source/core/rendering/style/StyleMultiColData.h
@@ -25,6 +25,7 @@
 #ifndef StyleMultiColData_h
 #define StyleMultiColData_h
 
+#include "core/css/StyleColor.h"
 #include "core/platform/Length.h"
 #include "core/rendering/style/BorderValue.h"
 #include "core/rendering/style/RenderStyleConstants.h"
@@ -57,7 +58,7 @@
     unsigned short m_count;
     float m_gap;
     BorderValue m_rule;
-    Color m_visitedLinkColumnRuleColor;
+    StyleColor m_visitedLinkColumnRuleColor;
 
     bool m_autoWidth : 1;
     bool m_autoCount : 1;
diff --git a/Source/core/rendering/style/StyleRareInheritedData.cpp b/Source/core/rendering/style/StyleRareInheritedData.cpp
index 4154ddb..ea3728e 100644
--- a/Source/core/rendering/style/StyleRareInheritedData.cpp
+++ b/Source/core/rendering/style/StyleRareInheritedData.cpp
@@ -33,9 +33,9 @@
 
 struct SameSizeAsStyleRareInheritedData : public RefCounted<SameSizeAsStyleRareInheritedData> {
     void* styleImage;
-    Color firstColor;
+    StyleColor firstColor;
     float firstFloat;
-    Color colors[5];
+    StyleColor colors[5];
     void* ownPtrs[1];
     AtomicString atomicStrings[5];
     void* refPtrs[2];
@@ -46,7 +46,7 @@
     unsigned unsigneds[1];
     short hyphenationShorts[3];
 
-    Color touchColors;
+    StyleColor touchColors;
 
     void* variableDataRefs[1];
 };
diff --git a/Source/core/rendering/style/StyleRareInheritedData.h b/Source/core/rendering/style/StyleRareInheritedData.h
index 1640c30..8d914e3 100644
--- a/Source/core/rendering/style/StyleRareInheritedData.h
+++ b/Source/core/rendering/style/StyleRareInheritedData.h
@@ -25,8 +25,8 @@
 #ifndef StyleRareInheritedData_h
 #define StyleRareInheritedData_h
 
+#include "core/css/StyleColor.h"
 #include "core/platform/Length.h"
-#include "core/platform/graphics/Color.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/text/AtomicString.h>
@@ -59,14 +59,14 @@
 
     RefPtr<StyleImage> listStyleImage;
 
-    Color textStrokeColor;
+    StyleColor textStrokeColor;
     float textStrokeWidth;
-    Color textFillColor;
-    Color textEmphasisColor;
+    StyleColor textFillColor;
+    StyleColor textEmphasisColor;
 
-    Color visitedLinkTextStrokeColor;
-    Color visitedLinkTextFillColor;
-    Color visitedLinkTextEmphasisColor;
+    StyleColor visitedLinkTextStrokeColor;
+    StyleColor visitedLinkTextFillColor;
+    StyleColor visitedLinkTextEmphasisColor;
 
     OwnPtr<ShadowData> textShadow; // Our text shadow information for shadowed text drawing.
     AtomicString highlight; // Apple-specific extension for custom highlight rendering.
@@ -121,7 +121,7 @@
     AtomicString m_lineGrid;
     unsigned m_tabSize;
 
-    Color tapHighlightColor;
+    StyleColor tapHighlightColor;
 
     DataRef<StyleVariableData> m_variables;
 
diff --git a/Source/core/rendering/style/StyleRareNonInheritedData.h b/Source/core/rendering/style/StyleRareNonInheritedData.h
index 6f024ed..85c0a8f 100644
--- a/Source/core/rendering/style/StyleRareNonInheritedData.h
+++ b/Source/core/rendering/style/StyleRareNonInheritedData.h
@@ -25,6 +25,7 @@
 #ifndef StyleRareNonInheritedData_h
 #define StyleRareNonInheritedData_h
 
+#include "core/css/StyleColor.h"
 #include "core/rendering/ClipPathOperation.h"
 #include "core/rendering/style/BasicShapes.h"
 #include "core/rendering/style/CounterDirectives.h"
@@ -130,14 +131,14 @@
 
     RefPtr<ClipPathOperation> m_clipPath;
 
-    Color m_textDecorationColor;
-    Color m_visitedLinkTextDecorationColor;
-    Color m_visitedLinkBackgroundColor;
-    Color m_visitedLinkOutlineColor;
-    Color m_visitedLinkBorderLeftColor;
-    Color m_visitedLinkBorderRightColor;
-    Color m_visitedLinkBorderTopColor;
-    Color m_visitedLinkBorderBottomColor;
+    StyleColor m_textDecorationColor;
+    StyleColor m_visitedLinkTextDecorationColor;
+    StyleColor m_visitedLinkBackgroundColor;
+    StyleColor m_visitedLinkOutlineColor;
+    StyleColor m_visitedLinkBorderLeftColor;
+    StyleColor m_visitedLinkBorderRightColor;
+    StyleColor m_visitedLinkBorderTopColor;
+    StyleColor m_visitedLinkBorderBottomColor;
 
     int m_order;
 
diff --git a/Source/core/rendering/svg/RenderSVGResource.cpp b/Source/core/rendering/svg/RenderSVGResource.cpp
index 6b13ce7..9ecdfdf 100644
--- a/Source/core/rendering/svg/RenderSVGResource.cpp
+++ b/Source/core/rendering/svg/RenderSVGResource.cpp
@@ -34,7 +34,7 @@
 
 namespace WebCore {
 
-static inline bool inheritColorFromParentStyleIfNeeded(RenderObject* object, bool applyToFill, Color& color)
+static inline bool inheritColorFromParentStyleIfNeeded(RenderObject* object, bool applyToFill, StyleColor& color)
 {
     if (color.isValid())
         return true;
@@ -45,7 +45,7 @@
     return true;
 }
 
-static inline RenderSVGResource* requestPaintingResource(RenderSVGResourceMode mode, RenderObject* object, const RenderStyle* style, Color& fallbackColor)
+static inline RenderSVGResource* requestPaintingResource(RenderSVGResourceMode mode, RenderObject* object, const RenderStyle* style, StyleColor& fallbackColor)
 {
     ASSERT(object);
     ASSERT(style);
@@ -80,7 +80,7 @@
     if (paintType == SVGPaint::SVG_PAINTTYPE_NONE)
         return 0;
 
-    Color color;
+    StyleColor color;
     switch (paintType) {
     case SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR:
     case SVGPaint::SVG_PAINTTYPE_RGBCOLOR:
@@ -100,8 +100,7 @@
         // For SVG_PAINTTYPE_CURRENTCOLOR, 'color' already contains the 'visitedColor'.
         if (visitedPaintType < SVGPaint::SVG_PAINTTYPE_URI_NONE && visitedPaintType != SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR) {
             const Color& visitedColor = applyToFill ? svgStyle->visitedLinkFillPaintColor() : svgStyle->visitedLinkStrokePaintColor();
-            if (visitedColor.isValid())
-                color = Color(visitedColor.red(), visitedColor.green(), visitedColor.blue(), color.alpha());
+            color = Color(visitedColor.red(), visitedColor.green(), visitedColor.blue(), color.alpha());
         }
     }
 
@@ -111,7 +110,7 @@
         if (!inheritColorFromParentStyleIfNeeded(object, applyToFill, color))
             return 0;
 
-        colorResource->setColor(color);
+        colorResource->setColor(color.color());
         return colorResource;
     }
 
@@ -121,7 +120,7 @@
         if (paintType == SVGPaint::SVG_PAINTTYPE_URI_NONE || !inheritColorFromParentStyleIfNeeded(object, applyToFill, color))
             return 0;
 
-        colorResource->setColor(color);
+        colorResource->setColor(color.color());
         return colorResource;
     }
 
@@ -131,7 +130,7 @@
         if (!inheritColorFromParentStyleIfNeeded(object, applyToFill, color))
             return 0;
 
-        colorResource->setColor(color);
+        colorResource->setColor(color.color());
         return colorResource;
     }
 
@@ -141,12 +140,12 @@
     return uriResource;
 }
 
-RenderSVGResource* RenderSVGResource::fillPaintingResource(RenderObject* object, const RenderStyle* style, Color& fallbackColor)
+RenderSVGResource* RenderSVGResource::fillPaintingResource(RenderObject* object, const RenderStyle* style, StyleColor& fallbackColor)
 {
     return requestPaintingResource(ApplyToFillMode, object, style, fallbackColor);
 }
 
-RenderSVGResource* RenderSVGResource::strokePaintingResource(RenderObject* object, const RenderStyle* style, Color& fallbackColor)
+RenderSVGResource* RenderSVGResource::strokePaintingResource(RenderObject* object, const RenderStyle* style, StyleColor& fallbackColor)
 {
     return requestPaintingResource(ApplyToStrokeMode, object, style, fallbackColor);
 }
diff --git a/Source/core/rendering/svg/RenderSVGResource.h b/Source/core/rendering/svg/RenderSVGResource.h
index 5feaa1a..e9bccc7 100644
--- a/Source/core/rendering/svg/RenderSVGResource.h
+++ b/Source/core/rendering/svg/RenderSVGResource.h
@@ -76,8 +76,8 @@
     }
 
     // Helper utilities used in the render tree to access resources used for painting shapes/text (gradients & patterns & solid colors only)
-    static RenderSVGResource* fillPaintingResource(RenderObject*, const RenderStyle*, Color& fallbackColor);
-    static RenderSVGResource* strokePaintingResource(RenderObject*, const RenderStyle*, Color& fallbackColor);
+    static RenderSVGResource* fillPaintingResource(RenderObject*, const RenderStyle*, StyleColor& fallbackColor);
+    static RenderSVGResource* strokePaintingResource(RenderObject*, const RenderStyle*, StyleColor& fallbackColor);
     static RenderSVGResourceSolidColor* sharedSolidPaintingResource();
 
     static void markForLayoutAndParentResourceInvalidation(RenderObject*, bool needsLayout = true);
diff --git a/Source/core/rendering/svg/RenderSVGResourceClipper.cpp b/Source/core/rendering/svg/RenderSVGResourceClipper.cpp
index 9d99a7d..65ed669 100644
--- a/Source/core/rendering/svg/RenderSVGResourceClipper.cpp
+++ b/Source/core/rendering/svg/RenderSVGResourceClipper.cpp
@@ -24,6 +24,7 @@
 
 #include "core/rendering/svg/RenderSVGResourceClipper.h"
 
+#include "RuntimeEnabledFeatures.h"
 #include "SVGNames.h"
 #include "core/page/FrameView.h"
 #include "core/platform/graphics/GraphicsContextStateSaver.h"
@@ -114,12 +115,16 @@
             continue;
         }
 
-        // Attempt to generate a combined clip path, fall back to masking if not possible.
-        Path subPath;
-        styled->toClipPath(subPath);
-        subPath.setWindRule(svgStyle->clipRule());
-        if (!clipPath.unionPath(subPath))
+        if (RuntimeEnabledFeatures::pathOpsSVGClippingEnabled()) {
+            // Attempt to generate a combined clip path, fall back to masking if not possible.
+            Path subPath;
+            styled->toClipPath(subPath);
+            subPath.setWindRule(svgStyle->clipRule());
+            if (!clipPath.unionPath(subPath))
+                return false;
+        } else {
             return false;
+        }
     }
     // Only one visible shape/path was found. Directly continue clipping and transform the content to userspace if necessary.
     if (static_cast<SVGClipPathElement*>(node())->clipPathUnitsCurrentValue() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
diff --git a/Source/core/rendering/svg/RenderSVGResourcePattern.cpp b/Source/core/rendering/svg/RenderSVGResourcePattern.cpp
index d496544..9f09fe9 100644
--- a/Source/core/rendering/svg/RenderSVGResourcePattern.cpp
+++ b/Source/core/rendering/svg/RenderSVGResourcePattern.cpp
@@ -58,7 +58,7 @@
     if (currentData && currentData->pattern)
         return currentData;
 
-    SVGPatternElement* patternElement = static_cast<SVGPatternElement*>(node());
+    SVGPatternElement* patternElement = toSVGPatternElement(node());
     if (!patternElement)
         return 0;
 
diff --git a/Source/core/rendering/svg/RenderSVGShape.cpp b/Source/core/rendering/svg/RenderSVGShape.cpp
index f84b85e..5272fdf 100644
--- a/Source/core/rendering/svg/RenderSVGShape.cpp
+++ b/Source/core/rendering/svg/RenderSVGShape.cpp
@@ -118,7 +118,7 @@
     if (!m_fillBoundingBox.contains(point))
         return false;
 
-    Color fallbackColor;
+    StyleColor fallbackColor;
     if (requiresFill && !RenderSVGResource::fillPaintingResource(this, style(), fallbackColor))
         return false;
 
@@ -130,7 +130,7 @@
     if (!strokeBoundingBox().contains(point))
         return false;
 
-    Color fallbackColor;
+    StyleColor fallbackColor;
     if (requiresStroke && !RenderSVGResource::strokePaintingResource(this, style(), fallbackColor))
         return false;
 
@@ -215,13 +215,13 @@
 
 void RenderSVGShape::fillShape(RenderStyle* style, GraphicsContext* context)
 {
-    Color fallbackColor;
+    StyleColor fallbackColor;
     if (RenderSVGResource* fillPaintingResource = RenderSVGResource::fillPaintingResource(this, style, fallbackColor)) {
         if (fillPaintingResource->applyResource(this, style, context, ApplyToFillMode))
             fillPaintingResource->postApplyResource(this, context, ApplyToFillMode, 0, this);
         else if (fallbackColor.isValid()) {
             RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::sharedSolidPaintingResource();
-            fallbackResource->setColor(fallbackColor);
+            fallbackResource->setColor(fallbackColor.color());
             if (fallbackResource->applyResource(this, style, context, ApplyToFillMode))
                 fallbackResource->postApplyResource(this, context, ApplyToFillMode, 0, this);
         }
@@ -230,13 +230,13 @@
 
 void RenderSVGShape::strokeShape(RenderStyle* style, GraphicsContext* context)
 {
-    Color fallbackColor;
+    StyleColor fallbackColor;
     if (RenderSVGResource* strokePaintingResource = RenderSVGResource::strokePaintingResource(this, style, fallbackColor)) {
         if (strokePaintingResource->applyResource(this, style, context, ApplyToStrokeMode))
             strokePaintingResource->postApplyResource(this, context, ApplyToStrokeMode, 0, this);
         else if (fallbackColor.isValid()) {
             RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::sharedSolidPaintingResource();
-            fallbackResource->setColor(fallbackColor);
+            fallbackResource->setColor(fallbackColor.color());
             if (fallbackResource->applyResource(this, style, context, ApplyToStrokeMode))
                 fallbackResource->postApplyResource(this, context, ApplyToStrokeMode, 0, this);
         }
diff --git a/Source/core/rendering/svg/SVGInlineTextBox.cpp b/Source/core/rendering/svg/SVGInlineTextBox.cpp
index db62df8..0b94074 100644
--- a/Source/core/rendering/svg/SVGInlineTextBox.cpp
+++ b/Source/core/rendering/svg/SVGInlineTextBox.cpp
@@ -206,7 +206,7 @@
         return;
 
     Color backgroundColor = renderer()->selectionBackgroundColor();
-    if (!backgroundColor.isValid() || !backgroundColor.alpha())
+    if (!backgroundColor.alpha())
         return;
 
     RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer());
@@ -355,7 +355,7 @@
     ASSERT(style);
     ASSERT(m_paintingResourceMode != ApplyToDefaultMode);
 
-    Color fallbackColor;
+    StyleColor fallbackColor;
     if (m_paintingResourceMode & ApplyToFillMode)
         m_paintingResource = RenderSVGResource::fillPaintingResource(renderer, style, fallbackColor);
     else if (m_paintingResourceMode & ApplyToStrokeMode)
@@ -371,7 +371,7 @@
     if (!m_paintingResource->applyResource(renderer, style, context, m_paintingResourceMode)) {
         if (fallbackColor.isValid()) {
             RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::sharedSolidPaintingResource();
-            fallbackResource->setColor(fallbackColor);
+            fallbackResource->setColor(fallbackColor.color());
 
             m_paintingResource = fallbackResource;
             m_paintingResource->applyResource(renderer, style, context, m_paintingResourceMode);
@@ -624,7 +624,7 @@
         DrawLooper drawLooper;
         do {
             FloatSize offset(shadow->x(), shadow->y());
-            drawLooper.addShadow(offset, shadow->blur(), shadow->color(),
+            drawLooper.addShadow(offset, shadow->blur(), textRenderer->resolveColor(shadow->color(), Color::stdShadowColor),
                 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowRespectsAlpha);
         } while ((shadow = shadow->next()));
         drawLooper.addUnmodifiedContent();
diff --git a/Source/core/rendering/svg/SVGPathData.cpp b/Source/core/rendering/svg/SVGPathData.cpp
index aa69c37..b15fe3d 100644
--- a/Source/core/rendering/svg/SVGPathData.cpp
+++ b/Source/core/rendering/svg/SVGPathData.cpp
@@ -146,9 +146,9 @@
     ASSERT(path.isEmpty());
 
     typedef void (*PathUpdateFunction)(SVGElement*, Path&);
-    static HashMap<AtomicStringImpl*, PathUpdateFunction>* map = 0;
+    static HashMap<StringImpl*, PathUpdateFunction>* map = 0;
     if (!map) {
-        map = new HashMap<AtomicStringImpl*, PathUpdateFunction>;
+        map = new HashMap<StringImpl*, PathUpdateFunction>;
         map->set(SVGNames::circleTag.localName().impl(), updatePathFromCircleElement);
         map->set(SVGNames::ellipseTag.localName().impl(), updatePathFromEllipseElement);
         map->set(SVGNames::lineTag.localName().impl(), updatePathFromLineElement);
diff --git a/Source/core/rendering/svg/SVGRenderTreeAsText.cpp b/Source/core/rendering/svg/SVGRenderTreeAsText.cpp
index a9c337e..fc5b9a6 100644
--- a/Source/core/rendering/svg/SVGRenderTreeAsText.cpp
+++ b/Source/core/rendering/svg/SVGRenderTreeAsText.cpp
@@ -270,7 +270,7 @@
         ASSERT(shape.node());
         ASSERT(shape.node()->isSVGElement());
 
-        Color fallbackColor;
+        StyleColor fallbackColor;
         if (RenderSVGResource* strokePaintingResource = RenderSVGResource::strokePaintingResource(const_cast<RenderSVGShape*>(&shape), shape.style(), fallbackColor)) {
             TextStreamSeparator s(" ");
             ts << " [stroke={" << s;
@@ -527,7 +527,7 @@
         // Dump final results that are used for rendering. No use in asking SVGPatternElement for its patternUnits(), as it may
         // link to other patterns using xlink:href, we need to build the full inheritance chain, aka. collectPatternProperties()
         PatternAttributes attributes;
-        static_cast<SVGPatternElement*>(pattern->node())->collectPatternAttributes(attributes);
+        toSVGPatternElement(pattern->node())->collectPatternAttributes(attributes);
 
         writeNameValuePair(ts, "patternUnits", attributes.patternUnits());
         writeNameValuePair(ts, "patternContentUnits", attributes.patternContentUnits());
diff --git a/Source/core/rendering/svg/SVGRenderingContext.cpp b/Source/core/rendering/svg/SVGRenderingContext.cpp
index 6b9968b..e4160b0 100644
--- a/Source/core/rendering/svg/SVGRenderingContext.cpp
+++ b/Source/core/rendering/svg/SVGRenderingContext.cpp
@@ -122,7 +122,9 @@
 
         if (shadow) {
             m_paintInfo->context->clip(repaintRect);
-            m_paintInfo->context->setShadow(IntSize(roundToInt(shadow->x()), roundToInt(shadow->y())), shadow->blur(), shadow->color());
+            m_paintInfo->context->setShadow(IntSize(roundToInt(shadow->x()),
+                roundToInt(shadow->y())), shadow->blur(),
+                m_object->resolveColor(shadow->color(), Color::stdShadowColor));
             m_paintInfo->context->beginTransparencyLayer(1);
             m_renderingFlags |= EndShadowLayer;
         }
diff --git a/Source/core/rendering/svg/SVGResources.cpp b/Source/core/rendering/svg/SVGResources.cpp
index f30edd1..ce31a0b 100644
--- a/Source/core/rendering/svg/SVGResources.cpp
+++ b/Source/core/rendering/svg/SVGResources.cpp
@@ -143,7 +143,7 @@
 {
     String target;
     if (element->hasTagName(SVGNames::patternTag))
-        target = static_cast<SVGPatternElement*>(element)->hrefCurrentValue();
+        target = toSVGPatternElement(element)->hrefCurrentValue();
     else if (element->hasTagName(SVGNames::linearGradientTag) || element->hasTagName(SVGNames::radialGradientTag))
         target = toSVGGradientElement(element)->hrefCurrentValue();
     else if (element->hasTagName(SVGNames::filterTag))
diff --git a/Source/core/scripts/make_event_factory.py b/Source/core/scripts/make_event_factory.py
index 947ce1c..d34e4be 100644
--- a/Source/core/scripts/make_event_factory.py
+++ b/Source/core/scripts/make_event_factory.py
@@ -60,7 +60,6 @@
         'ImplementedAs': None,
         'Conditional': None,
         'EnabledAtRuntime': None,
-        'AllowJSCreationOnlyIfFeatureEnabled': None,
     }
     default_parameters = {
         'namespace': '',
@@ -75,7 +74,7 @@
 
     def _factory_implementation(self, event):
         runtime_condition = ''
-        if event['EnabledAtRuntime'] and event['AllowJSCreationOnlyIfFeatureEnabled']:
+        if event['EnabledAtRuntime']:
             runtime_condition = ' && RuntimeEnabledFeatures::' + event['EnabledAtRuntime'] + '()'
         name = os.path.basename(event['name'])
         class_name = self._class_name_for_entry(event)
diff --git a/Source/core/scripts/make_names.pl b/Source/core/scripts/make_names.pl
index bceb391..1682a33 100755
--- a/Source/core/scripts/make_names.pl
+++ b/Source/core/scripts/make_names.pl
@@ -819,7 +819,7 @@
 print F ", HTMLFormElement*" if $parameters{namespace} eq "HTML";
 print F ", bool createdByParser);\n";
 print F <<END
-typedef HashMap<AtomicStringImpl*, ConstructorFunction> FunctionMap;
+typedef HashMap<StringImpl*, ConstructorFunction> FunctionMap;
 
 static FunctionMap* gFunctionMap = 0;
 
@@ -1088,7 +1088,7 @@
         print F <<END
 v8::Handle<v8::Object> createV8$parameters{namespace}Wrapper($parameters{namespace}Element* element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
-    typedef HashMap<WTF::AtomicStringImpl*, Create$parameters{namespace}ElementWrapperFunction> FunctionMap;
+    typedef HashMap<WTF::StringImpl*, Create$parameters{namespace}ElementWrapperFunction> FunctionMap;
     DEFINE_STATIC_LOCAL(FunctionMap, map, ());
     if (map.isEmpty()) {
 END
diff --git a/Source/core/scripts/templates/StyleBuilderFunctions.cpp.tmpl b/Source/core/scripts/templates/StyleBuilderFunctions.cpp.tmpl
index f803622..103f436 100644
--- a/Source/core/scripts/templates/StyleBuilderFunctions.cpp.tmpl
+++ b/Source/core/scripts/templates/StyleBuilderFunctions.cpp.tmpl
@@ -273,7 +273,7 @@
 {%- set visited_link_setter = "setVisitedLink" + property.camel_case_name %}
 {{ declare_initial_function(property_id) }}
 {
-    Color color = {{ initial_color or "Color" -}}();
+    StyleColor color = {{ initial_color or "StyleColor" -}}();
     if (state.applyPropertyToRegularStyle())
         {{ set_value(property) }}(color);
     if (state.applyPropertyToVisitedLinkStyle())
@@ -283,7 +283,7 @@
 {{ declare_inherit_function(property_id) }}
 {
     // Visited link style can never explicitly inherit from parent visited link style so no separate getters are needed.
-    Color color = state.parentStyle()->{{property.getter}}();
+    StyleColor color = state.parentStyle()->{{property.getter}}();
     if (!color.isValid())
         color = state.parentStyle()->{{default_getter}}();
     if (state.applyPropertyToRegularStyle())
@@ -307,9 +307,9 @@
 {%- endif %}
 
     if (state.applyPropertyToRegularStyle())
-        {{ set_value(property) }}(state.document()->textLinkColors().colorFromPrimitiveValue(primitiveValue, state.style()->visitedDependentColor(CSSPropertyColor)));
+        {{ set_value(property) }}(state.document()->textLinkColors().colorFromPrimitiveValue(primitiveValue));
     if (state.applyPropertyToVisitedLinkStyle())
-        state.style()->{{visited_link_setter}}(state.document()->textLinkColors().colorFromPrimitiveValue(primitiveValue, state.style()->visitedDependentColor(CSSPropertyColor), state.element()->isLink() /* forVisitedLink */));
+        state.style()->{{visited_link_setter}}(state.document()->textLinkColors().colorFromPrimitiveValue(primitiveValue, state.element()->isLink() /* forVisitedLink */));
 }
 {%- endmacro %}
 
diff --git a/Source/core/svg/SVGAnimatedColor.cpp b/Source/core/svg/SVGAnimatedColor.cpp
index ad478af..9f48b7f 100644
--- a/Source/core/svg/SVGAnimatedColor.cpp
+++ b/Source/core/svg/SVGAnimatedColor.cpp
@@ -52,7 +52,7 @@
     ASSERT(targetElement);
 
     if (RenderObject* targetRenderer = targetElement->renderer())
-        color = targetRenderer->style()->visitedDependentColor(CSSPropertyColor);
+        color = targetRenderer->resolveColor(CSSPropertyColor);
     else
         color = Color();
 }
@@ -100,11 +100,11 @@
 float SVGAnimatedColorAnimator::calculateDistance(const String& fromString, const String& toString)
 {
     ASSERT(m_contextElement);
-    Color from = SVGColor::colorFromRGBColorString(fromString);
-    if (!from.isValid())
+    Color from;
+    if (!SVGColor::colorFromRGBColorString(fromString, from))
         return -1;
-    Color to = SVGColor::colorFromRGBColorString(toString);
-    if (!to.isValid())
+    Color to;
+    if (!SVGColor::colorFromRGBColorString(toString, to))
         return -1;
     return ColorDistance(from, to).distance();
 }
diff --git a/Source/core/svg/SVGColor.cpp b/Source/core/svg/SVGColor.cpp
index 9d244c2..71782e9 100644
--- a/Source/core/svg/SVGColor.cpp
+++ b/Source/core/svg/SVGColor.cpp
@@ -31,12 +31,14 @@
 SVGColor::SVGColor(const SVGColorType& colorType)
     : CSSValue(SVGColorClass)
     , m_colorType(colorType)
+    , m_valid(false)
 {
 }
 
 SVGColor::SVGColor(ClassType classType, const SVGColorType& colorType)
     : CSSValue(classType)
     , m_colorType(colorType)
+    , m_valid(false)
 {
 }
 
@@ -45,13 +47,15 @@
     return RGBColor::create(m_color.rgb());
 }
 
-Color SVGColor::colorFromRGBColorString(const String& colorString)
+bool SVGColor::colorFromRGBColorString(const String& colorString, Color& color)
 {
     // FIXME: Rework css parser so it is more SVG aware.
-    RGBA32 color;
-    if (CSSParser::parseColor(color, colorString.stripWhiteSpace()))
-        return color;
-    return Color();
+    RGBA32 rgba;
+    if (CSSParser::parseColor(rgba, colorString.stripWhiteSpace())) {
+        color = rgba;
+        return true;
+    }
+    return false;
 }
 
 void SVGColor::setRGBColor(const String&, ExceptionCode& ec)
@@ -81,7 +85,7 @@
         // FIXME: No ICC color support.
         return m_color.serialized();
     case SVG_COLORTYPE_CURRENTCOLOR:
-        if (m_color.isValid())
+        if (m_valid)
             return m_color.serialized();
         return "currentColor";
     }
diff --git a/Source/core/svg/SVGColor.h b/Source/core/svg/SVGColor.h
index dd820fd..3ea3d7e 100644
--- a/Source/core/svg/SVGColor.h
+++ b/Source/core/svg/SVGColor.h
@@ -42,7 +42,7 @@
     static PassRefPtr<SVGColor> createFromString(const String& rgbColor)
     {
         RefPtr<SVGColor> color = adoptRef(new SVGColor(SVG_COLORTYPE_RGBCOLOR));
-        color->setColor(colorFromRGBColorString(rgbColor));
+        color->m_valid = colorFromRGBColorString(rgbColor, color->m_color);
         return color.release();
     }
 
@@ -62,7 +62,13 @@
     const SVGColorType& colorType() const { return m_colorType; }
     PassRefPtr<RGBColor> rgbColor() const;
 
-    static Color colorFromRGBColorString(const String&);
+    static bool colorFromRGBColorString(const String&, Color&);
+    static Color colorFromRGBColorString(const String& s)
+    {
+        Color color;
+        colorFromRGBColorString(s, color);
+        return color;
+    }
 
     void setRGBColor(const String& rgbColor, ExceptionCode&);
     void setRGBColorICCColor(const String& rgbColor, const String& iccColor, ExceptionCode&);
@@ -82,7 +88,7 @@
     SVGColor(ClassType, const SVGColorType&);
     SVGColor(ClassType, const SVGColor& cloneFrom);
 
-    void setColor(const Color& color) { m_color = color; }
+    void setColor(const Color& color) { m_color = color; m_valid = true; }
     void setColorType(const SVGColorType& type) { m_colorType = type; }
 
 private:
@@ -90,6 +96,7 @@
 
     Color m_color;
     SVGColorType m_colorType;
+    bool m_valid;
 };
 
 } // namespace WebCore
diff --git a/Source/core/svg/SVGFontFaceElement.cpp b/Source/core/svg/SVGFontFaceElement.cpp
index 00a0730..4c962b1 100644
--- a/Source/core/svg/SVGFontFaceElement.cpp
+++ b/Source/core/svg/SVGFontFaceElement.cpp
@@ -67,9 +67,9 @@
     if (!attrName.namespaceURI().isNull())
         return CSSPropertyInvalid;
     
-    static HashMap<AtomicStringImpl*, CSSPropertyID>* propertyNameToIdMap = 0;
+    static HashMap<StringImpl*, CSSPropertyID>* propertyNameToIdMap = 0;
     if (!propertyNameToIdMap) {
-        propertyNameToIdMap = new HashMap<AtomicStringImpl*, CSSPropertyID>;
+        propertyNameToIdMap = new HashMap<StringImpl*, CSSPropertyID>;
         // This is a list of all @font-face CSS properties which are exposed as SVG XML attributes
         // Those commented out are not yet supported by WebCore's style system
         // mapAttributeToCSSProperty(propertyNameToIdMap, accent_heightAttr);
diff --git a/Source/core/svg/SVGPatternElement.h b/Source/core/svg/SVGPatternElement.h
index b813817..8d09168 100644
--- a/Source/core/svg/SVGPatternElement.h
+++ b/Source/core/svg/SVGPatternElement.h
@@ -21,6 +21,7 @@
 #ifndef SVGPatternElement_h
 #define SVGPatternElement_h
 
+#include "SVGNames.h"
 #include "core/svg/SVGAnimatedBoolean.h"
 #include "core/svg/SVGAnimatedEnumeration.h"
 #include "core/svg/SVGAnimatedLength.h"
@@ -85,6 +86,12 @@
     virtual void synchronizeSystemLanguage() { SVGTests::synchronizeSystemLanguage(this); }
 };
 
+inline SVGPatternElement* toSVGPatternElement(Node* node)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::patternTag));
+    return static_cast<SVGPatternElement*>(node);
+}
+
 } // namespace WebCore
 
 #endif
diff --git a/Source/core/svg/SVGStopElement.cpp b/Source/core/svg/SVGStopElement.cpp
index 96c7814..397ea20 100644
--- a/Source/core/svg/SVGStopElement.cpp
+++ b/Source/core/svg/SVGStopElement.cpp
@@ -114,7 +114,7 @@
     // which the renderer or style is null. This entire class is scheduled for removal (Bug WK 86941)
     // and we will tolerate this null check until then.
     if (!style || !style->svgStyle())
-        return Color(Color::transparent, true); // Transparent black.
+        return Color(Color::transparent); // Transparent black.
 
     const SVGRenderStyle* svgStyle = style->svgStyle();
     return colorWithOverrideAlpha(svgStyle->stopColor().rgb(), svgStyle->stopOpacity());
diff --git a/Source/core/svg/SVGStyledElement.cpp b/Source/core/svg/SVGStyledElement.cpp
index 20fd2e0..28805ab 100644
--- a/Source/core/svg/SVGStyledElement.cpp
+++ b/Source/core/svg/SVGStyledElement.cpp
@@ -58,7 +58,7 @@
 
 using namespace SVGNames;
 
-void mapAttributeToCSSProperty(HashMap<AtomicStringImpl*, CSSPropertyID>* propertyNameToIdMap, const QualifiedName& attrName)
+void mapAttributeToCSSProperty(HashMap<StringImpl*, CSSPropertyID>* propertyNameToIdMap, const QualifiedName& attrName)
 {
     // FIXME: when CSS supports "transform-origin" the special case for transform_originAttr can be removed.
     CSSPropertyID propertyId = cssPropertyID(attrName.localName());
@@ -133,9 +133,9 @@
     if (!attrName.namespaceURI().isNull())
         return CSSPropertyInvalid;
     
-    static HashMap<AtomicStringImpl*, CSSPropertyID>* propertyNameToIdMap = 0;
+    static HashMap<StringImpl*, CSSPropertyID>* propertyNameToIdMap = 0;
     if (!propertyNameToIdMap) {
-        propertyNameToIdMap = new HashMap<AtomicStringImpl*, CSSPropertyID>;
+        propertyNameToIdMap = new HashMap<StringImpl*, CSSPropertyID>;
         // This is a list of all base CSS and SVG CSS properties which are exposed as SVG XML attributes
         mapAttributeToCSSProperty(propertyNameToIdMap, alignment_baselineAttr);
         mapAttributeToCSSProperty(propertyNameToIdMap, baseline_shiftAttr);
diff --git a/Source/core/svg/SVGStyledElement.h b/Source/core/svg/SVGStyledElement.h
index 9108c37..15d170f 100644
--- a/Source/core/svg/SVGStyledElement.h
+++ b/Source/core/svg/SVGStyledElement.h
@@ -30,7 +30,7 @@
 
 namespace WebCore {
 
-void mapAttributeToCSSProperty(HashMap<AtomicStringImpl*, CSSPropertyID>* propertyNameToIdMap, const QualifiedName& attrName);
+void mapAttributeToCSSProperty(HashMap<StringImpl*, CSSPropertyID>* propertyNameToIdMap, const QualifiedName& attrName);
 
 class CSSValue;
 class CSSStyleDeclaration;
diff --git a/Source/core/svg/SVGTRefElement.cpp b/Source/core/svg/SVGTRefElement.cpp
index 5d2e051..4e69339 100644
--- a/Source/core/svg/SVGTRefElement.cpp
+++ b/Source/core/svg/SVGTRefElement.cpp
@@ -33,6 +33,7 @@
 #include "core/dom/Text.h"
 #include "core/dom/shadow/ElementShadow.h"
 #include "core/dom/shadow/ShadowRoot.h"
+#include "core/editing/markup.h"
 #include "core/page/UseCounter.h"
 #include "core/rendering/style/StyleInheritedData.h"
 #include "core/rendering/svg/RenderSVGInline.h"
@@ -149,18 +150,10 @@
 
 void SVGTRefElement::updateReferencedText(Element* target)
 {
-    String textContent;
     if (target)
-        textContent = target->textContent();
-
-    ASSERT(shadow());
-    ShadowRoot* root = shadow()->oldestShadowRoot();
-    if (!root->firstChild())
-        root->appendChild(Text::create(document(), textContent), ASSERT_NO_EXCEPTION);
-    else {
-        ASSERT(root->firstChild()->isTextNode());
-        root->firstChild()->setTextContent(textContent, ASSERT_NO_EXCEPTION);
-    }
+        replaceChildrenWithText(userAgentShadowRoot(), target->textContent(), ASSERT_NO_EXCEPTION);
+    else
+        userAgentShadowRoot()->removeChildren();
 }
 
 void SVGTRefElement::detachTarget()
@@ -168,12 +161,7 @@
     // Remove active listeners and clear the text content.
     m_targetListener->detach();
 
-    String emptyContent;
-
-    ASSERT(shadow());
-    Node* container = shadow()->oldestShadowRoot()->firstChild();
-    if (container)
-        container->setTextContent(emptyContent, IGNORE_EXCEPTION);
+    userAgentShadowRoot()->removeChildren();
 
     if (!inDocument())
         return;
diff --git a/Source/core/svg/SVGTRefElement.h b/Source/core/svg/SVGTRefElement.h
index 8a6378d..2ca2ac7 100644
--- a/Source/core/svg/SVGTRefElement.h
+++ b/Source/core/svg/SVGTRefElement.h
@@ -43,9 +43,9 @@
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
     virtual void svgAttributeChanged(const QualifiedName&);
 
-    virtual RenderObject* createRenderer(RenderStyle*);
-    virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const;
-    virtual bool rendererIsNeeded(const NodeRenderingContext&);
+    virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
+    virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OVERRIDE;
+    virtual bool rendererIsNeeded(const NodeRenderingContext&) OVERRIDE;
 
     virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
     virtual void removedFrom(ContainerNode*) OVERRIDE;
diff --git a/Source/core/svg/animation/SVGSMILElement.cpp b/Source/core/svg/animation/SVGSMILElement.cpp
index b5fdb07..b84205a 100644
--- a/Source/core/svg/animation/SVGSMILElement.cpp
+++ b/Source/core/svg/animation/SVGSMILElement.cpp
@@ -1001,7 +1001,9 @@
     SMILTime activeTime = elapsed - m_intervalBegin;
     SMILTime repeatingDuration = this->repeatingDuration();
     if (elapsed >= m_intervalEnd || activeTime > repeatingDuration) {
-        repeat = static_cast<unsigned>(repeatingDuration.value() / simpleDuration.value()) - 1;
+        repeat = static_cast<unsigned>(repeatingDuration.value() / simpleDuration.value());
+        if (!fmod(repeatingDuration.value(), simpleDuration.value()))
+            repeat--;
 
         double percent = (m_intervalEnd.value() - m_intervalBegin.value()) / simpleDuration.value();
         percent = percent - floor(percent);
diff --git a/Source/core/svg/properties/SVGAnimatedPropertyDescription.h b/Source/core/svg/properties/SVGAnimatedPropertyDescription.h
index 025f89a..c149a9b 100644
--- a/Source/core/svg/properties/SVGAnimatedPropertyDescription.h
+++ b/Source/core/svg/properties/SVGAnimatedPropertyDescription.h
@@ -63,7 +63,7 @@
     }
 
     SVGElement* m_element;
-    AtomicStringImpl* m_attributeName;
+    StringImpl* m_attributeName;
 };
 
 struct SVGAnimatedPropertyDescriptionHash {
diff --git a/Source/core/testing/InternalSettings.cpp b/Source/core/testing/InternalSettings.cpp
index ac1225e..f847a0d 100644
--- a/Source/core/testing/InternalSettings.cpp
+++ b/Source/core/testing/InternalSettings.cpp
@@ -66,7 +66,6 @@
     , m_originalTextAutosizingWindowSizeOverride(settings->textAutosizingWindowSizeOverride())
     , m_originalTextAutosizingFontScaleFactor(settings->textAutosizingFontScaleFactor())
     , m_originalMediaTypeOverride(settings->mediaTypeOverride())
-    , m_originalDialogElementEnabled(RuntimeEnabledFeatures::dialogElementEnabled())
     , m_originalLazyLayoutEnabled(RuntimeEnabledFeatures::lazyLayoutEnabled())
     , m_originalMockScrollbarsEnabled(settings->mockScrollbarsEnabled())
     , m_langAttributeAwareFormControlUIEnabled(RuntimeEnabledFeatures::langAttributeAwareFormControlUIEnabled())
@@ -90,7 +89,6 @@
     settings->setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride);
     settings->setTextAutosizingFontScaleFactor(m_originalTextAutosizingFontScaleFactor);
     settings->setMediaTypeOverride(m_originalMediaTypeOverride);
-    RuntimeEnabledFeatures::setDialogElementEnabled(m_originalDialogElementEnabled);
     RuntimeEnabledFeatures::setLazyLayoutEnabled(m_originalLazyLayoutEnabled);
     settings->setMockScrollbarsEnabled(m_originalMockScrollbarsEnabled);
     RuntimeEnabledFeatures::setLangAttributeAwareFormControlUIEnabled(m_langAttributeAwareFormControlUIEnabled);
@@ -292,11 +290,6 @@
         ec = SyntaxError;
 }
 
-void InternalSettings::setDialogElementEnabled(bool enabled)
-{
-    RuntimeEnabledFeatures::setDialogElementEnabled(enabled);
-}
-
 void InternalSettings::setLazyLayoutEnabled(bool enabled)
 {
     RuntimeEnabledFeatures::setLazyLayoutEnabled(enabled);
diff --git a/Source/core/testing/InternalSettings.h b/Source/core/testing/InternalSettings.h
index 8ac6c02..44c8559 100644
--- a/Source/core/testing/InternalSettings.h
+++ b/Source/core/testing/InternalSettings.h
@@ -60,7 +60,6 @@
         IntSize m_originalTextAutosizingWindowSizeOverride;
         float m_originalTextAutosizingFontScaleFactor;
         String m_originalMediaTypeOverride;
-        bool m_originalDialogElementEnabled;
         bool m_originalLazyLayoutEnabled;
         bool m_originalMockScrollbarsEnabled;
         bool m_originalUsesOverlayScrollbars;
@@ -110,7 +109,6 @@
     // be removed or moved onto internals.runtimeFlags:
     void setAuthorShadowDOMForAnyElementEnabled(bool);
     void setCSSExclusionsEnabled(bool);
-    void setDialogElementEnabled(bool);
     void setExperimentalShadowDOMEnabled(bool);
     void setExperimentalWebSocketEnabled(bool);
     void setLangAttributeAwareFormControlUIEnabled(bool);
diff --git a/Source/core/testing/InternalSettings.idl b/Source/core/testing/InternalSettings.idl
index 85aa626..8243d29 100644
--- a/Source/core/testing/InternalSettings.idl
+++ b/Source/core/testing/InternalSettings.idl
@@ -54,7 +54,6 @@
     // be removed or moved onto internals.runtimeFlags:
     void setAuthorShadowDOMForAnyElementEnabled(boolean enabled);
     void setCSSExclusionsEnabled(boolean enabled);
-    void setDialogElementEnabled(boolean enabled);
     void setExperimentalShadowDOMEnabled(boolean enabled);
     void setExperimentalWebSocketEnabled(boolean enabled);
     void setLangAttributeAwareFormControlUIEnabled(boolean enabled);
diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp
index 6823d00..53dd5ef 100644
--- a/Source/core/testing/Internals.cpp
+++ b/Source/core/testing/Internals.cpp
@@ -451,7 +451,7 @@
 bool Internals::hasShadowInsertionPoint(const Node* root, ExceptionCode& ec) const
 {
     if (root && root->isShadowRoot())
-        return ScopeContentDistribution::hasShadowElement(toShadowRoot(root));
+        return toShadowRoot(root)->containsShadowElements();
 
     ec = InvalidAccessError;
     return 0;
@@ -460,7 +460,7 @@
 bool Internals::hasContentElement(const Node* root, ExceptionCode& ec) const
 {
     if (root && root->isShadowRoot())
-        return ScopeContentDistribution::hasContentElement(toShadowRoot(root));
+        return toShadowRoot(root)->containsContentElements();
 
     ec = InvalidAccessError;
     return 0;
@@ -472,8 +472,9 @@
         ec = InvalidAccessError;
         return 0;
     }
-
-    return ScopeContentDistribution::countElementShadow(toShadowRoot(root));
+    if (const ScopeContentDistribution* distribution = toShadowRoot(root)->scopeDistribution())
+        return distribution->numberOfElementShadowChildren();
+    return 0;
 }
 
 bool Internals::attached(Node* node, ExceptionCode& ec)
@@ -703,7 +704,7 @@
 {
     if (!element->hasTagName(inputTag))
         return;
-    toHTMLInputElement(element)->selectColorInColorChooser(Color(colorValue));
+    toHTMLInputElement(element)->selectColorInColorChooser(StyleColor(colorValue).color());
 }
 
 Vector<String> Internals::formControlStateOfPreviousHistoryItem(ExceptionCode& ec)
@@ -1599,12 +1600,9 @@
     }
 
     RenderLayer* layer = toRenderBox(renderer)->layer();
-    if (!layer) {
-        ec = InvalidAccessError;
-        return String();
-    }
-
-    if (!layer->backing() || !layer->backing()->graphicsLayer()) {
+    if (!layer
+        || !layer->backing()
+        || !layer->backing()->graphicsLayer()) {
         // Don't raise exception in these cases which may be normally used in tests.
         return String();
     }
diff --git a/Source/core/testing/MockPagePopupDriver.cpp b/Source/core/testing/MockPagePopupDriver.cpp
index 4c2fc5b..23594d6 100644
--- a/Source/core/testing/MockPagePopupDriver.cpp
+++ b/Source/core/testing/MockPagePopupDriver.cpp
@@ -67,7 +67,7 @@
     m_iframe->setInlineStyleProperty(CSSPropertyLeft, originBoundsInRootView.x(), CSSPrimitiveValue::CSS_PX, true);
     m_iframe->setInlineStyleProperty(CSSPropertyTop, originBoundsInRootView.maxY(), CSSPrimitiveValue::CSS_PX, true);
     if (document->body())
-        document->body()->appendChild(m_iframe.get());
+        document->body()->appendChild(m_iframe.get(), ASSERT_NO_EXCEPTION, AttachLazily);
     Frame* contentFrame = m_iframe->contentFrame();
     DocumentWriter* writer = contentFrame->loader()->activeDocumentLoader()->beginWriting("text/html", "UTF-8");
     const char scriptToSetUpPagePopupController[] = "<script>window.pagePopupController = parent.internals.pagePopupController;</script>";
diff --git a/Source/core/webcore.target.darwin-arm.mk b/Source/core/webcore.target.darwin-arm.mk
index ccfa6f3..5cbd62f 100644
--- a/Source/core/webcore.target.darwin-arm.mk
+++ b/Source/core/webcore.target.darwin-arm.mk
@@ -21,7 +21,7 @@
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_svg_gyp)/third_party_WebKit_Source_core_webcore_svg_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_derived_gyp)/third_party_WebKit_Source_core_webcore_derived_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_wtf_wtf_gyp)/third_party_WebKit_Source_wtf_wtf_gyp.a \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
 	$(call intermediates-dir-for,GYP,third_party_npapi_npapi_gyp)/npapi.stamp \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_qcms_qcms_gyp)/third_party_qcms_qcms_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,url_url_lib_gyp)/url_url_lib_gyp.a \
diff --git a/Source/core/webcore.target.darwin-mips.mk b/Source/core/webcore.target.darwin-mips.mk
index 4940fb2..04ed651 100644
--- a/Source/core/webcore.target.darwin-mips.mk
+++ b/Source/core/webcore.target.darwin-mips.mk
@@ -21,7 +21,7 @@
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_svg_gyp)/third_party_WebKit_Source_core_webcore_svg_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_derived_gyp)/third_party_WebKit_Source_core_webcore_derived_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_wtf_wtf_gyp)/third_party_WebKit_Source_wtf_wtf_gyp.a \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
 	$(call intermediates-dir-for,GYP,third_party_npapi_npapi_gyp)/npapi.stamp \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_qcms_qcms_gyp)/third_party_qcms_qcms_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,url_url_lib_gyp)/url_url_lib_gyp.a \
diff --git a/Source/core/webcore.target.darwin-x86.mk b/Source/core/webcore.target.darwin-x86.mk
index 4940fb2..04ed651 100644
--- a/Source/core/webcore.target.darwin-x86.mk
+++ b/Source/core/webcore.target.darwin-x86.mk
@@ -21,7 +21,7 @@
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_svg_gyp)/third_party_WebKit_Source_core_webcore_svg_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_derived_gyp)/third_party_WebKit_Source_core_webcore_derived_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_wtf_wtf_gyp)/third_party_WebKit_Source_wtf_wtf_gyp.a \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
 	$(call intermediates-dir-for,GYP,third_party_npapi_npapi_gyp)/npapi.stamp \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_qcms_qcms_gyp)/third_party_qcms_qcms_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,url_url_lib_gyp)/url_url_lib_gyp.a \
diff --git a/Source/core/webcore.target.linux-arm.mk b/Source/core/webcore.target.linux-arm.mk
index ccfa6f3..5cbd62f 100644
--- a/Source/core/webcore.target.linux-arm.mk
+++ b/Source/core/webcore.target.linux-arm.mk
@@ -21,7 +21,7 @@
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_svg_gyp)/third_party_WebKit_Source_core_webcore_svg_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_derived_gyp)/third_party_WebKit_Source_core_webcore_derived_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_wtf_wtf_gyp)/third_party_WebKit_Source_wtf_wtf_gyp.a \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
 	$(call intermediates-dir-for,GYP,third_party_npapi_npapi_gyp)/npapi.stamp \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_qcms_qcms_gyp)/third_party_qcms_qcms_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,url_url_lib_gyp)/url_url_lib_gyp.a \
diff --git a/Source/core/webcore.target.linux-mips.mk b/Source/core/webcore.target.linux-mips.mk
index 4940fb2..04ed651 100644
--- a/Source/core/webcore.target.linux-mips.mk
+++ b/Source/core/webcore.target.linux-mips.mk
@@ -21,7 +21,7 @@
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_svg_gyp)/third_party_WebKit_Source_core_webcore_svg_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_derived_gyp)/third_party_WebKit_Source_core_webcore_derived_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_wtf_wtf_gyp)/third_party_WebKit_Source_wtf_wtf_gyp.a \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
 	$(call intermediates-dir-for,GYP,third_party_npapi_npapi_gyp)/npapi.stamp \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_qcms_qcms_gyp)/third_party_qcms_qcms_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,url_url_lib_gyp)/url_url_lib_gyp.a \
diff --git a/Source/core/webcore.target.linux-x86.mk b/Source/core/webcore.target.linux-x86.mk
index 4940fb2..04ed651 100644
--- a/Source/core/webcore.target.linux-x86.mk
+++ b/Source/core/webcore.target.linux-x86.mk
@@ -21,7 +21,7 @@
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_svg_gyp)/third_party_WebKit_Source_core_webcore_svg_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_core_webcore_derived_gyp)/third_party_WebKit_Source_core_webcore_derived_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_wtf_wtf_gyp)/third_party_WebKit_Source_wtf_wtf_gyp.a \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
 	$(call intermediates-dir-for,GYP,third_party_npapi_npapi_gyp)/npapi.stamp \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_qcms_qcms_gyp)/third_party_qcms_qcms_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,url_url_lib_gyp)/url_url_lib_gyp.a \
diff --git a/Source/core/webcore_arm_neon.target.darwin-arm.mk b/Source/core/webcore_arm_neon.target.darwin-arm.mk
index cc25897..8e4a7f7 100644
--- a/Source/core/webcore_arm_neon.target.darwin-arm.mk
+++ b/Source/core/webcore_arm_neon.target.darwin-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -58,7 +58,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_arm_neon.target.linux-arm.mk b/Source/core/webcore_arm_neon.target.linux-arm.mk
index cc25897..8e4a7f7 100644
--- a/Source/core/webcore_arm_neon.target.linux-arm.mk
+++ b/Source/core/webcore_arm_neon.target.linux-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -58,7 +58,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_derived.target.darwin-arm.mk b/Source/core/webcore_derived.target.darwin-arm.mk
index a67709f..a7900f2 100644
--- a/Source/core/webcore_derived.target.darwin-arm.mk
+++ b/Source/core/webcore_derived.target.darwin-arm.mk
@@ -20,7 +20,8 @@
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_injected_canvas_script_source_gyp)/injected_canvas_script_source.stamp \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_injected_script_source_gyp)/injected_script_source.stamp \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_debugger_script_source_gyp)/debugger_script_source.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a \
 	$(call intermediates-dir-for,GYP,third_party_libwebp_libwebp_gyp)/webp.stamp \
 	$(call intermediates-dir-for,GYP,third_party_npapi_npapi_gyp)/npapi.stamp \
 	$(call intermediates-dir-for,GYP,v8_tools_gyp_v8_gyp)/v8.stamp \
@@ -217,7 +218,6 @@
 	third_party/WebKit/Source/bindings/v8/ScriptHeapSnapshot.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptInstance.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptObject.cpp \
-	third_party/WebKit/Source/bindings/v8/ScriptPreprocessor.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptProfiler.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptPromiseResolver.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptScope.cpp \
@@ -388,10 +388,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DUSE_I18N_EXTENSION' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
@@ -418,13 +418,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -466,8 +465,8 @@
 	$(LOCAL_PATH)/third_party/zlib \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -558,10 +557,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DUSE_I18N_EXTENSION' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
@@ -588,13 +587,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -636,8 +634,8 @@
 	$(LOCAL_PATH)/third_party/zlib \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -724,7 +722,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_derived.target.darwin-mips.mk b/Source/core/webcore_derived.target.darwin-mips.mk
index 0c62494..4c94da6 100644
--- a/Source/core/webcore_derived.target.darwin-mips.mk
+++ b/Source/core/webcore_derived.target.darwin-mips.mk
@@ -20,7 +20,8 @@
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_injected_canvas_script_source_gyp)/injected_canvas_script_source.stamp \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_injected_script_source_gyp)/injected_script_source.stamp \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_debugger_script_source_gyp)/debugger_script_source.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a \
 	$(call intermediates-dir-for,GYP,third_party_libwebp_libwebp_gyp)/webp.stamp \
 	$(call intermediates-dir-for,GYP,third_party_npapi_npapi_gyp)/npapi.stamp \
 	$(call intermediates-dir-for,GYP,v8_tools_gyp_v8_gyp)/v8.stamp \
@@ -217,7 +218,6 @@
 	third_party/WebKit/Source/bindings/v8/ScriptHeapSnapshot.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptInstance.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptObject.cpp \
-	third_party/WebKit/Source/bindings/v8/ScriptPreprocessor.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptProfiler.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptPromiseResolver.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptScope.cpp \
@@ -388,10 +388,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DUSE_I18N_EXTENSION' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
@@ -418,13 +418,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -466,8 +465,8 @@
 	$(LOCAL_PATH)/third_party/zlib \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -558,10 +557,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DUSE_I18N_EXTENSION' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
@@ -588,13 +587,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -636,8 +634,8 @@
 	$(LOCAL_PATH)/third_party/zlib \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -720,7 +718,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_derived.target.darwin-x86.mk b/Source/core/webcore_derived.target.darwin-x86.mk
index 6434b13..996e817 100644
--- a/Source/core/webcore_derived.target.darwin-x86.mk
+++ b/Source/core/webcore_derived.target.darwin-x86.mk
@@ -20,7 +20,8 @@
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_injected_canvas_script_source_gyp)/injected_canvas_script_source.stamp \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_injected_script_source_gyp)/injected_script_source.stamp \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_debugger_script_source_gyp)/debugger_script_source.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a \
 	$(call intermediates-dir-for,GYP,third_party_libwebp_libwebp_gyp)/webp.stamp \
 	$(call intermediates-dir-for,GYP,third_party_npapi_npapi_gyp)/npapi.stamp \
 	$(call intermediates-dir-for,GYP,v8_tools_gyp_v8_gyp)/v8.stamp \
@@ -217,7 +218,6 @@
 	third_party/WebKit/Source/bindings/v8/ScriptHeapSnapshot.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptInstance.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptObject.cpp \
-	third_party/WebKit/Source/bindings/v8/ScriptPreprocessor.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptProfiler.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptPromiseResolver.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptScope.cpp \
@@ -390,10 +390,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DUSE_I18N_EXTENSION' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
@@ -420,13 +420,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -468,8 +467,8 @@
 	$(LOCAL_PATH)/third_party/zlib \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -563,10 +562,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DUSE_I18N_EXTENSION' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
@@ -593,13 +592,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -641,8 +639,8 @@
 	$(LOCAL_PATH)/third_party/zlib \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -724,7 +722,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_derived.target.linux-arm.mk b/Source/core/webcore_derived.target.linux-arm.mk
index a67709f..a7900f2 100644
--- a/Source/core/webcore_derived.target.linux-arm.mk
+++ b/Source/core/webcore_derived.target.linux-arm.mk
@@ -20,7 +20,8 @@
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_injected_canvas_script_source_gyp)/injected_canvas_script_source.stamp \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_injected_script_source_gyp)/injected_script_source.stamp \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_debugger_script_source_gyp)/debugger_script_source.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a \
 	$(call intermediates-dir-for,GYP,third_party_libwebp_libwebp_gyp)/webp.stamp \
 	$(call intermediates-dir-for,GYP,third_party_npapi_npapi_gyp)/npapi.stamp \
 	$(call intermediates-dir-for,GYP,v8_tools_gyp_v8_gyp)/v8.stamp \
@@ -217,7 +218,6 @@
 	third_party/WebKit/Source/bindings/v8/ScriptHeapSnapshot.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptInstance.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptObject.cpp \
-	third_party/WebKit/Source/bindings/v8/ScriptPreprocessor.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptProfiler.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptPromiseResolver.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptScope.cpp \
@@ -388,10 +388,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DUSE_I18N_EXTENSION' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
@@ -418,13 +418,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -466,8 +465,8 @@
 	$(LOCAL_PATH)/third_party/zlib \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -558,10 +557,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DUSE_I18N_EXTENSION' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
@@ -588,13 +587,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -636,8 +634,8 @@
 	$(LOCAL_PATH)/third_party/zlib \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -724,7 +722,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_derived.target.linux-mips.mk b/Source/core/webcore_derived.target.linux-mips.mk
index 0c62494..4c94da6 100644
--- a/Source/core/webcore_derived.target.linux-mips.mk
+++ b/Source/core/webcore_derived.target.linux-mips.mk
@@ -20,7 +20,8 @@
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_injected_canvas_script_source_gyp)/injected_canvas_script_source.stamp \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_injected_script_source_gyp)/injected_script_source.stamp \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_debugger_script_source_gyp)/debugger_script_source.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a \
 	$(call intermediates-dir-for,GYP,third_party_libwebp_libwebp_gyp)/webp.stamp \
 	$(call intermediates-dir-for,GYP,third_party_npapi_npapi_gyp)/npapi.stamp \
 	$(call intermediates-dir-for,GYP,v8_tools_gyp_v8_gyp)/v8.stamp \
@@ -217,7 +218,6 @@
 	third_party/WebKit/Source/bindings/v8/ScriptHeapSnapshot.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptInstance.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptObject.cpp \
-	third_party/WebKit/Source/bindings/v8/ScriptPreprocessor.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptProfiler.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptPromiseResolver.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptScope.cpp \
@@ -388,10 +388,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DUSE_I18N_EXTENSION' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
@@ -418,13 +418,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -466,8 +465,8 @@
 	$(LOCAL_PATH)/third_party/zlib \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -558,10 +557,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DUSE_I18N_EXTENSION' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
@@ -588,13 +587,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -636,8 +634,8 @@
 	$(LOCAL_PATH)/third_party/zlib \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -720,7 +718,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_derived.target.linux-x86.mk b/Source/core/webcore_derived.target.linux-x86.mk
index 6434b13..996e817 100644
--- a/Source/core/webcore_derived.target.linux-x86.mk
+++ b/Source/core/webcore_derived.target.linux-x86.mk
@@ -20,7 +20,8 @@
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_injected_canvas_script_source_gyp)/injected_canvas_script_source.stamp \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_injected_script_source_gyp)/injected_script_source.stamp \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_debugger_script_source_gyp)/debugger_script_source.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a \
 	$(call intermediates-dir-for,GYP,third_party_libwebp_libwebp_gyp)/webp.stamp \
 	$(call intermediates-dir-for,GYP,third_party_npapi_npapi_gyp)/npapi.stamp \
 	$(call intermediates-dir-for,GYP,v8_tools_gyp_v8_gyp)/v8.stamp \
@@ -217,7 +218,6 @@
 	third_party/WebKit/Source/bindings/v8/ScriptHeapSnapshot.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptInstance.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptObject.cpp \
-	third_party/WebKit/Source/bindings/v8/ScriptPreprocessor.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptProfiler.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptPromiseResolver.cpp \
 	third_party/WebKit/Source/bindings/v8/ScriptScope.cpp \
@@ -390,10 +390,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DUSE_I18N_EXTENSION' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
@@ -420,13 +420,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -468,8 +467,8 @@
 	$(LOCAL_PATH)/third_party/zlib \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -563,10 +562,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DUSE_I18N_EXTENSION' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
@@ -593,13 +592,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -641,8 +639,8 @@
 	$(LOCAL_PATH)/third_party/zlib \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -724,7 +722,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_dom.target.darwin-arm.mk b/Source/core/webcore_dom.target.darwin-arm.mk
index eaf35b3..7aca931 100644
--- a/Source/core/webcore_dom.target.darwin-arm.mk
+++ b/Source/core/webcore_dom.target.darwin-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -46,6 +46,7 @@
 	third_party/WebKit/Source/core/dom/ContextLifecycleObserver.cpp \
 	third_party/WebKit/Source/core/dom/ContextFeatures.cpp \
 	third_party/WebKit/Source/core/dom/ContextLifecycleNotifier.cpp \
+	third_party/WebKit/Source/core/dom/CustomElement.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackDispatcher.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackInvocation.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackQueue.cpp \
@@ -231,10 +232,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -260,13 +261,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -297,8 +297,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -390,10 +390,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -419,13 +419,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -456,8 +455,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -545,7 +544,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_dom.target.darwin-mips.mk b/Source/core/webcore_dom.target.darwin-mips.mk
index 66a5e6d..5aae798 100644
--- a/Source/core/webcore_dom.target.darwin-mips.mk
+++ b/Source/core/webcore_dom.target.darwin-mips.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -46,6 +46,7 @@
 	third_party/WebKit/Source/core/dom/ContextLifecycleObserver.cpp \
 	third_party/WebKit/Source/core/dom/ContextFeatures.cpp \
 	third_party/WebKit/Source/core/dom/ContextLifecycleNotifier.cpp \
+	third_party/WebKit/Source/core/dom/CustomElement.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackDispatcher.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackInvocation.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackQueue.cpp \
@@ -231,10 +232,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -260,13 +261,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -297,8 +297,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -390,10 +390,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -419,13 +419,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -456,8 +455,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -541,7 +540,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_dom.target.darwin-x86.mk b/Source/core/webcore_dom.target.darwin-x86.mk
index f284e6e..ca51e59 100644
--- a/Source/core/webcore_dom.target.darwin-x86.mk
+++ b/Source/core/webcore_dom.target.darwin-x86.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -46,6 +46,7 @@
 	third_party/WebKit/Source/core/dom/ContextLifecycleObserver.cpp \
 	third_party/WebKit/Source/core/dom/ContextFeatures.cpp \
 	third_party/WebKit/Source/core/dom/ContextLifecycleNotifier.cpp \
+	third_party/WebKit/Source/core/dom/CustomElement.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackDispatcher.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackInvocation.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackQueue.cpp \
@@ -233,10 +234,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -262,13 +263,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -299,8 +299,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -395,10 +395,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -424,13 +424,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -461,8 +460,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -545,7 +544,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_dom.target.linux-arm.mk b/Source/core/webcore_dom.target.linux-arm.mk
index eaf35b3..7aca931 100644
--- a/Source/core/webcore_dom.target.linux-arm.mk
+++ b/Source/core/webcore_dom.target.linux-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -46,6 +46,7 @@
 	third_party/WebKit/Source/core/dom/ContextLifecycleObserver.cpp \
 	third_party/WebKit/Source/core/dom/ContextFeatures.cpp \
 	third_party/WebKit/Source/core/dom/ContextLifecycleNotifier.cpp \
+	third_party/WebKit/Source/core/dom/CustomElement.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackDispatcher.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackInvocation.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackQueue.cpp \
@@ -231,10 +232,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -260,13 +261,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -297,8 +297,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -390,10 +390,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -419,13 +419,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -456,8 +455,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -545,7 +544,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_dom.target.linux-mips.mk b/Source/core/webcore_dom.target.linux-mips.mk
index 66a5e6d..5aae798 100644
--- a/Source/core/webcore_dom.target.linux-mips.mk
+++ b/Source/core/webcore_dom.target.linux-mips.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -46,6 +46,7 @@
 	third_party/WebKit/Source/core/dom/ContextLifecycleObserver.cpp \
 	third_party/WebKit/Source/core/dom/ContextFeatures.cpp \
 	third_party/WebKit/Source/core/dom/ContextLifecycleNotifier.cpp \
+	third_party/WebKit/Source/core/dom/CustomElement.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackDispatcher.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackInvocation.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackQueue.cpp \
@@ -231,10 +232,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -260,13 +261,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -297,8 +297,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -390,10 +390,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -419,13 +419,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -456,8 +455,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -541,7 +540,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_dom.target.linux-x86.mk b/Source/core/webcore_dom.target.linux-x86.mk
index f284e6e..ca51e59 100644
--- a/Source/core/webcore_dom.target.linux-x86.mk
+++ b/Source/core/webcore_dom.target.linux-x86.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -46,6 +46,7 @@
 	third_party/WebKit/Source/core/dom/ContextLifecycleObserver.cpp \
 	third_party/WebKit/Source/core/dom/ContextFeatures.cpp \
 	third_party/WebKit/Source/core/dom/ContextLifecycleNotifier.cpp \
+	third_party/WebKit/Source/core/dom/CustomElement.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackDispatcher.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackInvocation.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackQueue.cpp \
@@ -233,10 +234,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -262,13 +263,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -299,8 +299,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -395,10 +395,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -424,13 +424,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -461,8 +460,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -545,7 +544,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_html.target.darwin-arm.mk b/Source/core/webcore_html.target.darwin-arm.mk
index 0f0db47..86b7584 100644
--- a/Source/core/webcore_html.target.darwin-arm.mk
+++ b/Source/core/webcore_html.target.darwin-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -333,10 +333,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -362,13 +362,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -399,8 +398,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -492,10 +491,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -521,13 +520,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -558,8 +556,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -647,7 +645,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_html.target.darwin-mips.mk b/Source/core/webcore_html.target.darwin-mips.mk
index 3259dd4..325abb0 100644
--- a/Source/core/webcore_html.target.darwin-mips.mk
+++ b/Source/core/webcore_html.target.darwin-mips.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -333,10 +333,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -362,13 +362,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -399,8 +398,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -492,10 +491,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -521,13 +520,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -558,8 +556,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -643,7 +641,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_html.target.darwin-x86.mk b/Source/core/webcore_html.target.darwin-x86.mk
index 40def83..f8e91ad 100644
--- a/Source/core/webcore_html.target.darwin-x86.mk
+++ b/Source/core/webcore_html.target.darwin-x86.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -335,10 +335,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -364,13 +364,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -401,8 +400,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -497,10 +496,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -526,13 +525,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -563,8 +561,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -647,7 +645,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_html.target.linux-arm.mk b/Source/core/webcore_html.target.linux-arm.mk
index 0f0db47..86b7584 100644
--- a/Source/core/webcore_html.target.linux-arm.mk
+++ b/Source/core/webcore_html.target.linux-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -333,10 +333,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -362,13 +362,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -399,8 +398,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -492,10 +491,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -521,13 +520,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -558,8 +556,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -647,7 +645,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_html.target.linux-mips.mk b/Source/core/webcore_html.target.linux-mips.mk
index 3259dd4..325abb0 100644
--- a/Source/core/webcore_html.target.linux-mips.mk
+++ b/Source/core/webcore_html.target.linux-mips.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -333,10 +333,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -362,13 +362,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -399,8 +398,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -492,10 +491,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -521,13 +520,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -558,8 +556,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -643,7 +641,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_html.target.linux-x86.mk b/Source/core/webcore_html.target.linux-x86.mk
index 40def83..f8e91ad 100644
--- a/Source/core/webcore_html.target.linux-x86.mk
+++ b/Source/core/webcore_html.target.linux-x86.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -335,10 +335,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -364,13 +364,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -401,8 +400,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -497,10 +496,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -526,13 +525,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -563,8 +561,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -647,7 +645,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_platform.target.darwin-arm.mk b/Source/core/webcore_platform.target.darwin-arm.mk
index 727cf9e..a282faa 100644
--- a/Source/core/webcore_platform.target.darwin-arm.mk
+++ b/Source/core/webcore_platform.target.darwin-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -38,7 +38,6 @@
 	third_party/WebKit/Source/core/platform/DragImage.cpp \
 	third_party/WebKit/Source/core/platform/EventTracer.cpp \
 	third_party/WebKit/Source/core/platform/FileChooser.cpp \
-	third_party/WebKit/Source/core/platform/FileIconLoader.cpp \
 	third_party/WebKit/Source/core/platform/JSONValues.cpp \
 	third_party/WebKit/Source/core/platform/KillRingNone.cpp \
 	third_party/WebKit/Source/core/platform/Language.cpp \
@@ -197,7 +196,6 @@
 	third_party/WebKit/Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/DiscardablePixelRef.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/FontCacheAndroid.cpp \
-	third_party/WebKit/Source/core/platform/graphics/chromium/IconChromiumAndroid.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageChromium.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageDecodingStore.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageFrameGenerator.cpp \
@@ -311,8 +309,6 @@
 	third_party/WebKit/Source/core/platform/network/ParsedContentType.cpp \
 	third_party/WebKit/Source/core/platform/network/ProxyServer.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceError.cpp \
-	third_party/WebKit/Source/core/platform/network/ResourceHandle.cpp \
-	third_party/WebKit/Source/core/platform/network/ResourceHandleClient.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceRequest.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceResponse.cpp \
 	third_party/WebKit/Source/core/platform/network/SocketStreamError.cpp \
@@ -390,10 +386,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -419,13 +415,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -456,8 +451,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -550,10 +545,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -579,13 +574,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -616,8 +610,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -706,7 +700,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_platform.target.darwin-mips.mk b/Source/core/webcore_platform.target.darwin-mips.mk
index 09db1fa..494e6e8 100644
--- a/Source/core/webcore_platform.target.darwin-mips.mk
+++ b/Source/core/webcore_platform.target.darwin-mips.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -38,7 +38,6 @@
 	third_party/WebKit/Source/core/platform/DragImage.cpp \
 	third_party/WebKit/Source/core/platform/EventTracer.cpp \
 	third_party/WebKit/Source/core/platform/FileChooser.cpp \
-	third_party/WebKit/Source/core/platform/FileIconLoader.cpp \
 	third_party/WebKit/Source/core/platform/JSONValues.cpp \
 	third_party/WebKit/Source/core/platform/KillRingNone.cpp \
 	third_party/WebKit/Source/core/platform/Language.cpp \
@@ -197,7 +196,6 @@
 	third_party/WebKit/Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/DiscardablePixelRef.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/FontCacheAndroid.cpp \
-	third_party/WebKit/Source/core/platform/graphics/chromium/IconChromiumAndroid.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageChromium.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageDecodingStore.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageFrameGenerator.cpp \
@@ -311,8 +309,6 @@
 	third_party/WebKit/Source/core/platform/network/ParsedContentType.cpp \
 	third_party/WebKit/Source/core/platform/network/ProxyServer.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceError.cpp \
-	third_party/WebKit/Source/core/platform/network/ResourceHandle.cpp \
-	third_party/WebKit/Source/core/platform/network/ResourceHandleClient.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceRequest.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceResponse.cpp \
 	third_party/WebKit/Source/core/platform/network/SocketStreamError.cpp \
@@ -390,10 +386,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -419,13 +415,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -456,8 +451,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -550,10 +545,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -579,13 +574,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -616,8 +610,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -702,7 +696,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_platform.target.darwin-x86.mk b/Source/core/webcore_platform.target.darwin-x86.mk
index 4ecb622..a97434c 100644
--- a/Source/core/webcore_platform.target.darwin-x86.mk
+++ b/Source/core/webcore_platform.target.darwin-x86.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -38,7 +38,6 @@
 	third_party/WebKit/Source/core/platform/DragImage.cpp \
 	third_party/WebKit/Source/core/platform/EventTracer.cpp \
 	third_party/WebKit/Source/core/platform/FileChooser.cpp \
-	third_party/WebKit/Source/core/platform/FileIconLoader.cpp \
 	third_party/WebKit/Source/core/platform/JSONValues.cpp \
 	third_party/WebKit/Source/core/platform/KillRingNone.cpp \
 	third_party/WebKit/Source/core/platform/Language.cpp \
@@ -197,7 +196,6 @@
 	third_party/WebKit/Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/DiscardablePixelRef.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/FontCacheAndroid.cpp \
-	third_party/WebKit/Source/core/platform/graphics/chromium/IconChromiumAndroid.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageChromium.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageDecodingStore.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageFrameGenerator.cpp \
@@ -311,8 +309,6 @@
 	third_party/WebKit/Source/core/platform/network/ParsedContentType.cpp \
 	third_party/WebKit/Source/core/platform/network/ProxyServer.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceError.cpp \
-	third_party/WebKit/Source/core/platform/network/ResourceHandle.cpp \
-	third_party/WebKit/Source/core/platform/network/ResourceHandleClient.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceRequest.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceResponse.cpp \
 	third_party/WebKit/Source/core/platform/network/SocketStreamError.cpp \
@@ -392,10 +388,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -421,13 +417,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -458,8 +453,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -555,10 +550,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -584,13 +579,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -621,8 +615,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -706,7 +700,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_platform.target.linux-arm.mk b/Source/core/webcore_platform.target.linux-arm.mk
index 727cf9e..a282faa 100644
--- a/Source/core/webcore_platform.target.linux-arm.mk
+++ b/Source/core/webcore_platform.target.linux-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -38,7 +38,6 @@
 	third_party/WebKit/Source/core/platform/DragImage.cpp \
 	third_party/WebKit/Source/core/platform/EventTracer.cpp \
 	third_party/WebKit/Source/core/platform/FileChooser.cpp \
-	third_party/WebKit/Source/core/platform/FileIconLoader.cpp \
 	third_party/WebKit/Source/core/platform/JSONValues.cpp \
 	third_party/WebKit/Source/core/platform/KillRingNone.cpp \
 	third_party/WebKit/Source/core/platform/Language.cpp \
@@ -197,7 +196,6 @@
 	third_party/WebKit/Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/DiscardablePixelRef.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/FontCacheAndroid.cpp \
-	third_party/WebKit/Source/core/platform/graphics/chromium/IconChromiumAndroid.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageChromium.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageDecodingStore.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageFrameGenerator.cpp \
@@ -311,8 +309,6 @@
 	third_party/WebKit/Source/core/platform/network/ParsedContentType.cpp \
 	third_party/WebKit/Source/core/platform/network/ProxyServer.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceError.cpp \
-	third_party/WebKit/Source/core/platform/network/ResourceHandle.cpp \
-	third_party/WebKit/Source/core/platform/network/ResourceHandleClient.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceRequest.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceResponse.cpp \
 	third_party/WebKit/Source/core/platform/network/SocketStreamError.cpp \
@@ -390,10 +386,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -419,13 +415,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -456,8 +451,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -550,10 +545,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -579,13 +574,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -616,8 +610,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -706,7 +700,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_platform.target.linux-mips.mk b/Source/core/webcore_platform.target.linux-mips.mk
index 09db1fa..494e6e8 100644
--- a/Source/core/webcore_platform.target.linux-mips.mk
+++ b/Source/core/webcore_platform.target.linux-mips.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -38,7 +38,6 @@
 	third_party/WebKit/Source/core/platform/DragImage.cpp \
 	third_party/WebKit/Source/core/platform/EventTracer.cpp \
 	third_party/WebKit/Source/core/platform/FileChooser.cpp \
-	third_party/WebKit/Source/core/platform/FileIconLoader.cpp \
 	third_party/WebKit/Source/core/platform/JSONValues.cpp \
 	third_party/WebKit/Source/core/platform/KillRingNone.cpp \
 	third_party/WebKit/Source/core/platform/Language.cpp \
@@ -197,7 +196,6 @@
 	third_party/WebKit/Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/DiscardablePixelRef.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/FontCacheAndroid.cpp \
-	third_party/WebKit/Source/core/platform/graphics/chromium/IconChromiumAndroid.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageChromium.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageDecodingStore.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageFrameGenerator.cpp \
@@ -311,8 +309,6 @@
 	third_party/WebKit/Source/core/platform/network/ParsedContentType.cpp \
 	third_party/WebKit/Source/core/platform/network/ProxyServer.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceError.cpp \
-	third_party/WebKit/Source/core/platform/network/ResourceHandle.cpp \
-	third_party/WebKit/Source/core/platform/network/ResourceHandleClient.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceRequest.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceResponse.cpp \
 	third_party/WebKit/Source/core/platform/network/SocketStreamError.cpp \
@@ -390,10 +386,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -419,13 +415,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -456,8 +451,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -550,10 +545,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -579,13 +574,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -616,8 +610,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -702,7 +696,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_platform.target.linux-x86.mk b/Source/core/webcore_platform.target.linux-x86.mk
index 4ecb622..a97434c 100644
--- a/Source/core/webcore_platform.target.linux-x86.mk
+++ b/Source/core/webcore_platform.target.linux-x86.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -38,7 +38,6 @@
 	third_party/WebKit/Source/core/platform/DragImage.cpp \
 	third_party/WebKit/Source/core/platform/EventTracer.cpp \
 	third_party/WebKit/Source/core/platform/FileChooser.cpp \
-	third_party/WebKit/Source/core/platform/FileIconLoader.cpp \
 	third_party/WebKit/Source/core/platform/JSONValues.cpp \
 	third_party/WebKit/Source/core/platform/KillRingNone.cpp \
 	third_party/WebKit/Source/core/platform/Language.cpp \
@@ -197,7 +196,6 @@
 	third_party/WebKit/Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/DiscardablePixelRef.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/FontCacheAndroid.cpp \
-	third_party/WebKit/Source/core/platform/graphics/chromium/IconChromiumAndroid.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageChromium.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageDecodingStore.cpp \
 	third_party/WebKit/Source/core/platform/graphics/chromium/ImageFrameGenerator.cpp \
@@ -311,8 +309,6 @@
 	third_party/WebKit/Source/core/platform/network/ParsedContentType.cpp \
 	third_party/WebKit/Source/core/platform/network/ProxyServer.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceError.cpp \
-	third_party/WebKit/Source/core/platform/network/ResourceHandle.cpp \
-	third_party/WebKit/Source/core/platform/network/ResourceHandleClient.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceRequest.cpp \
 	third_party/WebKit/Source/core/platform/network/ResourceResponse.cpp \
 	third_party/WebKit/Source/core/platform/network/SocketStreamError.cpp \
@@ -392,10 +388,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -421,13 +417,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -458,8 +453,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -555,10 +550,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -584,13 +579,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -621,8 +615,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -706,7 +700,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_platform_geometry.target.darwin-arm.mk b/Source/core/webcore_platform_geometry.target.darwin-arm.mk
index b63850e..70b2c97 100644
--- a/Source/core/webcore_platform_geometry.target.darwin-arm.mk
+++ b/Source/core/webcore_platform_geometry.target.darwin-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -83,10 +83,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -112,13 +112,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -149,8 +148,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -242,10 +241,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -271,13 +270,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -308,8 +306,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -397,7 +395,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_platform_geometry.target.darwin-mips.mk b/Source/core/webcore_platform_geometry.target.darwin-mips.mk
index 8dde62b..47e620f 100644
--- a/Source/core/webcore_platform_geometry.target.darwin-mips.mk
+++ b/Source/core/webcore_platform_geometry.target.darwin-mips.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -83,10 +83,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -112,13 +112,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -149,8 +148,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -242,10 +241,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -271,13 +270,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -308,8 +306,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -393,7 +391,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_platform_geometry.target.darwin-x86.mk b/Source/core/webcore_platform_geometry.target.darwin-x86.mk
index 4504f1c..bc09104 100644
--- a/Source/core/webcore_platform_geometry.target.darwin-x86.mk
+++ b/Source/core/webcore_platform_geometry.target.darwin-x86.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -85,10 +85,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -114,13 +114,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -151,8 +150,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -247,10 +246,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -276,13 +275,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -313,8 +311,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -397,7 +395,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_platform_geometry.target.linux-arm.mk b/Source/core/webcore_platform_geometry.target.linux-arm.mk
index b63850e..70b2c97 100644
--- a/Source/core/webcore_platform_geometry.target.linux-arm.mk
+++ b/Source/core/webcore_platform_geometry.target.linux-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -83,10 +83,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -112,13 +112,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -149,8 +148,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -242,10 +241,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -271,13 +270,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -308,8 +306,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -397,7 +395,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_platform_geometry.target.linux-mips.mk b/Source/core/webcore_platform_geometry.target.linux-mips.mk
index 8dde62b..47e620f 100644
--- a/Source/core/webcore_platform_geometry.target.linux-mips.mk
+++ b/Source/core/webcore_platform_geometry.target.linux-mips.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -83,10 +83,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -112,13 +112,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -149,8 +148,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -242,10 +241,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -271,13 +270,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -308,8 +306,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -393,7 +391,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_platform_geometry.target.linux-x86.mk b/Source/core/webcore_platform_geometry.target.linux-x86.mk
index 4504f1c..bc09104 100644
--- a/Source/core/webcore_platform_geometry.target.linux-x86.mk
+++ b/Source/core/webcore_platform_geometry.target.linux-x86.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -85,10 +85,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -114,13 +114,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -151,8 +150,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -247,10 +246,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -276,13 +275,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -313,8 +311,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -397,7 +395,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_prerequisites.target.darwin-arm.mk b/Source/core/webcore_prerequisites.target.darwin-arm.mk
index e299d16..d1b5c61 100644
--- a/Source/core/webcore_prerequisites.target.darwin-arm.mk
+++ b/Source/core/webcore_prerequisites.target.darwin-arm.mk
@@ -25,7 +25,7 @@
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_weborigin_weborigin_gyp)/third_party_WebKit_Source_weborigin_weborigin_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_angle_dx11_src_translator_glsl_gyp)/third_party_angle_dx11_src_translator_glsl_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,gpu_gles2_c_lib_gyp)/gpu_gles2_c_lib_gyp.a \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_iccjpeg_iccjpeg_gyp)/third_party_iccjpeg_iccjpeg_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_libpng_libpng_gyp)/third_party_libpng_libpng_gyp.a \
 	$(call intermediates-dir-for,GYP,third_party_libwebp_libwebp_gyp)/webp.stamp \
diff --git a/Source/core/webcore_prerequisites.target.darwin-mips.mk b/Source/core/webcore_prerequisites.target.darwin-mips.mk
index e299d16..d1b5c61 100644
--- a/Source/core/webcore_prerequisites.target.darwin-mips.mk
+++ b/Source/core/webcore_prerequisites.target.darwin-mips.mk
@@ -25,7 +25,7 @@
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_weborigin_weborigin_gyp)/third_party_WebKit_Source_weborigin_weborigin_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_angle_dx11_src_translator_glsl_gyp)/third_party_angle_dx11_src_translator_glsl_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,gpu_gles2_c_lib_gyp)/gpu_gles2_c_lib_gyp.a \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_iccjpeg_iccjpeg_gyp)/third_party_iccjpeg_iccjpeg_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_libpng_libpng_gyp)/third_party_libpng_libpng_gyp.a \
 	$(call intermediates-dir-for,GYP,third_party_libwebp_libwebp_gyp)/webp.stamp \
diff --git a/Source/core/webcore_prerequisites.target.darwin-x86.mk b/Source/core/webcore_prerequisites.target.darwin-x86.mk
index e299d16..d1b5c61 100644
--- a/Source/core/webcore_prerequisites.target.darwin-x86.mk
+++ b/Source/core/webcore_prerequisites.target.darwin-x86.mk
@@ -25,7 +25,7 @@
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_weborigin_weborigin_gyp)/third_party_WebKit_Source_weborigin_weborigin_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_angle_dx11_src_translator_glsl_gyp)/third_party_angle_dx11_src_translator_glsl_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,gpu_gles2_c_lib_gyp)/gpu_gles2_c_lib_gyp.a \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_iccjpeg_iccjpeg_gyp)/third_party_iccjpeg_iccjpeg_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_libpng_libpng_gyp)/third_party_libpng_libpng_gyp.a \
 	$(call intermediates-dir-for,GYP,third_party_libwebp_libwebp_gyp)/webp.stamp \
diff --git a/Source/core/webcore_prerequisites.target.linux-arm.mk b/Source/core/webcore_prerequisites.target.linux-arm.mk
index e299d16..d1b5c61 100644
--- a/Source/core/webcore_prerequisites.target.linux-arm.mk
+++ b/Source/core/webcore_prerequisites.target.linux-arm.mk
@@ -25,7 +25,7 @@
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_weborigin_weborigin_gyp)/third_party_WebKit_Source_weborigin_weborigin_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_angle_dx11_src_translator_glsl_gyp)/third_party_angle_dx11_src_translator_glsl_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,gpu_gles2_c_lib_gyp)/gpu_gles2_c_lib_gyp.a \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_iccjpeg_iccjpeg_gyp)/third_party_iccjpeg_iccjpeg_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_libpng_libpng_gyp)/third_party_libpng_libpng_gyp.a \
 	$(call intermediates-dir-for,GYP,third_party_libwebp_libwebp_gyp)/webp.stamp \
diff --git a/Source/core/webcore_prerequisites.target.linux-mips.mk b/Source/core/webcore_prerequisites.target.linux-mips.mk
index e299d16..d1b5c61 100644
--- a/Source/core/webcore_prerequisites.target.linux-mips.mk
+++ b/Source/core/webcore_prerequisites.target.linux-mips.mk
@@ -25,7 +25,7 @@
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_weborigin_weborigin_gyp)/third_party_WebKit_Source_weborigin_weborigin_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_angle_dx11_src_translator_glsl_gyp)/third_party_angle_dx11_src_translator_glsl_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,gpu_gles2_c_lib_gyp)/gpu_gles2_c_lib_gyp.a \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_iccjpeg_iccjpeg_gyp)/third_party_iccjpeg_iccjpeg_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_libpng_libpng_gyp)/third_party_libpng_libpng_gyp.a \
 	$(call intermediates-dir-for,GYP,third_party_libwebp_libwebp_gyp)/webp.stamp \
diff --git a/Source/core/webcore_prerequisites.target.linux-x86.mk b/Source/core/webcore_prerequisites.target.linux-x86.mk
index e299d16..d1b5c61 100644
--- a/Source/core/webcore_prerequisites.target.linux-x86.mk
+++ b/Source/core/webcore_prerequisites.target.linux-x86.mk
@@ -25,7 +25,7 @@
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_WebKit_Source_weborigin_weborigin_gyp)/third_party_WebKit_Source_weborigin_weborigin_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_angle_dx11_src_translator_glsl_gyp)/third_party_angle_dx11_src_translator_glsl_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,gpu_gles2_c_lib_gyp)/gpu_gles2_c_lib_gyp.a \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a \
+	$(call intermediates-dir-for,GYP,skia_skia_gyp)/skia.stamp \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_iccjpeg_iccjpeg_gyp)/third_party_iccjpeg_iccjpeg_gyp.a \
 	$(call intermediates-dir-for,STATIC_LIBRARIES,third_party_libpng_libpng_gyp)/third_party_libpng_libpng_gyp.a \
 	$(call intermediates-dir-for,GYP,third_party_libwebp_libwebp_gyp)/webp.stamp \
diff --git a/Source/core/webcore_remaining.target.darwin-arm.mk b/Source/core/webcore_remaining.target.darwin-arm.mk
index 3fdb646..431c4f8 100644
--- a/Source/core/webcore_remaining.target.darwin-arm.mk
+++ b/Source/core/webcore_remaining.target.darwin-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -152,6 +152,7 @@
 	third_party/WebKit/Source/core/css/SelectorCheckerFastPath.cpp \
 	third_party/WebKit/Source/core/css/SelectorFilter.cpp \
 	third_party/WebKit/Source/core/css/ShadowValue.cpp \
+	third_party/WebKit/Source/core/css/StyleColor.cpp \
 	third_party/WebKit/Source/core/css/StyleInvalidationAnalysis.cpp \
 	third_party/WebKit/Source/core/css/StyleMedia.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySerializer.cpp \
@@ -545,10 +546,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -574,13 +575,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -611,8 +611,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -706,10 +706,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -735,13 +735,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -772,8 +771,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -862,7 +861,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_remaining.target.darwin-mips.mk b/Source/core/webcore_remaining.target.darwin-mips.mk
index e52010a..094350e 100644
--- a/Source/core/webcore_remaining.target.darwin-mips.mk
+++ b/Source/core/webcore_remaining.target.darwin-mips.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -152,6 +152,7 @@
 	third_party/WebKit/Source/core/css/SelectorCheckerFastPath.cpp \
 	third_party/WebKit/Source/core/css/SelectorFilter.cpp \
 	third_party/WebKit/Source/core/css/ShadowValue.cpp \
+	third_party/WebKit/Source/core/css/StyleColor.cpp \
 	third_party/WebKit/Source/core/css/StyleInvalidationAnalysis.cpp \
 	third_party/WebKit/Source/core/css/StyleMedia.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySerializer.cpp \
@@ -545,10 +546,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -574,13 +575,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -611,8 +611,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -706,10 +706,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -735,13 +735,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -772,8 +771,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -858,7 +857,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_remaining.target.darwin-x86.mk b/Source/core/webcore_remaining.target.darwin-x86.mk
index f42f81f..4c284a4 100644
--- a/Source/core/webcore_remaining.target.darwin-x86.mk
+++ b/Source/core/webcore_remaining.target.darwin-x86.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -152,6 +152,7 @@
 	third_party/WebKit/Source/core/css/SelectorCheckerFastPath.cpp \
 	third_party/WebKit/Source/core/css/SelectorFilter.cpp \
 	third_party/WebKit/Source/core/css/ShadowValue.cpp \
+	third_party/WebKit/Source/core/css/StyleColor.cpp \
 	third_party/WebKit/Source/core/css/StyleInvalidationAnalysis.cpp \
 	third_party/WebKit/Source/core/css/StyleMedia.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySerializer.cpp \
@@ -547,10 +548,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -576,13 +577,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -613,8 +613,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -711,10 +711,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -740,13 +740,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -777,8 +776,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -862,7 +861,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_remaining.target.linux-arm.mk b/Source/core/webcore_remaining.target.linux-arm.mk
index 3fdb646..431c4f8 100644
--- a/Source/core/webcore_remaining.target.linux-arm.mk
+++ b/Source/core/webcore_remaining.target.linux-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -152,6 +152,7 @@
 	third_party/WebKit/Source/core/css/SelectorCheckerFastPath.cpp \
 	third_party/WebKit/Source/core/css/SelectorFilter.cpp \
 	third_party/WebKit/Source/core/css/ShadowValue.cpp \
+	third_party/WebKit/Source/core/css/StyleColor.cpp \
 	third_party/WebKit/Source/core/css/StyleInvalidationAnalysis.cpp \
 	third_party/WebKit/Source/core/css/StyleMedia.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySerializer.cpp \
@@ -545,10 +546,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -574,13 +575,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -611,8 +611,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -706,10 +706,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -735,13 +735,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -772,8 +771,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -862,7 +861,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_remaining.target.linux-mips.mk b/Source/core/webcore_remaining.target.linux-mips.mk
index e52010a..094350e 100644
--- a/Source/core/webcore_remaining.target.linux-mips.mk
+++ b/Source/core/webcore_remaining.target.linux-mips.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -152,6 +152,7 @@
 	third_party/WebKit/Source/core/css/SelectorCheckerFastPath.cpp \
 	third_party/WebKit/Source/core/css/SelectorFilter.cpp \
 	third_party/WebKit/Source/core/css/ShadowValue.cpp \
+	third_party/WebKit/Source/core/css/StyleColor.cpp \
 	third_party/WebKit/Source/core/css/StyleInvalidationAnalysis.cpp \
 	third_party/WebKit/Source/core/css/StyleMedia.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySerializer.cpp \
@@ -545,10 +546,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -574,13 +575,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -611,8 +611,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -706,10 +706,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -735,13 +735,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -772,8 +771,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -858,7 +857,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_remaining.target.linux-x86.mk b/Source/core/webcore_remaining.target.linux-x86.mk
index f42f81f..4c284a4 100644
--- a/Source/core/webcore_remaining.target.linux-x86.mk
+++ b/Source/core/webcore_remaining.target.linux-x86.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -152,6 +152,7 @@
 	third_party/WebKit/Source/core/css/SelectorCheckerFastPath.cpp \
 	third_party/WebKit/Source/core/css/SelectorFilter.cpp \
 	third_party/WebKit/Source/core/css/ShadowValue.cpp \
+	third_party/WebKit/Source/core/css/StyleColor.cpp \
 	third_party/WebKit/Source/core/css/StyleInvalidationAnalysis.cpp \
 	third_party/WebKit/Source/core/css/StyleMedia.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySerializer.cpp \
@@ -547,10 +548,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -576,13 +577,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -613,8 +613,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -711,10 +711,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -740,13 +740,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -777,8 +776,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -862,7 +861,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_rendering.target.darwin-arm.mk b/Source/core/webcore_rendering.target.darwin-arm.mk
index 5608945..ac308c8 100644
--- a/Source/core/webcore_rendering.target.darwin-arm.mk
+++ b/Source/core/webcore_rendering.target.darwin-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -77,6 +77,7 @@
 	third_party/WebKit/Source/core/rendering/RenderLayerBacking.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerCompositor.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerFilterInfo.cpp \
+	third_party/WebKit/Source/core/rendering/RenderLayerScrollableArea.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerModelObject.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLazyBlock.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLineBoxList.cpp \
@@ -223,10 +224,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -252,13 +253,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -289,8 +289,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -382,10 +382,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -411,13 +411,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -448,8 +447,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -537,7 +536,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_rendering.target.darwin-mips.mk b/Source/core/webcore_rendering.target.darwin-mips.mk
index 61ad3e8..a2fd928 100644
--- a/Source/core/webcore_rendering.target.darwin-mips.mk
+++ b/Source/core/webcore_rendering.target.darwin-mips.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -77,6 +77,7 @@
 	third_party/WebKit/Source/core/rendering/RenderLayerBacking.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerCompositor.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerFilterInfo.cpp \
+	third_party/WebKit/Source/core/rendering/RenderLayerScrollableArea.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerModelObject.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLazyBlock.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLineBoxList.cpp \
@@ -223,10 +224,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -252,13 +253,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -289,8 +289,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -382,10 +382,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -411,13 +411,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -448,8 +447,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -533,7 +532,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_rendering.target.darwin-x86.mk b/Source/core/webcore_rendering.target.darwin-x86.mk
index 4fe83b2..c224097 100644
--- a/Source/core/webcore_rendering.target.darwin-x86.mk
+++ b/Source/core/webcore_rendering.target.darwin-x86.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -77,6 +77,7 @@
 	third_party/WebKit/Source/core/rendering/RenderLayerBacking.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerCompositor.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerFilterInfo.cpp \
+	third_party/WebKit/Source/core/rendering/RenderLayerScrollableArea.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerModelObject.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLazyBlock.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLineBoxList.cpp \
@@ -226,10 +227,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -255,13 +256,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -292,8 +292,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -389,10 +389,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -418,13 +418,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -455,8 +454,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -539,7 +538,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_rendering.target.linux-arm.mk b/Source/core/webcore_rendering.target.linux-arm.mk
index 5608945..ac308c8 100644
--- a/Source/core/webcore_rendering.target.linux-arm.mk
+++ b/Source/core/webcore_rendering.target.linux-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -77,6 +77,7 @@
 	third_party/WebKit/Source/core/rendering/RenderLayerBacking.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerCompositor.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerFilterInfo.cpp \
+	third_party/WebKit/Source/core/rendering/RenderLayerScrollableArea.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerModelObject.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLazyBlock.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLineBoxList.cpp \
@@ -223,10 +224,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -252,13 +253,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -289,8 +289,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -382,10 +382,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -411,13 +411,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -448,8 +447,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -537,7 +536,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_rendering.target.linux-mips.mk b/Source/core/webcore_rendering.target.linux-mips.mk
index 61ad3e8..a2fd928 100644
--- a/Source/core/webcore_rendering.target.linux-mips.mk
+++ b/Source/core/webcore_rendering.target.linux-mips.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -77,6 +77,7 @@
 	third_party/WebKit/Source/core/rendering/RenderLayerBacking.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerCompositor.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerFilterInfo.cpp \
+	third_party/WebKit/Source/core/rendering/RenderLayerScrollableArea.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerModelObject.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLazyBlock.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLineBoxList.cpp \
@@ -223,10 +224,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -252,13 +253,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -289,8 +289,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -382,10 +382,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -411,13 +411,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -448,8 +447,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -533,7 +532,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_rendering.target.linux-x86.mk b/Source/core/webcore_rendering.target.linux-x86.mk
index 4fe83b2..c224097 100644
--- a/Source/core/webcore_rendering.target.linux-x86.mk
+++ b/Source/core/webcore_rendering.target.linux-x86.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -77,6 +77,7 @@
 	third_party/WebKit/Source/core/rendering/RenderLayerBacking.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerCompositor.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerFilterInfo.cpp \
+	third_party/WebKit/Source/core/rendering/RenderLayerScrollableArea.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLayerModelObject.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLazyBlock.cpp \
 	third_party/WebKit/Source/core/rendering/RenderLineBoxList.cpp \
@@ -226,10 +227,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -255,13 +256,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -292,8 +292,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -389,10 +389,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -418,13 +418,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -455,8 +454,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -539,7 +538,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_svg.target.darwin-arm.mk b/Source/core/webcore_svg.target.darwin-arm.mk
index 7cb2ea7..085dc28 100644
--- a/Source/core/webcore_svg.target.darwin-arm.mk
+++ b/Source/core/webcore_svg.target.darwin-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -292,10 +292,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -321,13 +321,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -358,8 +357,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -451,10 +450,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -480,13 +479,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -517,8 +515,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -606,7 +604,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_svg.target.darwin-mips.mk b/Source/core/webcore_svg.target.darwin-mips.mk
index 9386b00..f58e142 100644
--- a/Source/core/webcore_svg.target.darwin-mips.mk
+++ b/Source/core/webcore_svg.target.darwin-mips.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -292,10 +292,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -321,13 +321,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -358,8 +357,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -451,10 +450,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -480,13 +479,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -517,8 +515,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -602,7 +600,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_svg.target.darwin-x86.mk b/Source/core/webcore_svg.target.darwin-x86.mk
index aa4c74f..314247c 100644
--- a/Source/core/webcore_svg.target.darwin-x86.mk
+++ b/Source/core/webcore_svg.target.darwin-x86.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -294,10 +294,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -323,13 +323,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -360,8 +359,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -456,10 +455,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -485,13 +484,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -522,8 +520,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -606,7 +604,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_svg.target.linux-arm.mk b/Source/core/webcore_svg.target.linux-arm.mk
index 7cb2ea7..085dc28 100644
--- a/Source/core/webcore_svg.target.linux-arm.mk
+++ b/Source/core/webcore_svg.target.linux-arm.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -292,10 +292,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -321,13 +321,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -358,8 +357,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -451,10 +450,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -480,13 +479,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -517,8 +515,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -606,7 +604,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_svg.target.linux-mips.mk b/Source/core/webcore_svg.target.linux-mips.mk
index 9386b00..f58e142 100644
--- a/Source/core/webcore_svg.target.linux-mips.mk
+++ b/Source/core/webcore_svg.target.linux-mips.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -292,10 +292,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -321,13 +321,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -358,8 +357,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -451,10 +450,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -480,13 +479,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -517,8 +515,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -602,7 +600,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/webcore_svg.target.linux-x86.mk b/Source/core/webcore_svg.target.linux-x86.mk
index aa4c74f..314247c 100644
--- a/Source/core/webcore_svg.target.linux-x86.mk
+++ b/Source/core/webcore_svg.target.linux-x86.mk
@@ -12,7 +12,7 @@
 # Make sure our deps are built first.
 GYP_TARGET_DEPENDENCIES := \
 	$(call intermediates-dir-for,GYP,third_party_WebKit_Source_core_webcore_prerequisites_gyp)/webcore_prerequisites.stamp \
-	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_gyp)/skia_skia_gyp.a
+	$(call intermediates-dir-for,STATIC_LIBRARIES,skia_skia_library_gyp)/skia_skia_library_gyp.a
 
 GYP_GENERATED_OUTPUTS :=
 
@@ -294,10 +294,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -323,13 +323,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -360,8 +359,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -456,10 +455,10 @@
 	'-DCHROMIUM_BUILD' \
 	'-DUSE_LIBJPEG_TURBO=1' \
 	'-DUSE_PROPRIETARY_CODECS' \
+	'-DENABLE_CONFIGURATION_POLICY' \
 	'-DENABLE_GPU=1' \
 	'-DUSE_OPENSSL=1' \
 	'-DENABLE_EGLIMAGE=1' \
-	'-DENABLE_LANGUAGE_DETECTION=1' \
 	'-DWEBCORE_NAVIGATOR_VENDOR="Google Inc."' \
 	'-DWEBKIT_IMPLEMENTATION=1' \
 	'-DINSIDE_WEBKIT' \
@@ -485,13 +484,12 @@
 	'-DENABLE_OPENTYPE_VERTICAL=1' \
 	'-DWTF_USE_HARFBUZZ=1' \
 	'-DU_USING_ICU_NAMESPACE=0' \
-	'-DSK_BUILD_NO_IMAGE_ENCODE' \
-	'-DSK_DEFERRED_CANVAS_USES_GPIPE=1' \
-	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
-	'-DGR_AGGRESSIVE_SHADER_OPTS=1' \
 	'-DSK_ENABLE_INST_COUNT=0' \
-	'-DSK_USE_POSIX_THREADS' \
+	'-DSK_SUPPORT_GPU=1' \
+	'-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' \
 	'-DSK_BUILD_FOR_ANDROID' \
+	'-DUSE_CHROMIUM_SKIA' \
+	'-DSK_USE_POSIX_THREADS' \
 	'-DCHROME_PNG_WRITE_SUPPORT' \
 	'-DPNG_USER_CONFIG' \
 	'-DLIBXML_STATIC' \
@@ -522,8 +520,8 @@
 	$(LOCAL_PATH)/third_party/angle_dx11/include/GLSLANG \
 	$(PWD)/external/icu4c/common \
 	$(PWD)/external/icu4c/i18n \
-	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/src/core \
+	$(LOCAL_PATH)/skia/config \
 	$(LOCAL_PATH)/third_party/skia/include/config \
 	$(LOCAL_PATH)/third_party/skia/include/core \
 	$(LOCAL_PATH)/third_party/skia/include/effects \
@@ -606,7 +604,7 @@
 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))
 
 LOCAL_STATIC_LIBRARIES := \
-	skia_skia_gyp
+	skia_skia_library_gyp
 
 # Enable grouping to fix circular references
 LOCAL_GROUP_STATIC_LIBRARIES := true
diff --git a/Source/core/xml/XMLTreeViewer.cpp b/Source/core/xml/XMLTreeViewer.cpp
index f5595df..4c9109b 100644
--- a/Source/core/xml/XMLTreeViewer.cpp
+++ b/Source/core/xml/XMLTreeViewer.cpp
@@ -72,7 +72,7 @@
 
     String cssString(reinterpret_cast<const char*>(XMLViewer_css), sizeof(XMLViewer_css));
     RefPtr<Text> text = m_document->createTextNode(cssString);
-    m_document->getElementById("xml-viewer-style")->appendChild(text, IGNORE_EXCEPTION);
+    m_document->getElementById("xml-viewer-style")->appendChild(text, IGNORE_EXCEPTION, AttachLazily);
 }
 
 } // namespace WebCore