Merge from Chromium at DEPS revision r213057

This commit was generated by merge_to_master.py.

Change-Id: If0dbdee1edae80ae428c081eb0ecd6ce3518559f
diff --git a/Source/core/Resources/pagepopups/calendarPicker.css b/Source/core/Resources/pagepopups/calendarPicker.css
index bab88b5..18d1cf2 100644
--- a/Source/core/Resources/pagepopups/calendarPicker.css
+++ b/Source/core/Resources/pagepopups/calendarPicker.css
@@ -64,7 +64,7 @@
     box-sizing: border-box;
     display: inline-block;
     cursor: default;
-    -webkit-transition: color 1s;
+    transition: color 1s;
     padding: 1px;
 }
 
diff --git a/Source/core/Resources/pagepopups/chromium/calendarPickerChromium.css b/Source/core/Resources/pagepopups/chromium/calendarPickerChromium.css
index 6ffda69..167590d 100644
--- a/Source/core/Resources/pagepopups/chromium/calendarPickerChromium.css
+++ b/Source/core/Resources/pagepopups/chromium/calendarPickerChromium.css
@@ -32,7 +32,7 @@
 .month-popup-button:focus,
 .year-list-view:focus,
 .calendar-table-view:focus {
-    -webkit-transition: border-color 200ms;
+    transition: border-color 200ms;
     /* We use border color because it follows the border radius (unlike outline).
     * This is particularly noticeable on mac. */
     border-color: rgb(77, 144, 254) !important;
@@ -42,5 +42,5 @@
 .preparing button:focus,
 .preparing .year-list-view:focus,
 .preparing .calendar-table-view:focus {
-    -webkit-transition: none;
+    transition: none;
 }
diff --git a/Source/core/Resources/pagepopups/chromium/pickerCommonChromium.css b/Source/core/Resources/pagepopups/chromium/pickerCommonChromium.css
index 97e327e..b207a0d 100644
--- a/Source/core/Resources/pagepopups/chromium/pickerCommonChromium.css
+++ b/Source/core/Resources/pagepopups/chromium/pickerCommonChromium.css
@@ -62,7 +62,7 @@
 }
 
 :enabled:focus:-webkit-any(button, input[type='button']) {
-    -webkit-transition: border-color 200ms;
+    transition: border-color 200ms;
     /* We use border color because it follows the border radius (unlike outline).
     * This is particularly noticeable on mac. */
     border-color: rgb(77, 144, 254);
diff --git a/Source/core/accessibility/AXObjectCache.cpp b/Source/core/accessibility/AXObjectCache.cpp
index dd40ea5..08b19d0 100644
--- a/Source/core/accessibility/AXObjectCache.cpp
+++ b/Source/core/accessibility/AXObjectCache.cpp
@@ -156,7 +156,7 @@
 
     // get the focused node in the page
     Document* focusedDocument = page->focusController()->focusedOrMainFrame()->document();
-    Node* focusedNode = focusedDocument->focusedNode();
+    Node* focusedNode = focusedDocument->focusedElement();
     if (!focusedNode)
         focusedNode = focusedDocument;
 
@@ -622,6 +622,9 @@
         if (!obj->axObjectID())
             continue;
 
+        if (!obj->axObjectCache())
+            continue;
+
 #ifndef NDEBUG
         // Make sure none of the render views are in the process of being layed out.
         // Notifications should only be sent after the renderer has finished
@@ -960,12 +963,12 @@
 
     switch (notification) {
     case AXActiveDescendantChanged:
-        if (!obj->document()->focusedNode() || (obj->node() != obj->document()->focusedNode()))
+        if (!obj->document()->focusedElement() || (obj->node() != obj->document()->focusedElement()))
             break;
 
         // Calling handleFocusedUIElementChanged will focus the new active
         // descendant and send the AXFocusedUIElementChanged notification.
-        handleFocusedUIElementChanged(0, obj->document()->focusedNode());
+        handleFocusedUIElementChanged(0, obj->document()->focusedElement());
         break;
     case AXAriaAttributeChanged:
     case AXAutocorrectionOccured:
diff --git a/Source/core/accessibility/AccessibilityRenderObject.cpp b/Source/core/accessibility/AccessibilityRenderObject.cpp
index 094a0d1..22e5779 100644
--- a/Source/core/accessibility/AccessibilityRenderObject.cpp
+++ b/Source/core/accessibility/AccessibilityRenderObject.cpp
@@ -571,13 +571,13 @@
     if (!document)
         return false;
 
-    Node* focusedNode = document->focusedNode();
-    if (!focusedNode)
+    Element* focusedElement = document->focusedElement();
+    if (!focusedElement)
         return false;
 
     // A web area is represented by the Document node in the DOM tree, which isn't focusable.
     // Check instead if the frame's selection controller is focused
-    if (focusedNode == m_renderer->node()
+    if (focusedElement == m_renderer->node()
         || (roleValue() == WebAreaRole && document->frame()->selection()->isFocusedAndActive()))
         return true;
 
@@ -1743,7 +1743,7 @@
             // If this node is already the currently focused node, then calling focus() won't do anything.
             // That is a problem when focus is removed from the webpage to chrome, and then returns.
             // In these cases, we need to do what keyboard and mouse focus do, which is reset focus first.
-            if (document->focusedNode() == node)
+            if (document->focusedElement() == node)
                 document->setFocusedElement(0);
 
             toElement(node)->focus();
@@ -1813,7 +1813,7 @@
     if (!element)
         return;
     Document* doc = renderer()->document();
-    if (!doc->frame()->selection()->isFocusedAndActive() || doc->focusedNode() != element)
+    if (!doc->frame()->selection()->isFocusedAndActive() || doc->focusedElement() != element)
         return;
     AccessibilityRenderObject* activedescendant = static_cast<AccessibilityRenderObject*>(activeDescendant());
 
diff --git a/Source/core/animation/TimedItemCalculations.h b/Source/core/animation/TimedItemCalculations.h
index ca651f2..3603b04 100644
--- a/Source/core/animation/TimedItemCalculations.h
+++ b/Source/core/animation/TimedItemCalculations.h
@@ -150,6 +150,8 @@
     ASSERT(isNull(iterationTime) || (iterationTime >= 0 && iterationTime <= iterationDuration));
 
     double directedTime = calculateDirectedTime(currentIteration, iterationDuration, iterationTime, specified);
+    if (isNull(directedTime))
+        return nullValue();
     return specified.timingFunction ?
         iterationDuration * specified.timingFunction->evaluate(directedTime / iterationDuration, accuracyForDuration(iterationDuration)) :
         directedTime;
diff --git a/Source/core/animation/TimedItemCalculationsTest.cpp b/Source/core/animation/TimedItemCalculationsTest.cpp
index c540c23..9565b95 100644
--- a/Source/core/animation/TimedItemCalculationsTest.cpp
+++ b/Source/core/animation/TimedItemCalculationsTest.cpp
@@ -203,6 +203,8 @@
     ASSERT_EQ(5, calculateTransformedTime(0, 20, 12, timing));
     ASSERT_EQ(5, calculateTransformedTime(1, 20, 12, timing));
 
+    // Timing function when directed time is null.
+    ASSERT_TRUE(isNull(calculateTransformedTime(1, 2, nullValue(), timing)));
 }
 
 }
diff --git a/Source/core/core.gyp b/Source/core/core.gyp
index ab2ccd7..37a6211 100644
--- a/Source/core/core.gyp
+++ b/Source/core/core.gyp
@@ -315,6 +315,9 @@
         '<(SHARED_INTERMEDIATE_DIR)/webkit/SVGElementFactory.cpp',
         '<(SHARED_INTERMEDIATE_DIR)/webkit/V8SVGElementWrapperFactory.cpp',
 
+        # Generated from make_style_shorthands.py
+        '<(SHARED_INTERMEDIATE_DIR)/webkit/StylePropertyShorthand.cpp',
+
         # Generated from make_style_builder.py
         '<(SHARED_INTERMEDIATE_DIR)/webkit/StyleBuilder.cpp',
         '<(SHARED_INTERMEDIATE_DIR)/webkit/StyleBuilderFunctions.cpp',
@@ -1128,6 +1131,10 @@
         '<(SHARED_INTERMEDIATE_DIR)/webkit/bindings/V8InternalSettingsGenerated.h',
         '<(SHARED_INTERMEDIATE_DIR)/webkit/bindings/V8InternalRuntimeFlags.cpp',
         '<(SHARED_INTERMEDIATE_DIR)/webkit/bindings/V8InternalRuntimeFlags.h',
+        '<(SHARED_INTERMEDIATE_DIR)/webkit/bindings/V8LayerRect.cpp',
+        '<(SHARED_INTERMEDIATE_DIR)/webkit/bindings/V8LayerRect.h',
+        '<(SHARED_INTERMEDIATE_DIR)/webkit/bindings/V8LayerRectList.cpp',
+        '<(SHARED_INTERMEDIATE_DIR)/webkit/bindings/V8LayerRectList.h',
       ],
       'sources/': [
         ['exclude', 'testing/js'],
diff --git a/Source/core/core.gypi b/Source/core/core.gypi
index 49745e2..9df421c 100644
--- a/Source/core/core.gypi
+++ b/Source/core/core.gypi
@@ -22,6 +22,7 @@
             'css/CSSValue.idl',
             'css/CSSValueList.idl',
             'css/CSSViewportRule.idl',
+            'css/CSSVariablesMap.idl',
             'css/Counter.idl',
             'css/FontLoader.idl',
             'css/MediaList.idl',
@@ -57,7 +58,6 @@
             'dom/DOMStringMap.idl',
             'dom/DataTransferItem.idl',
             'dom/DataTransferItemList.idl',
-            'dom/DeviceOrientationEvent.idl',
             'dom/Document.idl',
             'dom/DocumentFragment.idl',
             'dom/DocumentType.idl',
@@ -291,6 +291,8 @@
             'page/SpeechInputResultList.idl',
             'page/WebKitPoint.idl',
             'page/Window.idl',
+            'page/WindowBase64.idl',
+            'page/WindowTimers.idl',
             'page/WorkerNavigator.idl',
             'plugins/MimeType.idl',
             'plugins/MimeTypeArray.idl',
@@ -321,7 +323,6 @@
             'dom/DocumentFullscreen.idl',
             'dom/ParentNode.idl',
             'page/WindowPagePopup.idl',
-            'page/WindowTimers.idl',
             'workers/AbstractWorker.idl',
         ],
         'deprecated_perl_svg_idl_files': [
@@ -642,6 +643,7 @@
             'css/CSSSelectorList.h',
             'css/CSSShaderValue.cpp',
             'css/CSSShaderValue.h',
+            'css/CSSStyleDeclaration.cpp',
             'css/CSSStyleDeclaration.h',
             'css/CSSStyleRule.cpp',
             'css/CSSStyleRule.h',
@@ -663,6 +665,8 @@
             'css/CSSValueList.cpp',
             'css/CSSValuePool.cpp',
             'css/CSSValuePool.h',
+            'css/CSSVariablesMap.cpp',
+            'css/CSSVariablesMap.h',
             'css/CSSVariableValue.h',
             'css/CSSViewportRule.h',
             'css/CSSViewportRule.cpp',
@@ -723,6 +727,7 @@
             'css/ShadowValue.cpp',
             'css/ShadowValue.h',
             'css/SiblingTraversalStrategies.h',
+            'css/StyleColor.h',
             'css/StyleInvalidationAnalysis.cpp',
             'css/StyleInvalidationAnalysis.h',
             'css/StyleMedia.cpp',
@@ -731,8 +736,7 @@
             'css/StylePropertySerializer.h',
             'css/StylePropertySet.cpp',
             'css/StylePropertySet.h',
-            'css/StylePropertyShorthand.cpp',
-            'css/StylePropertyShorthand.h',
+            'css/StylePropertyShorthandCustom.cpp',
             'css/StyleRule.cpp',
             'css/StyleRule.h',
             'css/StyleRuleImport.cpp',
@@ -1135,6 +1139,11 @@
             'page/DOMTimer.cpp',
             'page/DOMTimer.h',
             'page/DOMWindow.cpp',
+            'page/DOMWindow.h',
+            'page/DOMWindowBase64.cpp',
+            'page/DOMWindowBase64.h',
+            'page/DOMWindowTimers.cpp',
+            'page/DOMWindowTimers.h',
             'page/DOMWindowPagePopup.cpp',
             'page/DOMWindowPagePopup.h',
             'page/DOMWindowProperty.cpp',
@@ -1592,10 +1601,11 @@
             'workers/SharedWorkerThread.h',
             'workers/Worker.cpp',
             'workers/Worker.h',
-            'workers/WorkerGlobalScopeProxy.h',
-            'workers/WorkerGlobalScopeProxy.cpp',
+            'workers/WorkerClients.h',
             'workers/WorkerEventQueue.cpp',
             'workers/WorkerEventQueue.h',
+            'workers/WorkerGlobalScopeProxy.cpp',
+            'workers/WorkerGlobalScopeProxy.h',
             'workers/WorkerGlobalScope.cpp',
             'workers/WorkerGlobalScope.h',
             'workers/WorkerLoaderProxy.h',
@@ -1610,6 +1620,8 @@
             'workers/WorkerScriptLoader.h',
             'workers/WorkerScriptLoaderClient.h',
             'workers/WorkerThread.cpp',
+            'workers/WorkerThreadStartupData.cpp',
+            'workers/WorkerThreadStartupData.h',
             'xml/parser/CharacterReferenceParserInlines.h',
             'xml/parser/MarkupTokenizerInlines.h',
             'xml/parser/XMLDocumentParser.cpp',
@@ -1724,6 +1736,8 @@
             'dom/CustomElementCallbackInvocation.h',
             'dom/CustomElementCallbackQueue.cpp',
             'dom/CustomElementCallbackQueue.h',
+            'dom/CustomElementCallbackScheduler.cpp',
+            'dom/CustomElementCallbackScheduler.h',
             'dom/CustomElementDefinition.cpp',
             'dom/CustomElementDefinition.h',
             'dom/CustomElementDescriptor.h',
@@ -1757,9 +1771,6 @@
             'dom/DecodedDataDocumentParser.h',
             'dom/DeviceOrientationController.cpp',
             'dom/DeviceOrientationController.h',
-            'dom/DeviceOrientationData.cpp',
-            'dom/DeviceOrientationEvent.cpp',
-            'dom/DeviceOrientationEvent.h',
             'dom/Document.cpp',
             'dom/DocumentEventQueue.cpp',
             'dom/DocumentEventQueue.h',
@@ -3158,7 +3169,6 @@
             'platform/text/TextStream.cpp',
             'platform/text/UnicodeRange.cpp',
             'platform/text/cf/AtomicStringCF.cpp',
-            'platform/text/cf/HyphenationCF.cpp',
             'platform/text/cf/StringCF.cpp',
             'platform/text/cf/StringImplCF.cpp',
             'platform/text/mac/LocaleMac.h',
@@ -3641,6 +3651,8 @@
           'testing/Internals.idl',
           'testing/InternalProfilers.idl',
           'testing/InternalSettings.idl',
+          'testing/LayerRect.idl',
+          'testing/LayerRectList.idl',
           'testing/MallocStatistics.idl',
           'testing/TypeConversions.idl',
           '<(SHARED_INTERMEDIATE_DIR)/webkit/InternalSettingsGenerated.idl',
@@ -3659,6 +3671,9 @@
             'testing/InternalProfilers.h',
             'testing/InternalSettings.cpp',
             'testing/InternalSettings.h',
+            'testing/LayerRect.h',
+            'testing/LayerRectList.cpp',
+            'testing/LayerRectList.h',
             'testing/MallocStatistics.h',
             'testing/MockPagePopupDriver.cpp',
             'testing/MockPagePopupDriver.h',
diff --git a/Source/core/core_derived_sources.gyp b/Source/core/core_derived_sources.gyp
index 2883904..69ec6ed 100644
--- a/Source/core/core_derived_sources.gyp
+++ b/Source/core/core_derived_sources.gyp
@@ -218,6 +218,27 @@
           'msvs_cygwin_shell': 1,
         },
         {
+          'action_name': 'StylePropertyShorthand',
+          'inputs': [
+            '<@(scripts_for_in_files)',
+            'scripts/make_style_shorthands.py',
+            'css/CSSShorthands.in',
+            'scripts/templates/StylePropertyShorthand.h.tmpl',
+            'scripts/templates/StylePropertyShorthand.cpp.tmpl',
+          ],
+          'outputs': [
+            '<(SHARED_INTERMEDIATE_DIR)/webkit/StylePropertyShorthand.cpp',
+            '<(SHARED_INTERMEDIATE_DIR)/webkit/StylePropertyShorthand.h',
+          ],
+          'action': [
+            'python',
+            'scripts/make_style_shorthands.py',
+            'css/CSSShorthands.in',
+            '--output_dir',
+            '<(SHARED_INTERMEDIATE_DIR)/webkit/',
+          ],
+        },
+        {
           'action_name': 'StyleBuilder',
           'inputs': [
             '<@(scripts_for_in_files)',
diff --git a/Source/core/css/BasicShapeFunctions.cpp b/Source/core/css/BasicShapeFunctions.cpp
index 7bfd7ad..e80d033 100644
--- a/Source/core/css/BasicShapeFunctions.cpp
+++ b/Source/core/css/BasicShapeFunctions.cpp
@@ -113,7 +113,7 @@
 
 static Length convertToLength(const StyleResolverState& state, CSSPrimitiveValue* value)
 {
-    return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion | ViewportPercentageConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom());
+    return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom());
 }
 
 PassRefPtr<BasicShape> basicShapeForValue(const StyleResolverState& state, const CSSBasicShape* basicShapeValue)
diff --git a/Source/core/css/CSSCalculationValue.cpp b/Source/core/css/CSSCalculationValue.cpp
index a2aebba..adb1b5f 100644
--- a/Source/core/css/CSSCalculationValue.cpp
+++ b/Source/core/css/CSSCalculationValue.cpp
@@ -234,7 +234,7 @@
         case CalcPercentLength: {
             CSSPrimitiveValue* primitiveValue = m_value.get();
             return adoptPtr(new CalcExpressionLength(primitiveValue
-                ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, zoom)
+                ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | FractionConversion>(style, rootStyle, zoom)
                 : Length(Undefined)));
         }
         // Only types that could be part of a Length expression can be converted
diff --git a/Source/core/css/CSSComputedStyleDeclaration.cpp b/Source/core/css/CSSComputedStyleDeclaration.cpp
index 8ccea82..5cce9ab 100644
--- a/Source/core/css/CSSComputedStyleDeclaration.cpp
+++ b/Source/core/css/CSSComputedStyleDeclaration.cpp
@@ -27,6 +27,7 @@
 #include "CSSPropertyNames.h"
 #include "FontFamilyNames.h"
 #include "RuntimeEnabledFeatures.h"
+#include "StylePropertyShorthand.h"
 #include "core/css/BasicShapeFunctions.h"
 #include "core/css/CSSArrayFunctionValue.h"
 #include "core/css/CSSAspectRatioValue.h"
@@ -50,7 +51,6 @@
 #include "core/css/Rect.h"
 #include "core/css/ShadowValue.h"
 #include "core/css/StylePropertySet.h"
-#include "core/css/StylePropertyShorthand.h"
 #include "core/css/resolver/StyleResolver.h"
 #include "core/dom/Document.h"
 #include "core/dom/ExceptionCode.h"
@@ -3003,6 +3003,57 @@
     ec = NoModificationAllowedError;
 }
 
+const HashMap<AtomicString, String>* CSSComputedStyleDeclaration::variableMap() const
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    Node* styledNode = this->styledNode();
+    if (!styledNode)
+        return 0;
+    RefPtr<RenderStyle> style = styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : m_pseudoElementSpecifier);
+    if (!style)
+        return 0;
+    return style->variables();
+}
+
+unsigned CSSComputedStyleDeclaration::variableCount() const
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    const HashMap<AtomicString, String>* variables = variableMap();
+    if (!variables)
+        return 0;
+    return variables->size();
+}
+
+String CSSComputedStyleDeclaration::variableValue(const AtomicString& name) const
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    const HashMap<AtomicString, String>* variables = variableMap();
+    if (!variables)
+        return emptyString();
+    HashMap<AtomicString, String>::const_iterator it = variables->find(name);
+    if (it == variables->end())
+        return emptyString();
+    return it->value;
+}
+
+void CSSComputedStyleDeclaration::setVariableValue(const AtomicString&, const String&, ExceptionCode& ec)
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    ec = NoModificationAllowedError;
+}
+
+bool CSSComputedStyleDeclaration::removeVariable(const AtomicString&)
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    return false;
+}
+
+void CSSComputedStyleDeclaration::clearVariables(ExceptionCode& ec)
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    ec = NoModificationAllowedError;
+}
+
 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getBackgroundShorthandValue() const
 {
     static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage,
diff --git a/Source/core/css/CSSComputedStyleDeclaration.h b/Source/core/css/CSSComputedStyleDeclaration.h
index a8526cb..2eee153 100644
--- a/Source/core/css/CSSComputedStyleDeclaration.h
+++ b/Source/core/css/CSSComputedStyleDeclaration.h
@@ -23,7 +23,10 @@
 
 #include "core/css/CSSStyleDeclaration.h"
 #include "core/rendering/style/RenderStyleConstants.h"
+#include "wtf/HashMap.h"
 #include "wtf/RefPtr.h"
+#include "wtf/text/AtomicString.h"
+#include "wtf/text/AtomicStringHash.h"
 #include "wtf/text/WTFString.h"
 
 namespace WebCore {
@@ -97,6 +100,13 @@
     virtual String getPropertyValueInternal(CSSPropertyID);
     virtual void setPropertyInternal(CSSPropertyID, const String& value, bool important, ExceptionCode&);
 
+    const HashMap<AtomicString, String>* variableMap() const;
+    virtual unsigned variableCount() const OVERRIDE;
+    virtual String variableValue(const AtomicString& name) const OVERRIDE;
+    virtual void setVariableValue(const AtomicString& name, const String& value, ExceptionCode&) OVERRIDE;
+    virtual bool removeVariable(const AtomicString& name) OVERRIDE;
+    virtual void clearVariables(ExceptionCode&) OVERRIDE;
+
     virtual bool cssPropertyMatches(CSSPropertyID, const CSSValue*) const OVERRIDE;
 
     PassRefPtr<CSSValue> valueForShadow(const ShadowData*, CSSPropertyID, const RenderStyle*) const;
diff --git a/Source/core/css/CSSFontSelector.cpp b/Source/core/css/CSSFontSelector.cpp
index 443ed66..857aa47 100644
--- a/Source/core/css/CSSFontSelector.cpp
+++ b/Source/core/css/CSSFontSelector.cpp
@@ -30,6 +30,7 @@
 #include "CSSPropertyNames.h"
 #include "CSSValueKeywords.h"
 #include "FontFamilyNames.h"
+#include "RuntimeEnabledFeatures.h"
 #include "core/css/CSSFontFace.h"
 #include "core/css/CSSFontFaceRule.h"
 #include "core/css/CSSFontFaceSource.h"
@@ -596,7 +597,7 @@
         cachedResourceLoader->decrementRequestCount(fontsToBeginLoading[i].get());
     }
     // Ensure that if the request count reaches zero, the frame loader will know about it.
-    cachedResourceLoader->loadDone(0);
+    cachedResourceLoader->didLoadResource(0);
     // New font loads may be triggered by layout after the document load is complete but before we have dispatched
     // didFinishLoading for the frame. Make sure the delegate is always dispatched by checking explicitly.
     if (m_document && m_document->frame())
diff --git a/Source/core/css/CSSParser-in.cpp b/Source/core/css/CSSParser-in.cpp
index 70e52b4..ef0b3ff 100644
--- a/Source/core/css/CSSParser-in.cpp
+++ b/Source/core/css/CSSParser-in.cpp
@@ -29,6 +29,7 @@
 
 #include "CSSValueKeywords.h"
 #include "RuntimeEnabledFeatures.h"
+#include "StylePropertyShorthand.h"
 #include "core/css/CSSArrayFunctionValue.h"
 #include "core/css/CSSAspectRatioValue.h"
 #include "core/css/CSSBasicShapes.h"
@@ -67,7 +68,6 @@
 #include "core/css/Rect.h"
 #include "core/css/ShadowValue.h"
 #include "core/css/StylePropertySet.h"
-#include "core/css/StylePropertyShorthand.h"
 #include "core/css/StyleRule.h"
 #include "core/css/StyleRuleImport.h"
 #include "core/css/StyleSheetContents.h"
@@ -601,8 +601,8 @@
         // inline | block | list-item | run-in | inline-block | table |
         // inline-table | table-row-group | table-header-group | table-footer-group | table-row |
         // table-column-group | table-column | table-cell | table-caption | -webkit-box | -webkit-inline-box | none | inherit
-        // -webkit-flex | -webkit-inline-flex | -webkit-grid | -webkit-inline-grid | lazy-block
-        if ((valueID >= CSSValueInline && valueID <= CSSValueWebkitInlineFlex) || valueID == CSSValueNone)
+        // flex | inline-flex | -webkit-flex | -webkit-inline-flex | grid | inline-grid | lazy-block
+        if ((valueID >= CSSValueInline && valueID <= CSSValueInlineFlex) || valueID == CSSValueWebkitFlex || valueID == CSSValueWebkitInlineFlex || valueID == CSSValueNone)
             return true;
         if (valueID == CSSValueGrid || valueID == CSSValueInlineGrid)
             return RuntimeEnabledFeatures::cssGridLayoutEnabled();
@@ -1356,7 +1356,7 @@
         if (property.isImportant() != important)
             continue;
         if (property.id() == CSSPropertyVariable) {
-            const AtomicString& name = static_cast<CSSVariableValue*>(property.value())->name();
+            const AtomicString& name = toCSSVariableValue(property.value())->name();
             if (!seenVariables.add(name).isNewEntry)
                 continue;
             output[--unusedEntries] = property;
@@ -2601,7 +2601,7 @@
     case CSSPropertyBorder:
         // [ 'border-width' || 'border-style' || <color> ] | inherit
     {
-        if (parseShorthand(propId, borderAbridgedShorthand(), important)) {
+        if (parseShorthand(propId, borderShorthandForParsing(), important)) {
             // The CSS3 Borders and Backgrounds specification says that border also resets border-image. It's as
             // though a value of none was specified for the image.
             addExpandedPropertyForValue(CSSPropertyBorderImage, cssValuePool().createImplicitInitialValue(), important);
@@ -9121,7 +9121,7 @@
     CharacterOther,
     CharacterNull,
     CharacterWhiteSpace,
-    CharacterEndMediaQuery,
+    CharacterEndMediaQueryOrSupports,
     CharacterEndNthChild,
     CharacterQuote,
     CharacterExclamationMark,
@@ -9200,7 +9200,7 @@
 /*  56 - 8                  */ CharacterNumber,
 /*  57 - 9                  */ CharacterNumber,
 /*  58 - :                  */ CharacterOther,
-/*  59 - ;                  */ CharacterEndMediaQuery,
+/*  59 - ;                  */ CharacterEndMediaQueryOrSupports,
 /*  60 - <                  */ CharacterLess,
 /*  61 - =                  */ CharacterOther,
 /*  62 - >                  */ CharacterOther,
@@ -9264,7 +9264,7 @@
 /* 120 - x                  */ CharacterIdentifierStart,
 /* 121 - y                  */ CharacterIdentifierStart,
 /* 122 - z                  */ CharacterIdentifierStart,
-/* 123 - {                  */ CharacterEndMediaQuery,
+/* 123 - {                  */ CharacterEndMediaQueryOrSupports,
 /* 124 - |                  */ CharacterVerticalBar,
 /* 125 - }                  */ CharacterOther,
 /* 126 - ~                  */ CharacterTilde,
@@ -9973,9 +9973,6 @@
         CASE("webkit-max") {
             m_token = MAXFUNCTION;
         }
-        CASE("webkit-var") {
-            m_token = VARFUNCTION;
-        }
         CASE("webkit-calc") {
             m_token = CALCFUNCTION;
         }
@@ -10475,8 +10472,8 @@
         } while (*currentCharacter<SrcCharacterType>() <= ' ' && (typesOfASCIICharacters[*currentCharacter<SrcCharacterType>()] == CharacterWhiteSpace));
         break;
 
-    case CharacterEndMediaQuery:
-        if (m_parsingMode == MediaQueryMode)
+    case CharacterEndMediaQueryOrSupports:
+        if (m_parsingMode == MediaQueryMode || m_parsingMode == SupportsMode)
             m_parsingMode = NormalMode;
         break;
 
@@ -11435,11 +11432,11 @@
     bool validPrimitive = false;
 
     switch (propId) {
-    case CSSPropertyMinWidth: // auto | <length> | <percentage>
+    case CSSPropertyMinWidth: // auto | extend-to-zoom | <length> | <percentage>
     case CSSPropertyMaxWidth:
     case CSSPropertyMinHeight:
     case CSSPropertyMaxHeight:
-        if (id == CSSValueAuto)
+        if (id == CSSValueAuto || id == CSSValueInternalExtendToZoom)
             validPrimitive = true;
         else
             validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonNeg));
diff --git a/Source/core/css/CSSPrimitiveValue.cpp b/Source/core/css/CSSPrimitiveValue.cpp
index 1577839..4fa70c7 100644
--- a/Source/core/css/CSSPrimitiveValue.cpp
+++ b/Source/core/css/CSSPrimitiveValue.cpp
@@ -310,6 +310,10 @@
             m_primitiveUnitType = CSS_VALUE_ID;
             m_value.valueID = CSSValueWebkitFitContent;
             break;
+        case ExtendToZoom:
+            m_primitiveUnitType = CSS_VALUE_ID;
+            m_value.valueID = CSSValueInternalExtendToZoom;
+            break;
         case Percent:
             m_primitiveUnitType = CSS_PERCENTAGE;
             ASSERT(std::isfinite(length.percent()));
diff --git a/Source/core/css/CSSPrimitiveValueMappings.h b/Source/core/css/CSSPrimitiveValueMappings.h
index a9fb25e..49081b0 100644
--- a/Source/core/css/CSSPrimitiveValueMappings.h
+++ b/Source/core/css/CSSPrimitiveValueMappings.h
@@ -4267,8 +4267,6 @@
     AutoConversion = 1 << 2,
     PercentConversion = 1 << 3,
     FractionConversion = 1 << 4,
-    CalculatedConversion = 1 << 5,
-    ViewportPercentageConversion = 1 << 6
 };
 
 template<int supported> Length CSSPrimitiveValue::convertToLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
@@ -4286,9 +4284,9 @@
         return Length(getDoubleValue() * 100.0, Percent);
     if ((supported & AutoConversion) && getValueID() == CSSValueAuto)
         return Length(Auto);
-    if ((supported & CalculatedConversion) && isCalculated())
+    if ((supported & (FixedIntegerConversion | FixedFloatConversion)) && (supported & PercentConversion) && isCalculated())
         return Length(cssCalcValue()->toCalcValue(style, rootStyle, multiplier));
-    if ((supported & ViewportPercentageConversion) && isViewportPercentageLength())
+    if ((supported & (FixedIntegerConversion | FixedFloatConversion)) && isViewportPercentageLength())
         return viewportPercentageLength();
     return Length(Undefined);
 }
diff --git a/Source/core/css/CSSProperty.cpp b/Source/core/css/CSSProperty.cpp
index 65ed6d3..1c15c2e 100644
--- a/Source/core/css/CSSProperty.cpp
+++ b/Source/core/css/CSSProperty.cpp
@@ -21,8 +21,8 @@
 #include "config.h"
 #include "core/css/CSSProperty.h"
 
+#include "StylePropertyShorthand.h"
 #include "core/css/CSSValueList.h"
-#include "core/css/StylePropertyShorthand.h"
 #include "core/rendering/style/RenderStyleConstants.h"
 
 namespace WebCore {
diff --git a/Source/core/css/CSSShorthands.in b/Source/core/css/CSSShorthands.in
new file mode 100644
index 0000000..96caec3
--- /dev/null
+++ b/Source/core/css/CSSShorthands.in
@@ -0,0 +1,51 @@
+// This file contains all the mapping shorthands <-> longhands and generate
+// the appropriate code to handle them in core. First column is the shorthand name
+// followed by the longhands associated to the shorthand.
+// Note: Mandatory blank line to skip parameter parsing phase
+
+background longhands=background-image;background-position-x;background-position-y;background-size;background-repeat-x;background-repeat-y;background-attachment;background-origin;background-clip;background-color
+background-position longhands=background-position-x;background-position-y
+background-repeat longhands=background-repeat-x;background-repeat-y
+border longhands=border-top-color;border-top-style;border-top-width;border-right-color;border-right-style;border-right-width;border-bottom-color;border-bottom-style;border-bottom-width;border-left-color;border-left-style;border-left-width
+border-bottom longhands=border-bottom-width;border-bottom-style;border-bottom-color
+border-color longhands=border-top-color;border-right-color;border-bottom-color;border-left-color
+border-image longhands=border-image-source;border-image-slice;border-image-width;border-image-outset;border-image-repeat
+border-left longhands=border-left-width;border-left-style;border-left-color
+border-radius longhands=border-top-left-radius;border-top-right-radius;border-bottom-right-radius;border-bottom-left-radius
+border-right longhands=border-right-width;border-right-style;border-right-color
+border-spacing longhands=-webkit-border-horizontal-spacing;-webkit-border-vertical-spacing
+border-style longhands=border-top-style;border-right-style;border-bottom-style;border-left-style
+border-top longhands=border-top-width;border-top-style;border-top-color
+border-width longhands=border-top-width;border-right-width;border-bottom-width;border-left-width
+flex longhands=flex-grow;flex-shrink;flex-basis
+flex-flow longhands=flex-direction;flex-wrap
+font longhands=font-family;font-size;font-style;font-variant;font-weight;line-height
+grid-area longhands=grid-column-start;grid-row-start;grid-column-end;grid-row-end
+grid-column longhands=grid-column-start;grid-column-end
+grid-row longhands=grid-row-start;grid-row-end
+height longhands=min-height;max-height
+list-style longhands=list-style-type;list-style-position;list-style-image
+margin longhands=margin-top;margin-right;margin-bottom;margin-left
+marker longhands=marker-start;marker-mid;marker-end
+outline longhands=outline-color;outline-style;outline-width
+overflow longhands=overflow-x;overflow-y
+padding longhands=padding-top;padding-right;padding-bottom;padding-left
+transition longhands=transition-property;transition-duration;transition-timing-function;transition-delay
+-webkit-animation longhands=-webkit-animation-name;-webkit-animation-duration;-webkit-animation-timing-function;-webkit-animation-delay;-webkit-animation-iteration-count;-webkit-animation-direction;-webkit-animation-fill-mode
+-webkit-border-after longhands=-webkit-border-after-width;-webkit-border-after-style;-webkit-border-after-color
+-webkit-border-before longhands=-webkit-border-before-width;-webkit-border-before-style;-webkit-border-before-color
+-webkit-border-end longhands=-webkit-border-end-width;-webkit-border-end-style;-webkit-border-end-color
+-webkit-border-start longhands=-webkit-border-start-width;-webkit-border-start-style;-webkit-border-start-color
+-webkit-border-radius longhands=border-top-left-radius;border-top-right-radius;border-bottom-right-radius;border-bottom-left-radius
+-webkit-columns longhands=-webkit-column-width;-webkit-column-count
+-webkit-column-rule longhands=-webkit-column-rule-width;-webkit-column-rule-style;-webkit-column-rule-color
+-webkit-margin-collapse longhands=-webkit-margin-before-collapse;-webkit-margin-after-collapse
+-webkit-marquee longhands=-webkit-marquee-direction;-webkit-marquee-increment;-webkit-marquee-repetition;-webkit-marquee-style;-webkit-marquee-speed
+-webkit-mask longhands=-webkit-mask-image;-webkit-mask-position-x;-webkit-mask-position-y;-webkit-mask-size;-webkit-mask-repeat-x;-webkit-mask-repeat-y;-webkit-mask-origin;-webkit-mask-clip
+-webkit-mask-position longhands=-webkit-mask-position-x;-webkit-mask-position-y
+-webkit-mask-repeat longhands=-webkit-mask-repeat-x;-webkit-mask-repeat-y
+-webkit-text-emphasis longhands=-webkit-text-emphasis-style;-webkit-text-emphasis-color
+-webkit-text-stroke longhands=-webkit-text-stroke-width;-webkit-text-stroke-color
+-webkit-transition longhands=-webkit-transition-property;-webkit-transition-duration;-webkit-transition-timing-function;-webkit-transition-delay
+-webkit-transform-origin longhands=-webkit-transform-origin-x;-webkit-transform-origin-y;-webkit-transform-origin-z
+width longhands=min-width;max-width
diff --git a/Source/core/css/CSSStyleDeclaration.cpp b/Source/core/css/CSSStyleDeclaration.cpp
new file mode 100644
index 0000000..1999c32
--- /dev/null
+++ b/Source/core/css/CSSStyleDeclaration.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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 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/css/CSSStyleDeclaration.h"
+
+#include "core/css/CSSVariablesMap.h"
+
+namespace WebCore {
+
+PassRefPtr<CSSVariablesMap> CSSStyleDeclaration::var()
+{
+    if (!m_variablesMap)
+        m_variablesMap = CSSVariablesMap::create(this);
+    return m_variablesMap;
+}
+
+CSSStyleDeclaration::~CSSStyleDeclaration()
+{
+    if (m_variablesMap)
+        m_variablesMap->clearStyleDeclaration();
+}
+
+} // namespace WebCore
diff --git a/Source/core/css/CSSStyleDeclaration.h b/Source/core/css/CSSStyleDeclaration.h
index d29c902..0459adc 100644
--- a/Source/core/css/CSSStyleDeclaration.h
+++ b/Source/core/css/CSSStyleDeclaration.h
@@ -23,6 +23,7 @@
 
 #include "CSSPropertyNames.h"
 #include "bindings/v8/ScriptWrappable.h"
+#include "core/css/CSSVariablesMap.h"
 #include "wtf/Forward.h"
 #include "wtf/Noncopyable.h"
 
@@ -33,14 +34,14 @@
 class CSSStyleSheet;
 class CSSValue;
 class MutableStylePropertySet;
-class StylePropertySet;
+class VariablesIterator;
 
 typedef int ExceptionCode;
 
 class CSSStyleDeclaration : public ScriptWrappable {
     WTF_MAKE_NONCOPYABLE(CSSStyleDeclaration); WTF_MAKE_FAST_ALLOCATED;
 public:
-    virtual ~CSSStyleDeclaration() { }
+    virtual ~CSSStyleDeclaration();
 
     virtual void ref() = 0;
     virtual void deref() = 0;
@@ -58,6 +59,13 @@
     virtual void setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode&) = 0;
     virtual String removeProperty(const String& propertyName, ExceptionCode&) = 0;
 
+    PassRefPtr<CSSVariablesMap> var();
+    virtual unsigned variableCount() const = 0;
+    virtual String variableValue(const AtomicString& name) const = 0;
+    virtual void setVariableValue(const AtomicString& name, const String& value, ExceptionCode&) = 0;
+    virtual bool removeVariable(const AtomicString& name) = 0;
+    virtual void clearVariables(ExceptionCode&) = 0;
+
     // CSSPropertyID versions of the CSSOM functions to support bindings and editing.
     // Use the non-virtual methods in the concrete subclasses when possible.
     // The CSSValue returned by this function should not be exposed to the web as it may be used by multiple documents at the same time.
@@ -75,6 +83,7 @@
     {
         ScriptWrappable::init(this);
     }
+    RefPtr<CSSVariablesMap> m_variablesMap;
 };
 
 } // namespace WebCore
diff --git a/Source/core/css/CSSStyleDeclaration.idl b/Source/core/css/CSSStyleDeclaration.idl
index c94f081..a10b29f 100644
--- a/Source/core/css/CSSStyleDeclaration.idl
+++ b/Source/core/css/CSSStyleDeclaration.idl
@@ -37,5 +37,6 @@
     [Custom, CustomEnumerateProperty] getter (DOMString or float) (DOMString name);
     [Custom] setter void (DOMString propertyName, [TreatNullAs=NullString] DOMString propertyValue);
     readonly attribute CSSRule          parentRule;
+    [EnabledAtRuntime=CSSVariables] readonly attribute CSSVariablesMap var;
 };
 
diff --git a/Source/core/css/CSSValue.cpp b/Source/core/css/CSSValue.cpp
index c9435ab..bce2645 100644
--- a/Source/core/css/CSSValue.cpp
+++ b/Source/core/css/CSSValue.cpp
@@ -300,7 +300,7 @@
     case CSSShaderClass:
         return static_cast<const CSSShaderValue*>(this)->customCssText();
     case VariableClass:
-        return static_cast<const CSSVariableValue*>(this)->value();
+        return toCSSVariableValue(this)->value();
     case SVGColorClass:
         return static_cast<const SVGColor*>(this)->customCssText();
     case SVGPaintClass:
@@ -429,7 +429,7 @@
         delete static_cast<CSSShaderValue*>(this);
         return;
     case VariableClass:
-        delete static_cast<CSSVariableValue*>(this);
+        delete toCSSVariableValue(this);
         return;
     case SVGColorClass:
         delete static_cast<SVGColor*>(this);
diff --git a/Source/core/css/CSSValueKeywords.in b/Source/core/css/CSSValueKeywords.in
index 445b11d..82e507f 100644
--- a/Source/core/css/CSSValueKeywords.in
+++ b/Source/core/css/CSSValueKeywords.in
@@ -983,3 +983,8 @@
 // (scan:) media feature
 progressive
 interlace
+
+//
+// CSS3 viewport-length keywords
+//
+-internal-extend-to-zoom
diff --git a/Source/core/css/CSSVariableValue.h b/Source/core/css/CSSVariableValue.h
index 8070222..5e691e1 100644
--- a/Source/core/css/CSSVariableValue.h
+++ b/Source/core/css/CSSVariableValue.h
@@ -59,6 +59,18 @@
     const String m_value;
 };
 
+inline CSSVariableValue* toCSSVariableValue(CSSValue* value)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isVariableValue());
+    return static_cast<CSSVariableValue*>(value);
+}
+
+inline const CSSVariableValue* toCSSVariableValue(const CSSValue* value)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isVariableValue());
+    return static_cast<const CSSVariableValue*>(value);
+}
+
 }
 
 #endif /* CSSVariableValue_h */
diff --git a/Source/core/css/CSSVariablesMap.cpp b/Source/core/css/CSSVariablesMap.cpp
new file mode 100644
index 0000000..a104e43
--- /dev/null
+++ b/Source/core/css/CSSVariablesMap.cpp
@@ -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 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/css/CSSVariablesMap.h"
+
+#include "core/css/CSSStyleDeclaration.h"
+
+namespace WebCore {
+
+unsigned CSSVariablesMap::size() const
+{
+    if (m_styleDeclaration)
+        return m_styleDeclaration->variableCount();
+    return 0;
+}
+
+String CSSVariablesMap::get(const AtomicString& name) const
+{
+    if (m_styleDeclaration)
+        return m_styleDeclaration->variableValue(name);
+    return String();
+}
+
+bool CSSVariablesMap::has(const AtomicString& name) const
+{
+    if (m_styleDeclaration)
+        return !get(name).isEmpty();
+    return false;
+}
+
+void CSSVariablesMap::set(const AtomicString& name, const String& value, ExceptionCode& ec) const
+{
+    if (m_styleDeclaration)
+        m_styleDeclaration->setVariableValue(name, value, ec);
+}
+
+bool CSSVariablesMap::remove(const AtomicString& name) const
+{
+    if (m_styleDeclaration)
+        return m_styleDeclaration->removeVariable(name);
+    return false;
+}
+
+void CSSVariablesMap::clear(ExceptionCode& ec) const
+{
+    if (m_styleDeclaration)
+        return m_styleDeclaration->clearVariables(ec);
+}
+
+} // namespace WebCore
diff --git a/Source/core/css/CSSVariablesMap.h b/Source/core/css/CSSVariablesMap.h
new file mode 100644
index 0000000..bd7878a
--- /dev/null
+++ b/Source/core/css/CSSVariablesMap.h
@@ -0,0 +1,71 @@
+/*
+ * 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:
+ *
+ *     * 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.
+ *
+ * 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 CSSVariablesMap_h
+#define CSSVariablesMap_h
+
+#include "RuntimeEnabledFeatures.h"
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
+
+namespace WebCore {
+
+class CSSStyleDeclaration;
+
+typedef int ExceptionCode;
+
+class CSSVariablesMap : public RefCounted<CSSVariablesMap> {
+public:
+    virtual ~CSSVariablesMap() { }
+
+    static PassRefPtr<CSSVariablesMap> create(CSSStyleDeclaration* styleDeclaration)
+    {
+        return adoptRef(new CSSVariablesMap(styleDeclaration));
+    }
+
+    unsigned size() const;
+    String get(const AtomicString& name) const;
+    bool has(const AtomicString& name) const;
+    void set(const AtomicString& name, const String& value, ExceptionCode&) const;
+    bool remove(const AtomicString& name) const;
+    void clear(ExceptionCode&) const;
+
+    void clearStyleDeclaration() { m_styleDeclaration = 0; }
+
+private:
+    explicit CSSVariablesMap(CSSStyleDeclaration* styleDeclaration)
+        : m_styleDeclaration(styleDeclaration)
+    {
+        ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    }
+
+    CSSStyleDeclaration* m_styleDeclaration;
+};
+
+} // namespace WebCore
+
+#endif // CSSVariablesMap_h
diff --git a/Source/core/css/CSSVariablesMap.idl b/Source/core/css/CSSVariablesMap.idl
new file mode 100644
index 0000000..b6ab78a
--- /dev/null
+++ b/Source/core/css/CSSVariablesMap.idl
@@ -0,0 +1,35 @@
+/*
+ * 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:
+ *
+ *     * 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.
+ *
+ * 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.
+ */
+
+interface CSSVariablesMap {
+    readonly attribute unsigned long size;
+    DOMString get(DOMString name);
+    boolean has(DOMString name);
+    [RaisesException] void set(DOMString name, DOMString value);
+    [ImplementedAs=remove] boolean delete(DOMString name);
+    [RaisesException] void clear();
+};
diff --git a/Source/core/css/FontLoader.cpp b/Source/core/css/FontLoader.cpp
index 585da7c..88d7074 100644
--- a/Source/core/css/FontLoader.cpp
+++ b/Source/core/css/FontLoader.cpp
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "core/css/FontLoader.h"
 
+#include "RuntimeEnabledFeatures.h"
 #include "bindings/v8/Dictionary.h"
 #include "core/css/CSSFontFaceLoadEvent.h"
 #include "core/css/CSSFontFaceSource.h"
diff --git a/Source/core/css/LengthFunctions.cpp b/Source/core/css/LengthFunctions.cpp
index 2f76efd..28c98de 100644
--- a/Source/core/css/LengthFunctions.cpp
+++ b/Source/core/css/LengthFunctions.cpp
@@ -81,6 +81,7 @@
     case MinContent:
     case MaxContent:
     case FitContent:
+    case ExtendToZoom:
     case Undefined:
         ASSERT_NOT_REACHED();
         return 0;
@@ -109,6 +110,7 @@
     case MinContent:
     case MaxContent:
     case FitContent:
+    case ExtendToZoom:
     case Undefined:
         ASSERT_NOT_REACHED();
         return 0;
@@ -155,6 +157,7 @@
     case MinContent:
     case MaxContent:
     case FitContent:
+    case ExtendToZoom:
     case Undefined:
         ASSERT_NOT_REACHED();
         return 0;
diff --git a/Source/core/css/MediaQueryEvaluator.cpp b/Source/core/css/MediaQueryEvaluator.cpp
index 68d654c..bba87c5 100644
--- a/Source/core/css/MediaQueryEvaluator.cpp
+++ b/Source/core/css/MediaQueryEvaluator.cpp
@@ -138,6 +138,9 @@
             size_t j = 0;
             for (; j < exps->size(); ++j) {
                 bool exprResult = eval(exps->at(j).get());
+                // FIXME: Instead of storing these on StyleResolver, we should store them locally
+                // and then any client of this method can grab at them afterwords.
+                // Alternatively we could use an explicit out-paramemter of this method.
                 if (styleResolver && exps->at(j)->isViewportDependent())
                     styleResolver->addViewportDependentMediaQueryResult(exps->at(j).get(), exprResult);
                 if (!exprResult)
diff --git a/Source/core/css/PropertySetCSSStyleDeclaration.cpp b/Source/core/css/PropertySetCSSStyleDeclaration.cpp
index a78d436..74a46aa 100644
--- a/Source/core/css/PropertySetCSSStyleDeclaration.cpp
+++ b/Source/core/css/PropertySetCSSStyleDeclaration.cpp
@@ -23,6 +23,7 @@
 #include "core/css/PropertySetCSSStyleDeclaration.h"
 
 #include "HTMLNames.h"
+#include "RuntimeEnabledFeatures.h"
 #include "core/css/CSSParser.h"
 #include "core/css/CSSStyleSheet.h"
 #include "core/css/StylePropertySet.h"
@@ -271,6 +272,52 @@
         mutationScope.enqueueMutationRecord();
 }
 
+unsigned PropertySetCSSStyleDeclaration::variableCount() const
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    return m_propertySet->variableCount();
+}
+
+String PropertySetCSSStyleDeclaration::variableValue(const AtomicString& name) const
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    return m_propertySet->variableValue(name);
+}
+
+void PropertySetCSSStyleDeclaration::setVariableValue(const AtomicString& name, const String& value, ExceptionCode&)
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    StyleAttributeMutationScope mutationScope(this);
+    willMutate();
+    bool changed = m_propertySet->setVariableValue(name, value);
+    didMutate(changed ? PropertyChanged : NoChanges);
+    if (changed)
+        mutationScope.enqueueMutationRecord();
+}
+
+bool PropertySetCSSStyleDeclaration::removeVariable(const AtomicString& name)
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    StyleAttributeMutationScope mutationScope(this);
+    willMutate();
+    bool changed = m_propertySet->removeVariable(name);
+    didMutate(changed ? PropertyChanged : NoChanges);
+    if (changed)
+        mutationScope.enqueueMutationRecord();
+    return changed;
+}
+
+void PropertySetCSSStyleDeclaration::clearVariables(ExceptionCode&)
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    StyleAttributeMutationScope mutationScope(this);
+    willMutate();
+    bool changed = m_propertySet->clearVariables();
+    didMutate(changed ? PropertyChanged : NoChanges);
+    if (changed)
+        mutationScope.enqueueMutationRecord();
+}
+
 CSSValue* PropertySetCSSStyleDeclaration::cloneAndCacheForCSSOM(CSSValue* internalValue)
 {
     if (!internalValue)
diff --git a/Source/core/css/PropertySetCSSStyleDeclaration.h b/Source/core/css/PropertySetCSSStyleDeclaration.h
index 1341c13..3584978 100644
--- a/Source/core/css/PropertySetCSSStyleDeclaration.h
+++ b/Source/core/css/PropertySetCSSStyleDeclaration.h
@@ -66,7 +66,13 @@
     virtual PassRefPtr<CSSValue> getPropertyCSSValueInternal(CSSPropertyID) OVERRIDE;
     virtual String getPropertyValueInternal(CSSPropertyID) OVERRIDE;
     virtual void setPropertyInternal(CSSPropertyID, const String& value, bool important, ExceptionCode&) OVERRIDE;
-    
+
+    virtual unsigned variableCount() const OVERRIDE;
+    virtual String variableValue(const AtomicString& name) const OVERRIDE;
+    virtual void setVariableValue(const AtomicString& name, const String& value, ExceptionCode&) OVERRIDE;
+    virtual bool removeVariable(const AtomicString& name) OVERRIDE;
+    virtual void clearVariables(ExceptionCode&) OVERRIDE;
+
     virtual bool cssPropertyMatches(CSSPropertyID, const CSSValue*) const OVERRIDE;
     virtual PassRefPtr<MutableStylePropertySet> copyProperties() const OVERRIDE;
 
diff --git a/Source/core/css/RuleFeature.cpp b/Source/core/css/RuleFeature.cpp
index c47e143..6e30432 100644
--- a/Source/core/css/RuleFeature.cpp
+++ b/Source/core/css/RuleFeature.cpp
@@ -43,11 +43,11 @@
         attrsInRules.add(selector->attribute().localName().impl());
     switch (selector->pseudoType()) {
     case CSSSelector::PseudoFirstLine:
-        usesFirstLineRules = true;
+        m_usesFirstLineRules = true;
         break;
     case CSSSelector::PseudoBefore:
     case CSSSelector::PseudoAfter:
-        usesBeforeAfterRules = true;
+        m_usesBeforeAfterRules = true;
         break;
     default:
         break;
@@ -67,8 +67,8 @@
         attrsInRules.add(*it);
     siblingRules.append(other.siblingRules);
     uncommonAttributeRules.append(other.uncommonAttributeRules);
-    usesFirstLineRules = usesFirstLineRules || other.usesFirstLineRules;
-    usesBeforeAfterRules = usesBeforeAfterRules || other.usesBeforeAfterRules;
+    m_usesFirstLineRules = m_usesFirstLineRules || other.m_usesFirstLineRules;
+    m_usesBeforeAfterRules = m_usesBeforeAfterRules || other.m_usesBeforeAfterRules;
 }
 
 void RuleFeatureSet::clear()
@@ -78,8 +78,8 @@
     attrsInRules.clear();
     siblingRules.clear();
     uncommonAttributeRules.clear();
-    usesFirstLineRules = false;
-    usesBeforeAfterRules = false;
+    m_usesFirstLineRules = false;
+    m_usesBeforeAfterRules = false;
 }
 
 } // namespace WebCore
diff --git a/Source/core/css/RuleFeature.h b/Source/core/css/RuleFeature.h
index 57fe288..6e18fbb 100644
--- a/Source/core/css/RuleFeature.h
+++ b/Source/core/css/RuleFeature.h
@@ -35,18 +35,19 @@
     RuleFeature(StyleRule* rule, unsigned selectorIndex, bool hasDocumentSecurityOrigin)
         : rule(rule)
         , selectorIndex(selectorIndex)
-        , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) 
-    { 
+        , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin)
+    {
     }
     StyleRule* rule;
     unsigned selectorIndex;
     bool hasDocumentSecurityOrigin;
 };
 
-struct RuleFeatureSet {
+class RuleFeatureSet {
+public:
     RuleFeatureSet()
-        : usesFirstLineRules(false)
-        , usesBeforeAfterRules(false)
+        : m_usesFirstLineRules(false)
+        , m_usesBeforeAfterRules(false)
     { }
 
     void add(const RuleFeatureSet&);
@@ -54,13 +55,36 @@
 
     void collectFeaturesFromSelector(const CSSSelector*);
 
+    bool usesSiblingRules() const { return !siblingRules.isEmpty(); }
+    bool usesFirstLineRules() const { return m_usesFirstLineRules; }
+    bool usesBeforeAfterRules() const { return m_usesBeforeAfterRules; }
+
+    inline bool hasSelectorForAttribute(const AtomicString &attributeName) const
+    {
+        ASSERT(!attributeName.isEmpty());
+        return attrsInRules.contains(attributeName.impl());
+    }
+
+    inline bool hasSelectorForClass(const AtomicString& classValue) const
+    {
+        ASSERT(!classValue.isEmpty());
+        return classesInRules.contains(classValue.impl());
+    }
+
+    inline bool hasSelectorForId(const AtomicString& idValue) const
+    {
+        ASSERT(!idValue.isEmpty());
+        return idsInRules.contains(idValue.impl());
+    }
+
     HashSet<AtomicStringImpl*> idsInRules;
     HashSet<AtomicStringImpl*> classesInRules;
     HashSet<AtomicStringImpl*> attrsInRules;
     Vector<RuleFeature> siblingRules;
     Vector<RuleFeature> uncommonAttributeRules;
-    bool usesFirstLineRules;
-    bool usesBeforeAfterRules;
+private:
+    bool m_usesFirstLineRules;
+    bool m_usesBeforeAfterRules;
 };
 
 } // namespace WebCore
diff --git a/Source/core/css/SiblingTraversalStrategies.h b/Source/core/css/SiblingTraversalStrategies.h
index 55b78d0..c557cf6 100644
--- a/Source/core/css/SiblingTraversalStrategies.h
+++ b/Source/core/css/SiblingTraversalStrategies.h
@@ -146,12 +146,11 @@
 inline bool ShadowDOMSiblingTraversalStrategy::isFirstChild(Element* element) const
 {
     UNUSED_PARAM(element);
-    
-    const Vector<RefPtr<Node> >& siblings = m_siblings;
-    ASSERT(element == toElement(siblings[m_nth].get()));
+
+    ASSERT(element == toElement(m_siblings[m_nth].get()));
 
     for (int i = m_nth - 1; i >= 0; --i) {
-        if (siblings[i] && siblings[i]->isElementNode())
+        if (m_siblings[i]->isElementNode())
             return false;
     }
 
@@ -162,11 +161,10 @@
 {
     UNUSED_PARAM(element);
 
-    const Vector<RefPtr<Node> >& siblings = m_siblings;
-    ASSERT(element == toElement(siblings[m_nth].get()));
+    ASSERT(element == toElement(m_siblings[m_nth].get()));
 
-    for (size_t i = m_nth + 1; i < siblings.size(); ++i) {
-        if (siblings[i] && siblings[i]->isElementNode())
+    for (size_t i = m_nth + 1; i < m_siblings.size(); ++i) {
+        if (m_siblings[i]->isElementNode())
             return false;
     }
 
@@ -177,11 +175,10 @@
 {
     UNUSED_PARAM(element);
 
-    const Vector<RefPtr<Node> >& siblings = m_siblings;
-    ASSERT(element == toElement(siblings[m_nth].get()));
+    ASSERT(element == toElement(m_siblings[m_nth].get()));
 
     for (int i = m_nth - 1; i >= 0; --i) {
-        if (siblings[i] && siblings[i]->isElementNode() && siblings[i]->hasTagName(type))
+        if (m_siblings[i]->hasTagName(type))
             return false;
     }
 
@@ -192,11 +189,10 @@
 {
     UNUSED_PARAM(element);
 
-    const Vector<RefPtr<Node> >& siblings = m_siblings;
-    ASSERT(element == toElement(siblings[m_nth].get()));
+    ASSERT(element == toElement(m_siblings[m_nth].get()));
 
-    for (size_t i = m_nth + 1; i < siblings.size(); ++i) {
-        if (siblings[i] && siblings[i]->isElementNode() && siblings[i]->hasTagName(type))
+    for (size_t i = m_nth + 1; i < m_siblings.size(); ++i) {
+        if (m_siblings[i]->hasTagName(type))
             return false;
     }
 
@@ -207,12 +203,11 @@
 {
     UNUSED_PARAM(element);
 
-    const Vector<RefPtr<Node> >& siblings = m_siblings;
-    ASSERT(element == toElement(siblings[m_nth].get()));
+    ASSERT(element == toElement(m_siblings[m_nth].get()));
 
     int count = 0;
     for (int i = m_nth - 1; i >= 0; --i) {
-        if (siblings[i] && siblings[i]->isElementNode())
+        if (m_siblings[i]->isElementNode())
             ++count;
     }
 
@@ -223,12 +218,11 @@
 {
     UNUSED_PARAM(element);
 
-    const Vector<RefPtr<Node> >& siblings = m_siblings;
-    ASSERT(element == toElement(siblings[m_nth].get()));
+    ASSERT(element == toElement(m_siblings[m_nth].get()));
 
     int count = 0;
-    for (size_t i = m_nth + 1; i < siblings.size(); ++i) {
-        if (siblings[i] && siblings[i]->isElementNode())
+    for (size_t i = m_nth + 1; i < m_siblings.size(); ++i) {
+        if (m_siblings[i]->isElementNode())
             return ++count;
     }
 
@@ -239,12 +233,11 @@
 {
     UNUSED_PARAM(element);
 
-    const Vector<RefPtr<Node> >& siblings = m_siblings;
-    ASSERT(element == toElement(siblings[m_nth].get()));
+    ASSERT(element == toElement(m_siblings[m_nth].get()));
 
     int count = 0;
     for (int i = m_nth - 1; i >= 0; --i) {
-        if (siblings[i] && siblings[i]->isElementNode() && siblings[i]->hasTagName(type))
+        if (m_siblings[i]->hasTagName(type))
             ++count;
     }
 
@@ -255,12 +248,11 @@
 {
     UNUSED_PARAM(element);
 
-    const Vector<RefPtr<Node> >& siblings = m_siblings;
-    ASSERT(element == toElement(siblings[m_nth].get()));
+    ASSERT(element == toElement(m_siblings[m_nth].get()));
 
     int count = 0;
-    for (size_t i = m_nth + 1; i < siblings.size(); ++i) {
-        if (siblings[i] && siblings[i]->isElementNode() && siblings[i]->hasTagName(type))
+    for (size_t i = m_nth + 1; i < m_siblings.size(); ++i) {
+        if (m_siblings[i]->hasTagName(type))
             return ++count;
     }
 
diff --git a/Source/core/css/StyleColor.h b/Source/core/css/StyleColor.h
new file mode 100644
index 0000000..eb893e4
--- /dev/null
+++ b/Source/core/css/StyleColor.h
@@ -0,0 +1,118 @@
+/*
+ * 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:
+ *
+ *     * 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 StyleColor_h
+#define StyleColor_h
+
+#include "core/platform/graphics/Color.h"
+#include "wtf/FastAllocBase.h"
+
+namespace WebCore {
+
+class StyleColor {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    StyleColor()
+        : m_color()
+        , m_valid(false)
+        , m_currentColor(false) { }
+    StyleColor(Color color)
+        : m_color(color)
+        , m_valid(true)
+        , m_currentColor(false) { }
+    StyleColor(RGBA32 color, bool valid = true, bool currentColor = false)
+        : m_color(color)
+        , m_valid(valid)
+        , m_currentColor(currentColor) { }
+    StyleColor(int r, int g, int b)
+        : m_color(Color(r, g, b))
+        , m_valid(true)
+        , m_currentColor(false) { }
+    StyleColor(int r, int g, int b, int a)
+        : m_color(Color(r, g, b, a))
+        , m_valid(true)
+        , m_currentColor(false) { }
+    StyleColor(const StyleColor& other)
+        : m_color(other.m_color)
+        , m_valid(other.m_valid)
+        , m_currentColor(other.m_currentColor) { }
+
+    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 setRGB(int r, int g, int b)
+    {
+        m_color.setRGB(r, g, b);
+        m_valid = true;
+        m_currentColor = false;
+    }
+
+    RGBA32 rgb() const { return m_color.rgb(); } // Preserve the alpha.
+    int red() const { return m_color.red(); }
+    int green() const { return m_color.green(); }
+    int blue() const { return m_color.blue(); }
+    int alpha() const { return m_color.alpha(); }
+
+    static const StyleColor invalid()
+    {
+        return StyleColor(false, false);
+    }
+    static const StyleColor currentColor()
+    {
+        return StyleColor(true, true);
+    }
+
+private:
+    StyleColor(bool invalid, bool currentColor)
+        : m_color()
+        , m_valid(invalid)
+        , m_currentColor(currentColor) { }
+
+    Color m_color;
+    bool m_valid;
+    bool m_currentColor;
+};
+
+inline bool operator==(const StyleColor& a, const StyleColor& b)
+{
+    return a.rgb() == b.rgb() && a.isValid() == b.isValid() && a.isCurrentColor() == b.isCurrentColor();
+}
+
+inline bool operator!=(const StyleColor& a, const StyleColor& b)
+{
+    return !(a == b);
+}
+
+
+} // namespace WebCore
+
+#endif // StyleColor_h
diff --git a/Source/core/css/StylePropertySerializer.cpp b/Source/core/css/StylePropertySerializer.cpp
index f8bb3fd..c6f298f 100644
--- a/Source/core/css/StylePropertySerializer.cpp
+++ b/Source/core/css/StylePropertySerializer.cpp
@@ -24,7 +24,7 @@
 #include "core/css/StylePropertySerializer.h"
 
 #include "CSSValueKeywords.h"
-#include "core/css/StylePropertyShorthand.h"
+#include "StylePropertyShorthand.h"
 #include "core/page/RuntimeCSSEnabled.h"
 #include "wtf/BitArray.h"
 #include "wtf/text/StringBuilder.h"
diff --git a/Source/core/css/StylePropertySet.cpp b/Source/core/css/StylePropertySet.cpp
index 9a06b9f..a066caf 100644
--- a/Source/core/css/StylePropertySet.cpp
+++ b/Source/core/css/StylePropertySet.cpp
@@ -22,12 +22,13 @@
 #include "config.h"
 #include "core/css/StylePropertySet.h"
 
+#include "RuntimeEnabledFeatures.h"
+#include "StylePropertyShorthand.h"
 #include "core/css/CSSParser.h"
 #include "core/css/CSSValuePool.h"
 #include "core/css/CSSVariableValue.h"
 #include "core/css/PropertySetCSSStyleDeclaration.h"
 #include "core/css/StylePropertySerializer.h"
-#include "core/css/StylePropertyShorthand.h"
 #include "core/css/StyleSheetContents.h"
 #include "core/page/RuntimeCSSEnabled.h"
 #include "wtf/text/StringBuilder.h"
@@ -121,6 +122,26 @@
     return propertyAt(foundPropertyIndex).value();
 }
 
+unsigned StylePropertySet::variableCount() const
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    unsigned count = 0;
+    for (unsigned i = 0; i < propertyCount(); ++i) {
+        if (propertyAt(i).id() == CSSPropertyVariable)
+            count++;
+    }
+    return count;
+}
+
+String StylePropertySet::variableValue(const AtomicString& name) const
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    size_t index = findVariableIndex(name);
+    if (index == notFound)
+        return String();
+    return toCSSVariableValue(propertyAt(index).value())->value();
+}
+
 bool MutableStylePropertySet::removeShorthandProperty(CSSPropertyID propertyID)
 {
     StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
@@ -255,6 +276,27 @@
     return indexOfShorthandForLonghand(prefixedShorthand, matchingShorthandsForLonghand(prefixingVariant));
 }
 
+bool MutableStylePropertySet::setVariableValue(const AtomicString& name, const String& value, bool important)
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    if (value.isEmpty())
+        return removeVariable(name);
+
+    size_t index = findVariableIndex(name);
+    if (index != notFound) {
+        CSSValue* cssValue = m_propertyVector.at(index).value();
+        if (toCSSVariableValue(cssValue)->value() == value)
+            return false;
+    }
+
+    CSSProperty property(CSSPropertyVariable, CSSVariableValue::create(name, value), important);
+    if (index == notFound)
+        m_propertyVector.append(property);
+    else
+        m_propertyVector.at(index) = property;
+    return true;
+}
+
 void MutableStylePropertySet::appendPrefixingVariantProperty(const CSSProperty& property)
 {
     m_propertyVector.append(property);
@@ -445,6 +487,17 @@
     return -1;
 }
 
+size_t StylePropertySet::findVariableIndex(const AtomicString& name) const
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    for (int i = propertyCount() - 1; i >= 0; --i) {
+        const PropertyReference& property = propertyAt(i);
+        if (property.id() == CSSPropertyVariable && toCSSVariableValue(property.value())->name() == name)
+            return i;
+    }
+    return notFound;
+}
+
 CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(CSSPropertyID propertyID)
 {
     int foundPropertyIndex = findPropertyIndex(propertyID);
@@ -489,6 +542,23 @@
         removeProperty(propertiesToRemove[i]);
 }
 
+bool MutableStylePropertySet::removeVariable(const AtomicString& name)
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    size_t index = findVariableIndex(name);
+    if (index == notFound)
+        return false;
+    m_propertyVector.remove(index);
+    return true;
+}
+
+bool MutableStylePropertySet::clearVariables()
+{
+    ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+    CSSPropertyID variablesId = CSSPropertyVariable;
+    return removePropertiesInSet(&variablesId, 1);
+}
+
 PassRefPtr<MutableStylePropertySet> StylePropertySet::mutableCopy() const
 {
     return adoptRef(new MutableStylePropertySet(*this));
@@ -564,10 +634,9 @@
 String StylePropertySet::PropertyReference::cssName() const
 {
     if (id() == CSSPropertyVariable) {
-        ASSERT(propertyValue()->isVariableValue());
         if (!propertyValue()->isVariableValue())
             return emptyString(); // Should not happen, but if it does, avoid a bad cast.
-        return "var-" + static_cast<const CSSVariableValue*>(propertyValue())->name();
+        return "var-" + toCSSVariableValue(propertyValue())->name();
     }
     return getPropertyNameString(id());
 }
diff --git a/Source/core/css/StylePropertySet.h b/Source/core/css/StylePropertySet.h
index e8d76a7..9bf6a56 100644
--- a/Source/core/css/StylePropertySet.h
+++ b/Source/core/css/StylePropertySet.h
@@ -85,9 +85,13 @@
     bool isEmpty() const;
     PropertyReference propertyAt(unsigned index) const { return PropertyReference(*this, index); }
     int findPropertyIndex(CSSPropertyID) const;
+    size_t findVariableIndex(const AtomicString& name) const;
 
     PassRefPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const;
     String getPropertyValue(CSSPropertyID) const;
+    unsigned variableCount() const;
+    String variableValue(const AtomicString& name) const;
+
     bool propertyIsImportant(CSSPropertyID) const;
     CSSPropertyID getPropertyShorthand(CSSPropertyID) const;
     bool isPropertyImplicit(CSSPropertyID) const;
@@ -189,6 +193,7 @@
     void appendPrefixingVariantProperty(const CSSProperty&);
     void setPrefixingVariantProperty(const CSSProperty&);
     void setProperty(const CSSProperty&, CSSProperty* slot = 0);
+    bool setVariableValue(const AtomicString& name, const String& value, bool important = false);
 
     bool removeProperty(CSSPropertyID, String* returnText = 0);
     void removePrefixedOrUnprefixedProperty(CSSPropertyID);
@@ -196,6 +201,8 @@
     bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
     void removeEquivalentProperties(const StylePropertySet*);
     void removeEquivalentProperties(const CSSStyleDeclaration*);
+    bool removeVariable(const AtomicString& name);
+    bool clearVariables();
 
     void mergeAndOverrideOnConflict(const StylePropertySet*);
 
diff --git a/Source/core/css/StylePropertyShorthand.cpp b/Source/core/css/StylePropertyShorthand.cpp
deleted file mode 100644
index 6e6512f..0000000
--- a/Source/core/css/StylePropertyShorthand.cpp
+++ /dev/null
@@ -1,954 +0,0 @@
-/*
- * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2013 Intel Corporation. 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.
- */
-
-#include "config.h"
-#include "core/css/StylePropertyShorthand.h"
-
-#include "wtf/HashMap.h"
-#include "wtf/StdLibExtras.h"
-
-namespace WebCore {
-
-const StylePropertyShorthand& backgroundShorthand()
-{
-    static const CSSPropertyID backgroundProperties[] = {
-        CSSPropertyBackgroundImage,
-        CSSPropertyBackgroundPositionX,
-        CSSPropertyBackgroundPositionY,
-        CSSPropertyBackgroundSize,
-        CSSPropertyBackgroundRepeatX,
-        CSSPropertyBackgroundRepeatY,
-        CSSPropertyBackgroundAttachment,
-        CSSPropertyBackgroundOrigin,
-        CSSPropertyBackgroundClip,
-        CSSPropertyBackgroundColor
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, backgroundShorthand, (CSSPropertyBackground, backgroundProperties, WTF_ARRAY_LENGTH(backgroundProperties)));
-    return backgroundShorthand;
-}
-
-const StylePropertyShorthand& backgroundPositionShorthand()
-{
-    static const CSSPropertyID backgroundPositionProperties[] = { CSSPropertyBackgroundPositionX, CSSPropertyBackgroundPositionY };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, backgroundPositionLonghands, (CSSPropertyBackgroundPosition, backgroundPositionProperties, WTF_ARRAY_LENGTH(backgroundPositionProperties)));
-    return backgroundPositionLonghands;
-}
-
-const StylePropertyShorthand& backgroundRepeatShorthand()
-{
-    static const CSSPropertyID backgroundRepeatProperties[] = { CSSPropertyBackgroundRepeatX, CSSPropertyBackgroundRepeatY };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, backgroundRepeatLonghands, (CSSPropertyBackgroundRepeat, backgroundRepeatProperties, WTF_ARRAY_LENGTH(backgroundRepeatProperties)));
-    return backgroundRepeatLonghands;
-}
-
-const StylePropertyShorthand& borderShorthand()
-{
-    // Do not change the order of the following four shorthands, and keep them together.
-    static const CSSPropertyID borderProperties[4][3] = {
-        { CSSPropertyBorderTopColor, CSSPropertyBorderTopStyle, CSSPropertyBorderTopWidth },
-        { CSSPropertyBorderRightColor, CSSPropertyBorderRightStyle, CSSPropertyBorderRightWidth },
-        { CSSPropertyBorderBottomColor, CSSPropertyBorderBottomStyle, CSSPropertyBorderBottomWidth },
-        { CSSPropertyBorderLeftColor, CSSPropertyBorderLeftStyle, CSSPropertyBorderLeftWidth }
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderLonghands, (CSSPropertyBorder, borderProperties[0], sizeof(borderProperties) / sizeof(borderProperties[0][0])));
-    return borderLonghands;
-}
-
-const StylePropertyShorthand& borderAbridgedShorthand()
-{
-    static const CSSPropertyID borderAbridgedProperties[] = { CSSPropertyBorderWidth, CSSPropertyBorderStyle, CSSPropertyBorderColor };
-    static const StylePropertyShorthand* propertiesForInitialization[] = {
-        &borderWidthShorthand(),
-        &borderStyleShorthand(),
-        &borderColorShorthand(),
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderAbridgedLonghands,
-        (CSSPropertyBorder, borderAbridgedProperties, propertiesForInitialization, WTF_ARRAY_LENGTH(borderAbridgedProperties)));
-    return borderAbridgedLonghands;
-}
-
-const StylePropertyShorthand& borderBottomShorthand()
-{
-    static const CSSPropertyID borderBottomProperties[] = { CSSPropertyBorderBottomWidth, CSSPropertyBorderBottomStyle, CSSPropertyBorderBottomColor };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderBottomLonghands, (CSSPropertyBorderBottom, borderBottomProperties, WTF_ARRAY_LENGTH(borderBottomProperties)));
-    return borderBottomLonghands;
-}
-
-const StylePropertyShorthand& borderColorShorthand()
-{
-    static const CSSPropertyID borderColorProperties[] = {
-        CSSPropertyBorderTopColor,
-        CSSPropertyBorderRightColor,
-        CSSPropertyBorderBottomColor,
-        CSSPropertyBorderLeftColor
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderColorLonghands, (CSSPropertyBorderColor, borderColorProperties, WTF_ARRAY_LENGTH(borderColorProperties)));
-    return borderColorLonghands;
-}
-
-const StylePropertyShorthand& borderImageShorthand()
-{
-    static const CSSPropertyID borderImageProperties[] = {
-        CSSPropertyBorderImageSource,
-        CSSPropertyBorderImageSlice,
-        CSSPropertyBorderImageWidth,
-        CSSPropertyBorderImageOutset,
-        CSSPropertyBorderImageRepeat
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderImageLonghands, (CSSPropertyBorderImage, borderImageProperties, WTF_ARRAY_LENGTH(borderImageProperties)));
-    return borderImageLonghands;
-}
-
-const StylePropertyShorthand& borderLeftShorthand()
-{
-    static const CSSPropertyID borderLeftProperties[] = { CSSPropertyBorderLeftWidth, CSSPropertyBorderLeftStyle, CSSPropertyBorderLeftColor };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderLeftLonghands, (CSSPropertyBorderLeft, borderLeftProperties, WTF_ARRAY_LENGTH(borderLeftProperties)));
-    return borderLeftLonghands;
-}
-
-const StylePropertyShorthand& borderRadiusShorthand()
-{
-    static const CSSPropertyID borderRadiusProperties[] = {
-        CSSPropertyBorderTopLeftRadius,
-        CSSPropertyBorderTopRightRadius,
-        CSSPropertyBorderBottomRightRadius,
-        CSSPropertyBorderBottomLeftRadius
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderRadiusLonghands, (CSSPropertyBorderRadius, borderRadiusProperties, WTF_ARRAY_LENGTH(borderRadiusProperties)));
-    return borderRadiusLonghands;
-}
-
-const StylePropertyShorthand& webkitBorderRadiusShorthand()
-{
-    static const CSSPropertyID borderRadiusProperties[] = {
-        CSSPropertyBorderTopLeftRadius,
-        CSSPropertyBorderTopRightRadius,
-        CSSPropertyBorderBottomRightRadius,
-        CSSPropertyBorderBottomLeftRadius
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderRadiusLonghands, (CSSPropertyWebkitBorderRadius, borderRadiusProperties, WTF_ARRAY_LENGTH(borderRadiusProperties)));
-    return borderRadiusLonghands;
-}
-
-const StylePropertyShorthand& borderRightShorthand()
-{
-    static const CSSPropertyID borderRightProperties[] = { CSSPropertyBorderRightWidth, CSSPropertyBorderRightStyle, CSSPropertyBorderRightColor };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderRightLonghands, (CSSPropertyBorderRight, borderRightProperties, WTF_ARRAY_LENGTH(borderRightProperties)));
-    return borderRightLonghands;
-}
-
-const StylePropertyShorthand& borderSpacingShorthand()
-{
-    static const CSSPropertyID borderSpacingProperties[] = { CSSPropertyWebkitBorderHorizontalSpacing, CSSPropertyWebkitBorderVerticalSpacing };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderSpacingLonghands, (CSSPropertyBorderSpacing, borderSpacingProperties, WTF_ARRAY_LENGTH(borderSpacingProperties)));
-    return borderSpacingLonghands;
-}
-
-const StylePropertyShorthand& borderStyleShorthand()
-{
-    static const CSSPropertyID borderStyleProperties[] = {
-        CSSPropertyBorderTopStyle,
-        CSSPropertyBorderRightStyle,
-        CSSPropertyBorderBottomStyle,
-        CSSPropertyBorderLeftStyle
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderStyleLonghands, (CSSPropertyBorderStyle, borderStyleProperties, WTF_ARRAY_LENGTH(borderStyleProperties)));
-    return borderStyleLonghands;
-}
-
-const StylePropertyShorthand& borderTopShorthand()
-{
-    static const CSSPropertyID borderTopProperties[] = { CSSPropertyBorderTopWidth, CSSPropertyBorderTopStyle, CSSPropertyBorderTopColor };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderTopLonghands, (CSSPropertyBorderTop, borderTopProperties, WTF_ARRAY_LENGTH(borderTopProperties)));
-    return borderTopLonghands;
-}
-
-const StylePropertyShorthand& borderWidthShorthand()
-{
-    static const CSSPropertyID borderWidthProperties[] = {
-        CSSPropertyBorderTopWidth,
-        CSSPropertyBorderRightWidth,
-        CSSPropertyBorderBottomWidth,
-        CSSPropertyBorderLeftWidth
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderWidthLonghands, (CSSPropertyBorderWidth, borderWidthProperties, WTF_ARRAY_LENGTH(borderWidthProperties)));
-    return borderWidthLonghands;
-}
-
-const StylePropertyShorthand& listStyleShorthand()
-{
-    static const CSSPropertyID listStyleProperties[] = {
-        CSSPropertyListStyleType,
-        CSSPropertyListStylePosition,
-        CSSPropertyListStyleImage
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, listStyleLonghands, (CSSPropertyListStyle, listStyleProperties, WTF_ARRAY_LENGTH(listStyleProperties)));
-    return listStyleLonghands;
-}
-
-const StylePropertyShorthand& fontShorthand()
-{
-    static const CSSPropertyID fontProperties[] = {
-        CSSPropertyFontFamily,
-        CSSPropertyFontSize,
-        CSSPropertyFontStyle,
-        CSSPropertyFontVariant,
-        CSSPropertyFontWeight,
-        CSSPropertyLineHeight
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, fontLonghands, (CSSPropertyFont, fontProperties, WTF_ARRAY_LENGTH(fontProperties)));
-    return fontLonghands;
-}
-
-const StylePropertyShorthand& marginShorthand()
-{
-    static const CSSPropertyID marginProperties[] = {
-        CSSPropertyMarginTop,
-        CSSPropertyMarginRight,
-        CSSPropertyMarginBottom,
-        CSSPropertyMarginLeft
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, marginLonghands, (CSSPropertyMargin, marginProperties, WTF_ARRAY_LENGTH(marginProperties)));
-    return marginLonghands;
-}
-
-const StylePropertyShorthand& markerShorthand()
-{
-    static const CSSPropertyID markerProperties[] = {
-        CSSPropertyMarkerStart,
-        CSSPropertyMarkerMid,
-        CSSPropertyMarkerEnd
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, markerLonghands, (CSSPropertyMarker, markerProperties, WTF_ARRAY_LENGTH(markerProperties)));
-    return markerLonghands;
-}
-
-const StylePropertyShorthand& outlineShorthand()
-{
-    static const CSSPropertyID outlineProperties[] = {
-        CSSPropertyOutlineColor,
-        CSSPropertyOutlineStyle,
-        CSSPropertyOutlineWidth
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, outlineLonghands, (CSSPropertyOutline, outlineProperties, WTF_ARRAY_LENGTH(outlineProperties)));
-    return outlineLonghands;
-}
-
-const StylePropertyShorthand& overflowShorthand()
-{
-    static const CSSPropertyID overflowProperties[] = { CSSPropertyOverflowX, CSSPropertyOverflowY };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, overflowLonghands, (CSSPropertyOverflow, overflowProperties, WTF_ARRAY_LENGTH(overflowProperties)));
-    return overflowLonghands;
-}
-
-const StylePropertyShorthand& paddingShorthand()
-{
-    static const CSSPropertyID paddingProperties[] = {
-        CSSPropertyPaddingTop,
-        CSSPropertyPaddingRight,
-        CSSPropertyPaddingBottom,
-        CSSPropertyPaddingLeft
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, paddingLonghands, (CSSPropertyPadding, paddingProperties, WTF_ARRAY_LENGTH(paddingProperties)));
-    return paddingLonghands;
-}
-
-const StylePropertyShorthand& transitionShorthand()
-{
-    static const CSSPropertyID transitionProperties[] = {
-        CSSPropertyTransitionProperty,
-        CSSPropertyTransitionDuration,
-        CSSPropertyTransitionTimingFunction,
-        CSSPropertyTransitionDelay
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, transitionLonghands, (CSSPropertyTransition, transitionProperties, WTF_ARRAY_LENGTH(transitionProperties)));
-    return transitionLonghands;
-}
-
-const StylePropertyShorthand& webkitAnimationShorthand()
-{
-    static const CSSPropertyID animationProperties[] = {
-        CSSPropertyWebkitAnimationName,
-        CSSPropertyWebkitAnimationDuration,
-        CSSPropertyWebkitAnimationTimingFunction,
-        CSSPropertyWebkitAnimationDelay,
-        CSSPropertyWebkitAnimationIterationCount,
-        CSSPropertyWebkitAnimationDirection,
-        CSSPropertyWebkitAnimationFillMode
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitAnimationLonghands, (CSSPropertyWebkitAnimation, animationProperties, WTF_ARRAY_LENGTH(animationProperties)));
-    return webkitAnimationLonghands;
-}
-
-const StylePropertyShorthand& webkitAnimationShorthandForParsing()
-{
-    // When we parse the animation shorthand we need to look for animation-name
-    // last because otherwise it might match against the keywords for fill mode,
-    // timing functions and infinite iteration. This means that animation names
-    // that are the same as keywords (e.g. 'forwards') won't always match in the
-    // shorthand. In that case the authors should be using longhands (or
-    // reconsidering their approach). This is covered by the animations spec
-    // bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=14790
-    // And in the spec (editor's draft) at:
-    // http://dev.w3.org/csswg/css3-animations/#animation-shorthand-property
-    static const CSSPropertyID animationPropertiesForParsing[] = {
-        CSSPropertyWebkitAnimationDuration,
-        CSSPropertyWebkitAnimationTimingFunction,
-        CSSPropertyWebkitAnimationDelay,
-        CSSPropertyWebkitAnimationIterationCount,
-        CSSPropertyWebkitAnimationDirection,
-        CSSPropertyWebkitAnimationFillMode,
-        CSSPropertyWebkitAnimationName
-    };
-
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitAnimationLonghandsForParsing, (CSSPropertyWebkitAnimation, animationPropertiesForParsing, WTF_ARRAY_LENGTH(animationPropertiesForParsing)));
-    return webkitAnimationLonghandsForParsing;
-}
-
-const StylePropertyShorthand& webkitBorderAfterShorthand()
-{
-    static const CSSPropertyID borderAfterProperties[] = { CSSPropertyWebkitBorderAfterWidth, CSSPropertyWebkitBorderAfterStyle, CSSPropertyWebkitBorderAfterColor  };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderAfterLonghands, (CSSPropertyWebkitBorderAfter, borderAfterProperties, WTF_ARRAY_LENGTH(borderAfterProperties)));
-    return webkitBorderAfterLonghands;
-}
-
-const StylePropertyShorthand& webkitBorderBeforeShorthand()
-{
-    static const CSSPropertyID borderBeforeProperties[] = { CSSPropertyWebkitBorderBeforeWidth, CSSPropertyWebkitBorderBeforeStyle, CSSPropertyWebkitBorderBeforeColor  };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderBeforeLonghands, (CSSPropertyWebkitBorderBefore, borderBeforeProperties, WTF_ARRAY_LENGTH(borderBeforeProperties)));
-    return webkitBorderBeforeLonghands;
-}
-
-const StylePropertyShorthand& webkitBorderEndShorthand()
-{
-    static const CSSPropertyID borderEndProperties[] = { CSSPropertyWebkitBorderEndWidth, CSSPropertyWebkitBorderEndStyle, CSSPropertyWebkitBorderEndColor };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderEndLonghands, (CSSPropertyWebkitBorderEnd, borderEndProperties, WTF_ARRAY_LENGTH(borderEndProperties)));
-    return webkitBorderEndLonghands;
-}
-
-const StylePropertyShorthand& webkitBorderStartShorthand()
-{
-    static const CSSPropertyID borderStartProperties[] = { CSSPropertyWebkitBorderStartWidth, CSSPropertyWebkitBorderStartStyle, CSSPropertyWebkitBorderStartColor };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderStartLonghands, (CSSPropertyWebkitBorderStart, borderStartProperties, WTF_ARRAY_LENGTH(borderStartProperties)));
-    return webkitBorderStartLonghands;
-}
-
-const StylePropertyShorthand& webkitColumnsShorthand()
-{
-    static const CSSPropertyID columnsProperties[] = { CSSPropertyWebkitColumnWidth, CSSPropertyWebkitColumnCount };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitColumnsLonghands, (CSSPropertyWebkitColumns, columnsProperties, WTF_ARRAY_LENGTH(columnsProperties)));
-    return webkitColumnsLonghands;
-}
-
-const StylePropertyShorthand& webkitColumnRuleShorthand()
-{
-    static const CSSPropertyID columnRuleProperties[] = {
-        CSSPropertyWebkitColumnRuleWidth,
-        CSSPropertyWebkitColumnRuleStyle,
-        CSSPropertyWebkitColumnRuleColor,
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitColumnRuleLonghands, (CSSPropertyWebkitColumnRule, columnRuleProperties, WTF_ARRAY_LENGTH(columnRuleProperties)));
-    return webkitColumnRuleLonghands;
-}
-
-const StylePropertyShorthand& flexFlowShorthand()
-{
-    static const CSSPropertyID flexFlowProperties[] = { CSSPropertyFlexDirection, CSSPropertyFlexWrap };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, flexFlowLonghands, (CSSPropertyFlexFlow, flexFlowProperties, WTF_ARRAY_LENGTH(flexFlowProperties)));
-    return flexFlowLonghands;
-}
-
-const StylePropertyShorthand& flexShorthand()
-{
-    static const CSSPropertyID flexProperties[] = { CSSPropertyFlexGrow, CSSPropertyFlexShrink, CSSPropertyFlexBasis };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, flexLonghands, (CSSPropertyFlex, flexProperties, WTF_ARRAY_LENGTH(flexProperties)));
-    return flexLonghands;
-}
-
-const StylePropertyShorthand& webkitMarginCollapseShorthand()
-{
-    static const CSSPropertyID marginCollapseProperties[] = { CSSPropertyWebkitMarginBeforeCollapse, CSSPropertyWebkitMarginAfterCollapse };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMarginCollapseLonghands, (CSSPropertyWebkitMarginCollapse, marginCollapseProperties, WTF_ARRAY_LENGTH(marginCollapseProperties)));
-    return webkitMarginCollapseLonghands;
-}
-
-const StylePropertyShorthand& gridColumnShorthand()
-{
-    static const CSSPropertyID gridColumnProperties[] = {
-        CSSPropertyGridColumnStart,
-        CSSPropertyGridColumnEnd
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, gridColumnLonghands, (CSSPropertyGridColumn, gridColumnProperties, WTF_ARRAY_LENGTH(gridColumnProperties)));
-    return gridColumnLonghands;
-}
-
-const StylePropertyShorthand& gridRowShorthand()
-{
-    static const CSSPropertyID gridRowProperties[] = {
-        CSSPropertyGridRowStart,
-        CSSPropertyGridRowEnd
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, gridRowLonghands, (CSSPropertyGridRow, gridRowProperties, WTF_ARRAY_LENGTH(gridRowProperties)));
-    return gridRowLonghands;
-}
-
-const StylePropertyShorthand& gridAreaShorthand()
-{
-    static const CSSPropertyID gridAreaProperties[] = {
-        CSSPropertyGridColumnStart,
-        CSSPropertyGridRowStart,
-        CSSPropertyGridColumnEnd,
-        CSSPropertyGridRowEnd
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, gridAreaLonghands, (CSSPropertyGridArea, gridAreaProperties, WTF_ARRAY_LENGTH(gridAreaProperties)));
-    return gridAreaLonghands;
-}
-
-const StylePropertyShorthand& webkitMarqueeShorthand()
-{
-    static const CSSPropertyID marqueeProperties[] = {
-        CSSPropertyWebkitMarqueeDirection,
-        CSSPropertyWebkitMarqueeIncrement,
-        CSSPropertyWebkitMarqueeRepetition,
-        CSSPropertyWebkitMarqueeStyle,
-        CSSPropertyWebkitMarqueeSpeed
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMarqueeLonghands, (CSSPropertyWebkitMarquee, marqueeProperties, WTF_ARRAY_LENGTH(marqueeProperties)));
-    return webkitMarqueeLonghands;
-}
-
-const StylePropertyShorthand& webkitMaskShorthand()
-{
-    static const CSSPropertyID maskProperties[] = {
-        CSSPropertyWebkitMaskImage,
-        CSSPropertyWebkitMaskPositionX,
-        CSSPropertyWebkitMaskPositionY,
-        CSSPropertyWebkitMaskSize,
-        CSSPropertyWebkitMaskRepeatX,
-        CSSPropertyWebkitMaskRepeatY,
-        CSSPropertyWebkitMaskOrigin,
-        CSSPropertyWebkitMaskClip
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMaskLonghands, (CSSPropertyWebkitMask, maskProperties, WTF_ARRAY_LENGTH(maskProperties)));
-    return webkitMaskLonghands;
-}
-
-const StylePropertyShorthand& webkitMaskPositionShorthand()
-{
-    static const CSSPropertyID maskPositionProperties[] = { CSSPropertyWebkitMaskPositionX, CSSPropertyWebkitMaskPositionY };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMaskPositionLonghands, (CSSPropertyWebkitMaskPosition, maskPositionProperties, WTF_ARRAY_LENGTH(maskPositionProperties)));
-    return webkitMaskPositionLonghands;
-}
-
-const StylePropertyShorthand& webkitMaskRepeatShorthand()
-{
-    static const CSSPropertyID maskRepeatProperties[] = { CSSPropertyWebkitMaskRepeatX, CSSPropertyWebkitMaskRepeatY };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMaskRepeatLonghands, (CSSPropertyWebkitMaskRepeat, maskRepeatProperties, WTF_ARRAY_LENGTH(maskRepeatProperties)));
-    return webkitMaskRepeatLonghands;
-}
-
-const StylePropertyShorthand& webkitTextEmphasisShorthand()
-{
-    static const CSSPropertyID textEmphasisProperties[] = {
-        CSSPropertyWebkitTextEmphasisStyle,
-        CSSPropertyWebkitTextEmphasisColor
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTextEmphasisLonghands, (CSSPropertyWebkitTextEmphasis, textEmphasisProperties, WTF_ARRAY_LENGTH(textEmphasisProperties)));
-    return webkitTextEmphasisLonghands;
-}
-
-const StylePropertyShorthand& webkitTextStrokeShorthand()
-{
-    static const CSSPropertyID textStrokeProperties[] = { CSSPropertyWebkitTextStrokeWidth, CSSPropertyWebkitTextStrokeColor };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTextStrokeLonghands, (CSSPropertyWebkitTextStroke, textStrokeProperties, WTF_ARRAY_LENGTH(textStrokeProperties)));
-    return webkitTextStrokeLonghands;
-}
-
-const StylePropertyShorthand& webkitTransitionShorthand()
-{
-    static const CSSPropertyID transitionProperties[] = {
-        CSSPropertyWebkitTransitionProperty,
-        CSSPropertyWebkitTransitionDuration,
-        CSSPropertyWebkitTransitionTimingFunction,
-        CSSPropertyWebkitTransitionDelay
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTransitionLonghands, (CSSPropertyWebkitTransition, transitionProperties, WTF_ARRAY_LENGTH(transitionProperties)));
-    return webkitTransitionLonghands;
-}
-
-const StylePropertyShorthand& webkitTransformOriginShorthand()
-{
-    static const CSSPropertyID transformOriginProperties[] = {
-        CSSPropertyWebkitTransformOriginX,
-        CSSPropertyWebkitTransformOriginY,
-        CSSPropertyWebkitTransformOriginZ
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTransformOriginLonghands, (CSSPropertyWebkitTransformOrigin, transformOriginProperties, WTF_ARRAY_LENGTH(transformOriginProperties)));
-    return webkitTransformOriginLonghands;
-}
-
-const StylePropertyShorthand& widthShorthand()
-{
-    static const CSSPropertyID widthProperties[] = {
-        CSSPropertyMinWidth,
-        CSSPropertyMaxWidth
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, widthLonghands, (CSSPropertyWidth, widthProperties, WTF_ARRAY_LENGTH(widthProperties)));
-    return widthLonghands;
-}
-
-const StylePropertyShorthand& heightShorthand()
-{
-    static const CSSPropertyID heightProperties[] = {
-        CSSPropertyMinHeight,
-        CSSPropertyMaxHeight
-    };
-    DEFINE_STATIC_LOCAL(StylePropertyShorthand, heightLonghands, (CSSPropertyHeight, heightProperties, WTF_ARRAY_LENGTH(heightProperties)));
-    return heightLonghands;
-}
-
-// Returns an empty list if the property is not a shorthand
-const StylePropertyShorthand& shorthandForProperty(CSSPropertyID propertyID)
-{
-    switch (propertyID) {
-    case CSSPropertyBackground:
-        return backgroundShorthand();
-    case CSSPropertyBackgroundPosition:
-        return backgroundPositionShorthand();
-    case CSSPropertyBackgroundRepeat:
-        return backgroundRepeatShorthand();
-    case CSSPropertyBorder:
-        return borderShorthand();
-    case CSSPropertyBorderBottom:
-        return borderBottomShorthand();
-    case CSSPropertyBorderColor:
-        return borderColorShorthand();
-    case CSSPropertyBorderImage:
-        return borderImageShorthand();
-    case CSSPropertyBorderLeft:
-        return borderLeftShorthand();
-    case CSSPropertyBorderRadius:
-        return borderRadiusShorthand();
-    case CSSPropertyBorderRight:
-        return borderRightShorthand();
-    case CSSPropertyBorderSpacing:
-        return borderSpacingShorthand();
-    case CSSPropertyBorderStyle:
-        return borderStyleShorthand();
-    case CSSPropertyBorderTop:
-        return borderTopShorthand();
-    case CSSPropertyBorderWidth:
-        return borderWidthShorthand();
-    case CSSPropertyListStyle:
-        return listStyleShorthand();
-    case CSSPropertyFont:
-        return fontShorthand();
-    case CSSPropertyMargin:
-        return marginShorthand();
-    case CSSPropertyOutline:
-        return outlineShorthand();
-    case CSSPropertyOverflow:
-        return overflowShorthand();
-    case CSSPropertyPadding:
-        return paddingShorthand();
-    case CSSPropertyTransition:
-        return transitionShorthand();
-    case CSSPropertyWebkitAnimation:
-        return webkitAnimationShorthand();
-    case CSSPropertyWebkitBorderAfter:
-        return webkitBorderAfterShorthand();
-    case CSSPropertyWebkitBorderBefore:
-        return webkitBorderBeforeShorthand();
-    case CSSPropertyWebkitBorderEnd:
-        return webkitBorderEndShorthand();
-    case CSSPropertyWebkitBorderStart:
-        return webkitBorderStartShorthand();
-    case CSSPropertyWebkitBorderRadius:
-        return borderRadiusShorthand();
-    case CSSPropertyWebkitColumns:
-        return webkitColumnsShorthand();
-    case CSSPropertyWebkitColumnRule:
-        return webkitColumnRuleShorthand();
-    case CSSPropertyFlex:
-        return flexShorthand();
-    case CSSPropertyFlexFlow:
-        return flexFlowShorthand();
-    case CSSPropertyGridColumn:
-        return gridColumnShorthand();
-    case CSSPropertyGridRow:
-        return gridRowShorthand();
-    case CSSPropertyGridArea:
-        return gridAreaShorthand();
-    case CSSPropertyWebkitMarginCollapse:
-        return webkitMarginCollapseShorthand();
-    case CSSPropertyWebkitMarquee:
-        return webkitMarqueeShorthand();
-    case CSSPropertyWebkitMask:
-        return webkitMaskShorthand();
-    case CSSPropertyWebkitMaskPosition:
-        return webkitMaskPositionShorthand();
-    case CSSPropertyWebkitMaskRepeat:
-        return webkitMaskRepeatShorthand();
-    case CSSPropertyWebkitTextEmphasis:
-        return webkitTextEmphasisShorthand();
-    case CSSPropertyWebkitTextStroke:
-        return webkitTextStrokeShorthand();
-    case CSSPropertyWebkitTransition:
-        return webkitTransitionShorthand();
-    case CSSPropertyWebkitTransformOrigin:
-        return webkitTransformOriginShorthand();
-    default: {
-        DEFINE_STATIC_LOCAL(StylePropertyShorthand, emptyShorthand, ());
-        return emptyShorthand;
-    }
-    }
-}
-
-bool isExpandedShorthand(CSSPropertyID id)
-{
-    // The system fonts bypass the normal style resolution by using RenderTheme,
-    // thus we need to special case it here. FIXME: This is a violation of CSS 3 Fonts
-    // as we should still be able to change the longhands.
-    // DON'T ADD ANY SHORTHAND HERE UNLESS IT ISN'T ALWAYS EXPANDED AT PARSE TIME (which is wrong).
-    if (id == CSSPropertyFont)
-        return false;
-
-    return shorthandForProperty(id).length();
-}
-
-// FIXME : We need to generate all of this.
-typedef HashMap<CSSPropertyID, Vector<StylePropertyShorthand> > longhandsMap;
-const Vector<StylePropertyShorthand> matchingShorthandsForLonghand(CSSPropertyID propertyID)
-{
-    DEFINE_STATIC_LOCAL(longhandsMap, map, ());
-    if (map.isEmpty()) {
-        Vector<StylePropertyShorthand, 1> background;
-        background.uncheckedAppend(backgroundShorthand());
-        map.set(CSSPropertyBackgroundImage, background);
-        map.set(CSSPropertyBackgroundSize, background);
-        map.set(CSSPropertyBackgroundAttachment, background);
-        map.set(CSSPropertyBackgroundOrigin, background);
-        map.set(CSSPropertyBackgroundClip, background);
-        map.set(CSSPropertyBackgroundColor, background);
-
-        Vector<StylePropertyShorthand, 2> positionShorthands;
-        positionShorthands.uncheckedAppend(backgroundShorthand());
-        positionShorthands.uncheckedAppend(backgroundPositionShorthand());
-        map.set(CSSPropertyBackgroundPositionX, positionShorthands);
-        map.set(CSSPropertyBackgroundPositionY, positionShorthands);
-
-        Vector<StylePropertyShorthand, 2> repeatShorthands;
-        repeatShorthands.uncheckedAppend(backgroundShorthand());
-        repeatShorthands.uncheckedAppend(backgroundRepeatShorthand());
-        map.set(CSSPropertyBackgroundRepeatX, repeatShorthands);
-        map.set(CSSPropertyBackgroundRepeatY, repeatShorthands);
-
-        Vector<StylePropertyShorthand, 3> bottomWidthShorthands;
-        bottomWidthShorthands.uncheckedAppend(borderShorthand());
-        bottomWidthShorthands.uncheckedAppend(borderBottomShorthand());
-        bottomWidthShorthands.uncheckedAppend(borderWidthShorthand());
-        map.set(CSSPropertyBorderBottomWidth, bottomWidthShorthands);
-
-        Vector<StylePropertyShorthand, 3> topColorShorthands;
-        topColorShorthands.uncheckedAppend(borderShorthand());
-        topColorShorthands.uncheckedAppend(borderTopShorthand());
-        topColorShorthands.uncheckedAppend(borderColorShorthand());
-        map.set(CSSPropertyBorderTopColor, topColorShorthands);
-
-        Vector<StylePropertyShorthand, 3> rightColorShorthands;
-        rightColorShorthands.uncheckedAppend(borderShorthand());
-        rightColorShorthands.uncheckedAppend(borderRightShorthand());
-        rightColorShorthands.uncheckedAppend(borderColorShorthand());
-        map.set(CSSPropertyBorderRightColor, rightColorShorthands);
-
-        Vector<StylePropertyShorthand, 3> leftColorShorthands;
-        leftColorShorthands.uncheckedAppend(borderShorthand());
-        leftColorShorthands.uncheckedAppend(borderLeftShorthand());
-        leftColorShorthands.uncheckedAppend(borderColorShorthand());
-        map.set(CSSPropertyBorderLeftColor, leftColorShorthands);
-
-        Vector<StylePropertyShorthand, 3> bottomColorShorthands;
-        bottomColorShorthands.uncheckedAppend(borderShorthand());
-        bottomColorShorthands.uncheckedAppend(borderBottomShorthand());
-        bottomColorShorthands.uncheckedAppend(borderColorShorthand());
-        map.set(CSSPropertyBorderBottomColor, bottomColorShorthands);
-
-        Vector<StylePropertyShorthand, 1> borderImage;
-        borderImage.uncheckedAppend(borderImageShorthand());
-        map.set(CSSPropertyBorderImageSource, borderImage);
-        map.set(CSSPropertyBorderImageSlice, borderImage);
-        map.set(CSSPropertyBorderImageWidth, borderImage);
-        map.set(CSSPropertyBorderImageOutset, borderImage);
-        map.set(CSSPropertyBorderImageRepeat, borderImage);
-
-        Vector<StylePropertyShorthand, 3> leftWidthShorthands;
-        leftWidthShorthands.uncheckedAppend(borderShorthand());
-        leftWidthShorthands.uncheckedAppend(borderLeftShorthand());
-        leftWidthShorthands.uncheckedAppend(borderWidthShorthand());
-        map.set(CSSPropertyBorderLeftWidth, leftWidthShorthands);
-
-        Vector<StylePropertyShorthand, 2> radiusShorthands;
-        radiusShorthands.uncheckedAppend(borderRadiusShorthand());
-        radiusShorthands.uncheckedAppend(webkitBorderRadiusShorthand());
-        map.set(CSSPropertyBorderTopLeftRadius, radiusShorthands);
-        map.set(CSSPropertyBorderTopRightRadius, radiusShorthands);
-        map.set(CSSPropertyBorderBottomRightRadius, radiusShorthands);
-        map.set(CSSPropertyBorderBottomLeftRadius, radiusShorthands);
-
-        Vector<StylePropertyShorthand, 3> rightWidthShorthands;
-        rightWidthShorthands.uncheckedAppend(borderShorthand());
-        rightWidthShorthands.uncheckedAppend(borderRightShorthand());
-        rightWidthShorthands.uncheckedAppend(borderWidthShorthand());
-        map.set(CSSPropertyBorderRightWidth, rightWidthShorthands);
-
-        Vector<StylePropertyShorthand, 1> spacingShorthand;
-        spacingShorthand.uncheckedAppend(borderSpacingShorthand());
-        map.set(CSSPropertyWebkitBorderHorizontalSpacing, spacingShorthand);
-        map.set(CSSPropertyWebkitBorderVerticalSpacing, spacingShorthand);
-
-        Vector<StylePropertyShorthand, 3> topStyleShorthands;
-        topStyleShorthands.uncheckedAppend(borderShorthand());
-        topStyleShorthands.uncheckedAppend(borderTopShorthand());
-        topStyleShorthands.uncheckedAppend(borderStyleShorthand());
-        map.set(CSSPropertyBorderTopStyle, topStyleShorthands);
-
-        Vector<StylePropertyShorthand, 3> bottomStyleShorthands;
-        bottomStyleShorthands.uncheckedAppend(borderShorthand());
-        bottomStyleShorthands.uncheckedAppend(borderBottomShorthand());
-        bottomStyleShorthands.uncheckedAppend(borderStyleShorthand());
-        map.set(CSSPropertyBorderBottomStyle, bottomStyleShorthands);
-
-        Vector<StylePropertyShorthand, 3> leftStyleShorthands;
-        leftStyleShorthands.uncheckedAppend(borderShorthand());
-        leftStyleShorthands.uncheckedAppend(borderLeftShorthand());
-        leftStyleShorthands.uncheckedAppend(borderStyleShorthand());
-        map.set(CSSPropertyBorderLeftStyle, leftStyleShorthands);
-
-        Vector<StylePropertyShorthand, 3> rightStyleShorthands;
-        rightStyleShorthands.uncheckedAppend(borderShorthand());
-        rightStyleShorthands.uncheckedAppend(borderRightShorthand());
-        rightStyleShorthands.uncheckedAppend(borderStyleShorthand());
-        map.set(CSSPropertyBorderRightStyle, rightStyleShorthands);
-
-        Vector<StylePropertyShorthand, 3> topWidthShorthands;
-        topWidthShorthands.uncheckedAppend(borderShorthand());
-        topWidthShorthands.uncheckedAppend(borderTopShorthand());
-        topWidthShorthands.uncheckedAppend(borderWidthShorthand());
-        map.set(CSSPropertyBorderTopWidth, topWidthShorthands);
-
-        Vector<StylePropertyShorthand, 1> listStyle;
-        listStyle.uncheckedAppend(listStyleShorthand());
-        map.set(CSSPropertyListStyleType, listStyle);
-        map.set(CSSPropertyListStylePosition, listStyle);
-        map.set(CSSPropertyListStyleImage, listStyle);
-
-        Vector<StylePropertyShorthand, 1> font;
-        font.uncheckedAppend(fontShorthand());
-        map.set(CSSPropertyFontFamily, font);
-        map.set(CSSPropertyFontSize, font);
-        map.set(CSSPropertyFontStyle, font);
-        map.set(CSSPropertyFontVariant, font);
-        map.set(CSSPropertyFontWeight, font);
-        map.set(CSSPropertyLineHeight, font);
-
-        Vector<StylePropertyShorthand, 1> margin;
-        margin.uncheckedAppend(marginShorthand());
-        map.set(CSSPropertyMarginTop, margin);
-        map.set(CSSPropertyMarginRight, margin);
-        map.set(CSSPropertyMarginBottom, margin);
-        map.set(CSSPropertyMarginLeft, margin);
-
-        Vector<StylePropertyShorthand, 1> marker;
-        marker.uncheckedAppend(markerShorthand());
-        map.set(CSSPropertyMarkerStart, marker);
-        map.set(CSSPropertyMarkerMid, marker);
-        map.set(CSSPropertyMarkerEnd, marker);
-
-        Vector<StylePropertyShorthand, 1> outline;
-        outline.uncheckedAppend(outlineShorthand());
-        map.set(CSSPropertyOutlineColor, outline);
-        map.set(CSSPropertyOutlineStyle, outline);
-        map.set(CSSPropertyOutlineWidth, outline);
-
-        Vector<StylePropertyShorthand, 1> padding;
-        padding.uncheckedAppend(paddingShorthand());
-        map.set(CSSPropertyPaddingTop, padding);
-        map.set(CSSPropertyPaddingRight, padding);
-        map.set(CSSPropertyPaddingBottom, padding);
-        map.set(CSSPropertyPaddingLeft, padding);
-
-        Vector<StylePropertyShorthand, 1> overflow;
-        overflow.uncheckedAppend(overflowShorthand());
-        map.set(CSSPropertyOverflowX, overflow);
-        map.set(CSSPropertyOverflowY, overflow);
-
-        Vector<StylePropertyShorthand, 1> transition;
-        transition.uncheckedAppend(transitionShorthand());
-        map.set(CSSPropertyTransitionProperty, transition);
-        map.set(CSSPropertyTransitionDuration, transition);
-        map.set(CSSPropertyTransitionTimingFunction, transition);
-        map.set(CSSPropertyTransitionDelay, transition);
-
-        Vector<StylePropertyShorthand, 1> animation;
-        animation.uncheckedAppend(webkitAnimationShorthand());
-        map.set(CSSPropertyWebkitAnimationName, animation);
-        map.set(CSSPropertyWebkitAnimationDuration, animation);
-        map.set(CSSPropertyWebkitAnimationTimingFunction, animation);
-        map.set(CSSPropertyWebkitAnimationDelay, animation);
-        map.set(CSSPropertyWebkitAnimationIterationCount, animation);
-        map.set(CSSPropertyWebkitAnimationDirection, animation);
-        map.set(CSSPropertyWebkitAnimationFillMode, animation);
-
-        Vector<StylePropertyShorthand, 1> borderAfter;
-        borderAfter.uncheckedAppend(webkitBorderAfterShorthand());
-        map.set(CSSPropertyWebkitBorderAfterWidth, borderAfter);
-        map.set(CSSPropertyWebkitBorderAfterStyle, borderAfter);
-        map.set(CSSPropertyWebkitBorderAfterColor, borderAfter);
-
-        Vector<StylePropertyShorthand, 1> borderBefore;
-        borderBefore.uncheckedAppend(webkitBorderBeforeShorthand());
-        map.set(CSSPropertyWebkitBorderBeforeWidth, borderBefore);
-        map.set(CSSPropertyWebkitBorderBeforeStyle, borderBefore);
-        map.set(CSSPropertyWebkitBorderBeforeColor, borderBefore);
-
-        Vector<StylePropertyShorthand, 1> borderEnd;
-        borderEnd.uncheckedAppend(webkitBorderEndShorthand());
-        map.set(CSSPropertyWebkitBorderEndWidth, borderEnd);
-        map.set(CSSPropertyWebkitBorderEndStyle, borderEnd);
-        map.set(CSSPropertyWebkitBorderEndColor, borderEnd);
-
-        Vector<StylePropertyShorthand, 1> borderStart;
-        borderStart.uncheckedAppend(webkitBorderStartShorthand());
-        map.set(CSSPropertyWebkitBorderStartWidth, borderStart);
-        map.set(CSSPropertyWebkitBorderStartStyle, borderStart);
-        map.set(CSSPropertyWebkitBorderStartColor, borderStart);
-
-        Vector<StylePropertyShorthand, 1> columns;
-        columns.uncheckedAppend(webkitColumnsShorthand());
-        map.set(CSSPropertyWebkitColumnWidth, columns);
-        map.set(CSSPropertyWebkitColumnCount, columns);
-
-        Vector<StylePropertyShorthand, 1> columnRule;
-        columnRule.uncheckedAppend(webkitColumnRuleShorthand());
-        map.set(CSSPropertyWebkitColumnRuleWidth, columnRule);
-        map.set(CSSPropertyWebkitColumnRuleStyle, columnRule);
-        map.set(CSSPropertyWebkitColumnRuleColor, columnRule);
-
-        Vector<StylePropertyShorthand, 1> flex;
-        flex.uncheckedAppend(flexShorthand());
-        map.set(CSSPropertyFlexGrow, flex);
-        map.set(CSSPropertyFlexShrink, flex);
-        map.set(CSSPropertyFlexBasis, flex);
-
-        Vector<StylePropertyShorthand, 1> flexFlow;
-        flexFlow.uncheckedAppend(flexFlowShorthand());
-        map.set(CSSPropertyFlexDirection, flexFlow);
-        map.set(CSSPropertyFlexWrap, flexFlow);
-
-        Vector<StylePropertyShorthand, 2> grid;
-        grid.uncheckedAppend(gridAreaShorthand());
-        grid.uncheckedAppend(gridColumnShorthand());
-        map.set(CSSPropertyGridColumnStart, grid);
-        map.set(CSSPropertyGridColumnEnd, grid);
-
-        Vector<StylePropertyShorthand, 2> gridAfter;
-        gridAfter.uncheckedAppend(gridAreaShorthand());
-        gridAfter.uncheckedAppend(gridRowShorthand());
-        map.set(CSSPropertyGridRowStart, gridAfter);
-        map.set(CSSPropertyGridRowEnd, gridAfter);
-
-        Vector<StylePropertyShorthand, 1> marginCollapse;
-        marginCollapse.uncheckedAppend(webkitMarginCollapseShorthand());
-        map.set(CSSPropertyWebkitMarginBeforeCollapse, marginCollapse);
-        map.set(CSSPropertyWebkitMarginAfterCollapse, marginCollapse);
-
-        Vector<StylePropertyShorthand, 1> marquee;
-        marquee.uncheckedAppend(webkitMarqueeShorthand());
-        map.set(CSSPropertyWebkitMarqueeDirection, marquee);
-        map.set(CSSPropertyWebkitMarqueeIncrement, marquee);
-        map.set(CSSPropertyWebkitMarqueeRepetition, marquee);
-        map.set(CSSPropertyWebkitMarqueeStyle, marquee);
-        map.set(CSSPropertyWebkitMarqueeSpeed, marquee);
-
-        Vector<StylePropertyShorthand, 1> mask;
-        mask.uncheckedAppend(webkitMaskShorthand());
-        map.set(CSSPropertyWebkitMaskImage, mask);
-        map.set(CSSPropertyWebkitMaskSize, mask);
-        map.set(CSSPropertyWebkitMaskOrigin, mask);
-        map.set(CSSPropertyWebkitMaskClip, mask);
-
-        Vector<StylePropertyShorthand, 1> maskPosition;
-        maskPosition.uncheckedAppend(webkitMaskPositionShorthand());
-        map.set(CSSPropertyWebkitMaskPositionX, maskPosition);
-        map.set(CSSPropertyWebkitMaskPositionY, maskPosition);
-
-        Vector<StylePropertyShorthand, 1> maskRepeat;
-        maskRepeat.uncheckedAppend(webkitMaskRepeatShorthand());
-        map.set(CSSPropertyWebkitMaskRepeatX, maskRepeat);
-        map.set(CSSPropertyWebkitMaskRepeatY, maskRepeat);
-
-        Vector<StylePropertyShorthand, 1> textEmphasis;
-        textEmphasis.uncheckedAppend(webkitTextEmphasisShorthand());
-        map.set(CSSPropertyWebkitTextEmphasisStyle, textEmphasis);
-        map.set(CSSPropertyWebkitTextEmphasisColor, textEmphasis);
-
-        Vector<StylePropertyShorthand, 1> textStroke;
-        textStroke.uncheckedAppend(webkitTextStrokeShorthand());
-        map.set(CSSPropertyWebkitTextStrokeWidth, textStroke);
-        map.set(CSSPropertyWebkitTextStrokeColor, textStroke);
-
-        Vector<StylePropertyShorthand, 1> webkitTransition;
-        webkitTransition.uncheckedAppend(webkitTransitionShorthand());
-        map.set(CSSPropertyWebkitTransitionProperty, webkitTransition);
-        map.set(CSSPropertyWebkitTransitionDuration, webkitTransition);
-        map.set(CSSPropertyWebkitTransitionTimingFunction, webkitTransition);
-        map.set(CSSPropertyWebkitTransitionDelay, webkitTransition);
-
-        Vector<StylePropertyShorthand, 1> transform;
-        transform.uncheckedAppend(webkitTransformOriginShorthand());
-        map.set(CSSPropertyWebkitTransformOriginX, transform);
-        map.set(CSSPropertyWebkitTransformOriginY, transform);
-        map.set(CSSPropertyWebkitTransformOriginZ, transform);
-
-        Vector<StylePropertyShorthand, 1> width;
-        width.uncheckedAppend(widthShorthand());
-        map.set(CSSPropertyMinWidth, width);
-        map.set(CSSPropertyMaxWidth, width);
-
-        Vector<StylePropertyShorthand, 1> height;
-        height.uncheckedAppend(heightShorthand());
-        map.set(CSSPropertyMinHeight, height);
-        map.set(CSSPropertyMaxHeight, height);
-    }
-    return map.get(propertyID);
-}
-
-unsigned indexOfShorthandForLonghand(CSSPropertyID shorthandID, const Vector<StylePropertyShorthand>& shorthands)
-{
-    for (unsigned i = 0; i < shorthands.size(); ++i) {
-        if (shorthands.at(i).id() == shorthandID)
-            return i;
-    }
-    ASSERT_NOT_REACHED();
-    return 0;
-}
-
-} // namespace WebCore
diff --git a/Source/core/css/StylePropertyShorthand.h b/Source/core/css/StylePropertyShorthand.h
deleted file mode 100644
index d3f3b3f..0000000
--- a/Source/core/css/StylePropertyShorthand.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2013 Intel Corporation. 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 StylePropertyShorthand_h
-#define StylePropertyShorthand_h
-
-#include "CSSPropertyNames.h"
-#include "wtf/Vector.h"
-
-namespace WebCore {
-
-class StylePropertyShorthand {
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    StylePropertyShorthand()
-        : m_properties(0)
-        , m_propertiesForInitialization(0)
-        , m_length(0)
-        , m_shorthandID(CSSPropertyInvalid)
-    {
-    }
-
-    StylePropertyShorthand(CSSPropertyID id, const CSSPropertyID* properties, unsigned numProperties)
-        : m_properties(properties)
-        , m_propertiesForInitialization(0)
-        , m_length(numProperties)
-        , m_shorthandID(id)
-    {
-    }
-
-    StylePropertyShorthand(CSSPropertyID id, const CSSPropertyID* properties, const StylePropertyShorthand** propertiesForInitialization, unsigned numProperties)
-        : m_properties(properties)
-        , m_propertiesForInitialization(propertiesForInitialization)
-        , m_length(numProperties)
-        , m_shorthandID(id)
-    {
-    }
-
-    const CSSPropertyID* properties() const { return m_properties; }
-    const StylePropertyShorthand** propertiesForInitialization() const { return m_propertiesForInitialization; }
-    unsigned length() const { return m_length; }
-    CSSPropertyID id() const { return m_shorthandID; }
-
-private:
-    const CSSPropertyID* m_properties;
-    const StylePropertyShorthand** m_propertiesForInitialization;
-    unsigned m_length;
-    CSSPropertyID m_shorthandID;
-};
-
-const StylePropertyShorthand& backgroundShorthand();
-const StylePropertyShorthand& backgroundPositionShorthand();
-const StylePropertyShorthand& backgroundRepeatShorthand();
-const StylePropertyShorthand& borderShorthand();
-const StylePropertyShorthand& borderAbridgedShorthand();
-const StylePropertyShorthand& borderBottomShorthand();
-const StylePropertyShorthand& borderColorShorthand();
-const StylePropertyShorthand& borderImageShorthand();
-const StylePropertyShorthand& borderLeftShorthand();
-const StylePropertyShorthand& borderRadiusShorthand();
-const StylePropertyShorthand& borderRightShorthand();
-const StylePropertyShorthand& borderSpacingShorthand();
-const StylePropertyShorthand& borderStyleShorthand();
-const StylePropertyShorthand& borderTopShorthand();
-const StylePropertyShorthand& borderWidthShorthand();
-const StylePropertyShorthand& listStyleShorthand();
-const StylePropertyShorthand& fontShorthand();
-const StylePropertyShorthand& marginShorthand();
-const StylePropertyShorthand& outlineShorthand();
-const StylePropertyShorthand& overflowShorthand();
-const StylePropertyShorthand& paddingShorthand();
-const StylePropertyShorthand& transitionShorthand();
-const StylePropertyShorthand& webkitAnimationShorthand();
-const StylePropertyShorthand& webkitAnimationShorthandForParsing();
-const StylePropertyShorthand& webkitBorderAfterShorthand();
-const StylePropertyShorthand& webkitBorderBeforeShorthand();
-const StylePropertyShorthand& webkitBorderEndShorthand();
-const StylePropertyShorthand& webkitBorderStartShorthand();
-const StylePropertyShorthand& webkitColumnsShorthand();
-const StylePropertyShorthand& webkitColumnRuleShorthand();
-const StylePropertyShorthand& flexFlowShorthand();
-const StylePropertyShorthand& flexShorthand();
-const StylePropertyShorthand& gridColumnShorthand();
-const StylePropertyShorthand& gridRowShorthand();
-const StylePropertyShorthand& gridAreaShorthand();
-const StylePropertyShorthand& webkitMarginCollapseShorthand();
-const StylePropertyShorthand& webkitMarqueeShorthand();
-const StylePropertyShorthand& webkitMaskShorthand();
-const StylePropertyShorthand& webkitMaskPositionShorthand();
-const StylePropertyShorthand& webkitMaskRepeatShorthand();
-const StylePropertyShorthand& webkitTextEmphasisShorthand();
-const StylePropertyShorthand& webkitTextStrokeShorthand();
-const StylePropertyShorthand& webkitTransitionShorthand();
-const StylePropertyShorthand& webkitTransformOriginShorthand();
-
-// Returns an empty list if the property is not a shorthand.
-const StylePropertyShorthand& shorthandForProperty(CSSPropertyID);
-
-// Return the list of shorthands for a given longhand.
-const Vector<StylePropertyShorthand> matchingShorthandsForLonghand(CSSPropertyID);
-unsigned indexOfShorthandForLonghand(CSSPropertyID, const Vector<StylePropertyShorthand>&);
-
-bool isExpandedShorthand(CSSPropertyID);
-
-} // namespace WebCore
-
-#endif // StylePropertyShorthand_h
diff --git a/Source/core/css/StylePropertyShorthandCustom.cpp b/Source/core/css/StylePropertyShorthandCustom.cpp
new file mode 100644
index 0000000..dec399d
--- /dev/null
+++ b/Source/core/css/StylePropertyShorthandCustom.cpp
@@ -0,0 +1,98 @@
+/*
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2013 Intel Corporation. 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.
+ */
+
+#include "config.h"
+#include "StylePropertyShorthand.h"
+
+namespace WebCore {
+
+const StylePropertyShorthand& borderShorthand()
+{
+    // Do not change the order of the following four shorthands, and keep them together.
+    static const CSSPropertyID borderProperties[4][3] = {
+        { CSSPropertyBorderTopColor, CSSPropertyBorderTopStyle, CSSPropertyBorderTopWidth },
+        { CSSPropertyBorderRightColor, CSSPropertyBorderRightStyle, CSSPropertyBorderRightWidth },
+        { CSSPropertyBorderBottomColor, CSSPropertyBorderBottomStyle, CSSPropertyBorderBottomWidth },
+        { CSSPropertyBorderLeftColor, CSSPropertyBorderLeftStyle, CSSPropertyBorderLeftWidth }
+    };
+    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderLonghands, (CSSPropertyBorder, borderProperties[0], sizeof(borderProperties) / sizeof(borderProperties[0][0])));
+    return borderLonghands;
+}
+
+const StylePropertyShorthand& borderShorthandForParsing()
+{
+    static const CSSPropertyID borderShorthandProperties[] = { CSSPropertyBorderWidth, CSSPropertyBorderStyle, CSSPropertyBorderColor };
+    static const StylePropertyShorthand* propertiesForInitialization[] = {
+        &borderWidthShorthand(),
+        &borderStyleShorthand(),
+        &borderColorShorthand(),
+    };
+    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderForParsingLonghands, (CSSPropertyBorder, borderShorthandProperties, propertiesForInitialization, WTF_ARRAY_LENGTH(borderShorthandProperties)));
+    return borderForParsingLonghands;
+}
+
+const StylePropertyShorthand& webkitAnimationShorthandForParsing()
+{
+    // When we parse the animation shorthand we need to look for animation-name
+    // last because otherwise it might match against the keywords for fill mode,
+    // timing functions and infinite iteration. This means that animation names
+    // that are the same as keywords (e.g. 'forwards') won't always match in the
+    // shorthand. In that case the authors should be using longhands (or
+    // reconsidering their approach). This is covered by the animations spec
+    // bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=14790
+    // And in the spec (editor's draft) at:
+    // http://dev.w3.org/csswg/css3-animations/#animation-shorthand-property
+    static const CSSPropertyID animationPropertiesForParsing[] = {
+        CSSPropertyWebkitAnimationDuration,
+        CSSPropertyWebkitAnimationTimingFunction,
+        CSSPropertyWebkitAnimationDelay,
+        CSSPropertyWebkitAnimationIterationCount,
+        CSSPropertyWebkitAnimationDirection,
+        CSSPropertyWebkitAnimationFillMode,
+        CSSPropertyWebkitAnimationName
+    };
+    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitAnimationLonghandsForParsing, (CSSPropertyWebkitAnimation, animationPropertiesForParsing, WTF_ARRAY_LENGTH(animationPropertiesForParsing)));
+    return webkitAnimationLonghandsForParsing;
+}
+
+bool isExpandedShorthand(CSSPropertyID id)
+{
+    // The system fonts bypass the normal style resolution by using RenderTheme,
+    // thus we need to special case it here. FIXME: This is a violation of CSS 3 Fonts
+    // as we should still be able to change the longhands.
+    // DON'T ADD ANY SHORTHAND HERE UNLESS IT ISN'T ALWAYS EXPANDED AT PARSE TIME (which is wrong).
+    if (id == CSSPropertyFont)
+        return false;
+
+    return shorthandForProperty(id).length();
+}
+
+unsigned indexOfShorthandForLonghand(CSSPropertyID shorthandID, const Vector<StylePropertyShorthand>& shorthands)
+{
+    for (unsigned i = 0; i < shorthands.size(); ++i) {
+        if (shorthands.at(i).id() == shorthandID)
+            return i;
+    }
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
+} // namespace WebCore
diff --git a/Source/core/css/fullscreen.css b/Source/core/css/fullscreen.css
index ebf12f6..c7c2dcd 100644
--- a/Source/core/css/fullscreen.css
+++ b/Source/core/css/fullscreen.css
@@ -15,7 +15,7 @@
     -webkit-mask: none !important;
     clip: none !important;
     -webkit-filter: none !important;
-    -webkit-transition: none !important;
+    transition: none !important;
     -webkit-box-reflect: none !important;
     -webkit-perspective: none !important;
     -webkit-transform-style: flat !important;
diff --git a/Source/core/css/mediaControls.css b/Source/core/css/mediaControls.css
index 1e3b928..d31a0aa 100644
--- a/Source/core/css/mediaControls.css
+++ b/Source/core/css/mediaControls.css
@@ -367,7 +367,7 @@
 }
 
 video::-webkit-media-text-track-region-container.scrolling {
-    -webkit-transition: top 433ms linear;
+    transition: top 433ms linear;
 }
 
 
diff --git a/Source/core/css/resolver/FilterOperationResolver.cpp b/Source/core/css/resolver/FilterOperationResolver.cpp
index 70991ba..9a155d9 100644
--- a/Source/core/css/resolver/FilterOperationResolver.cpp
+++ b/Source/core/css/resolver/FilterOperationResolver.cpp
@@ -29,7 +29,6 @@
 #include "config.h"
 #include "core/css/resolver/FilterOperationResolver.h"
 
-
 #include "core/css/CSSFilterValue.h"
 #include "core/css/CSSMixFunctionValue.h"
 #include "core/css/CSSParser.h"
@@ -53,7 +52,7 @@
 
 static Length convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
 {
-    return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
+    return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | FractionConversion>(style, rootStyle, multiplier) : Length(Undefined);
 }
 
 
diff --git a/Source/core/css/resolver/FontBuilder.h b/Source/core/css/resolver/FontBuilder.h
index 4e712ec..877fd8d 100644
--- a/Source/core/css/resolver/FontBuilder.h
+++ b/Source/core/css/resolver/FontBuilder.h
@@ -31,9 +31,7 @@
 namespace WebCore {
 
 class CSSValue;
-class FontDescription;
 class FontSelector;
-class FontSize;
 class RenderStyle;
 
 class FontDescriptionChangeScope;
diff --git a/Source/core/css/resolver/ScopedStyleResolver.h b/Source/core/css/resolver/ScopedStyleResolver.h
index 7a28798..57d503e 100644
--- a/Source/core/css/resolver/ScopedStyleResolver.h
+++ b/Source/core/css/resolver/ScopedStyleResolver.h
@@ -29,19 +29,19 @@
 
 #include "core/css/CSSKeyframesRule.h"
 #include "core/css/RuleSet.h"
-#include "core/css/SiblingTraversalStrategies.h"
+#include "core/dom/ContainerNode.h"
+#include "core/dom/Element.h"
 #include "wtf/Forward.h"
 #include "wtf/HashMap.h"
 #include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
 #include "wtf/Vector.h"
 
 namespace WebCore {
 
-class ContainerNode;
 class ElementRuleCollector;
 class MediaQueryEvaluator;
 class PageRuleCollector;
-class ScopedStyleResolver;
 class ShadowRoot;
 class StyleSheetContents;
 
diff --git a/Source/core/css/resolver/SharedStyleFinder.cpp b/Source/core/css/resolver/SharedStyleFinder.cpp
index c376ba5..074596b 100644
--- a/Source/core/css/resolver/SharedStyleFinder.cpp
+++ b/Source/core/css/resolver/SharedStyleFinder.cpp
@@ -29,74 +29,28 @@
 #include "config.h"
 #include "core/css/resolver/SharedStyleFinder.h"
 
-// FIXME: This include list is way more than we need!
-#include "CSSPropertyNames.h"
 #include "HTMLNames.h"
-#include "RuntimeEnabledFeatures.h"
-#include "SVGNames.h"
 #include "XMLNames.h"
-#include "core/animation/AnimatableValue.h"
-#include "core/animation/Animation.h"
-#include "core/css/CSSCalculationValue.h"
-#include "core/css/CSSCursorImageValue.h"
-#include "core/css/CSSDefaultStyleSheets.h"
-#include "core/css/CSSFontSelector.h"
-#include "core/css/CSSImageSetValue.h"
-#include "core/css/CSSKeyframeRule.h"
-#include "core/css/CSSKeyframesRule.h"
-#include "core/css/CSSLineBoxContainValue.h"
-#include "core/css/CSSParser.h"
-#include "core/css/CSSPrimitiveValueMappings.h"
-#include "core/css/CSSReflectValue.h"
-#include "core/css/CSSSVGDocumentValue.h"
-#include "core/css/CSSSelector.h"
-#include "core/css/CSSSelectorList.h"
-#include "core/css/CSSStyleRule.h"
-#include "core/css/CSSValueList.h"
-#include "core/css/CSSVariableValue.h"
-#include "core/css/MediaQueryEvaluator.h"
-#include "core/css/PageRuleCollector.h"
-#include "core/css/Pair.h"
-#include "core/css/RuleSet.h"
-#include "core/css/StylePropertySet.h"
-#include "core/css/StylePropertyShorthand.h"
-#include "core/css/StyleSheetContents.h"
+#include "core/css/RuleFeature.h"
 #include "core/css/resolver/StyleResolver.h"
-#include "core/dom/DocumentStyleSheetCollection.h"
+#include "core/css/resolver/StyleResolverState.h"
+#include "core/dom/ContainerNode.h"
+#include "core/dom/Document.h"
+#include "core/dom/Element.h"
 #include "core/dom/FullscreenController.h"
+#include "core/dom/Node.h"
 #include "core/dom/NodeRenderStyle.h"
-#include "core/dom/NodeRenderingContext.h"
-#include "core/dom/Text.h"
-#include "core/dom/shadow/ShadowRoot.h"
-#include "core/html/HTMLIFrameElement.h"
+#include "core/dom/NodeTraversal.h"
+#include "core/dom/QualifiedName.h"
+#include "core/dom/SpaceSplitString.h"
+#include "core/html/HTMLElement.h"
 #include "core/html/HTMLInputElement.h"
 #include "core/html/HTMLOptGroupElement.h"
-#include "core/html/HTMLTableElement.h"
 #include "core/html/track/WebVTTElement.h"
-#include "core/inspector/InspectorInstrumentation.h"
-#include "core/page/Frame.h"
-#include "core/page/FrameView.h"
-#include "core/page/Page.h"
-#include "core/page/Settings.h"
-#include "core/platform/LinkHash.h"
-#include "core/platform/graphics/filters/custom/CustomFilterConstants.h"
-#include "core/platform/text/LocaleToScriptMapping.h"
-#include "core/rendering/RenderTheme.h"
-#include "core/rendering/RenderView.h"
-#include "core/rendering/style/ContentData.h"
-#include "core/rendering/style/CursorList.h"
-#include "core/rendering/style/KeyframeList.h"
-#include "core/rendering/style/RenderStyleConstants.h"
-#include "core/rendering/style/StyleCachedImage.h"
-#include "core/rendering/style/StyleCachedImageSet.h"
-#include "core/rendering/style/StyleCustomFilterProgramCache.h"
-#include "core/rendering/style/StyleGeneratedImage.h"
-#include "core/svg/SVGDocumentExtensions.h"
+#include "core/rendering/style/RenderStyle.h"
 #include "core/svg/SVGElement.h"
-#include "core/svg/SVGFontFaceElement.h"
-#include "wtf/StdLibExtras.h"
-#include "wtf/Vector.h"
-
+#include "wtf/HashSet.h"
+#include "wtf/text/AtomicString.h"
 
 namespace WebCore {
 
@@ -354,8 +308,20 @@
     return toElement(node);
 }
 
+#ifdef STYLE_STATS
+Element* SharedStyleFinder::searchDocumentForSharedStyle(const ElementResolveContext& context) const
+{
+    for (Element* element = context.element()->document()->documentElement(); element; element = ElementTraversal::next(element)) {
+        if (canShareStyleWithElement(context, element))
+            return element;
+    }
+    return 0;
+}
+#endif
+
 RenderStyle* SharedStyleFinder::locateSharedStyle(const ElementResolveContext& context)
 {
+    STYLE_STATS_ADD_SEARCH();
     if (!context.element() || !context.element()->isStyledElement())
         return 0;
 
@@ -392,6 +358,8 @@
     if (context.element()->hasTagName(dialogTag))
         return 0;
 
+    STYLE_STATS_ADD_ELEMENT_ELIGIBLE_FOR_SHARING();
+
     // Cache whether context.element() is affected by any known class selectors.
     // FIXME: This should be an explicit out parameter, instead of a member variable.
     m_elementAffectedByClassRules = context.element() && context.element()->hasClass() && classNamesAffectedByRules(context.element()->classNames());
@@ -408,6 +376,19 @@
         cousinList = locateCousinList(cousinList->parentElement(), visitedNodeCount);
     }
 
+#ifdef STYLE_STATS
+    // FIXME: these stats don't to into account whether or not sibling/attribute
+    // rules prevent these nodes from actually sharing
+    if (shareElement) {
+        STYLE_STATS_ADD_SEARCH_FOUND_SIBLING_FOR_SHARING();
+    } else {
+        shareElement = searchDocumentForSharedStyle(context);
+        if (shareElement)
+            STYLE_STATS_ADD_SEARCH_MISSED_SHARING();
+        shareElement = 0;
+    }
+#endif
+
     // If we have exhausted all our budget or our cousins.
     if (!shareElement)
         return 0;
@@ -421,6 +402,7 @@
     // Tracking child index requires unique style for each node. This may get set by the sibling rule match above.
     if (parentElementPreventsSharing(context.element()->parentElement()))
         return 0;
+    STYLE_STATS_ADD_STYLE_SHARED();
     return shareElement->renderStyle();
 }
 
diff --git a/Source/core/css/resolver/SharedStyleFinder.h b/Source/core/css/resolver/SharedStyleFinder.h
index bed6369..590cac4 100644
--- a/Source/core/css/resolver/SharedStyleFinder.h
+++ b/Source/core/css/resolver/SharedStyleFinder.h
@@ -54,6 +54,9 @@
     Node* locateCousinList(Element* parent, unsigned& visitedNodeCount) const;
     Element* findSiblingForStyleSharing(const ElementResolveContext&, Node*, unsigned& count) const;
 
+    // Only used when we're collecting stats on styles
+    Element* searchDocumentForSharedStyle(const ElementResolveContext&) const;
+
     bool classNamesAffectedByRules(const SpaceSplitString&) const;
 
     bool canShareStyleWithElement(const ElementResolveContext&, Element*) const;
diff --git a/Source/core/css/resolver/StyleAdjuster.cpp b/Source/core/css/resolver/StyleAdjuster.cpp
index 5be48db..a3792a9 100644
--- a/Source/core/css/resolver/StyleAdjuster.cpp
+++ b/Source/core/css/resolver/StyleAdjuster.cpp
@@ -29,73 +29,26 @@
 #include "config.h"
 #include "core/css/resolver/StyleAdjuster.h"
 
-// FIXME: This include list is way more than we need!
-#include "CSSPropertyNames.h"
 #include "HTMLNames.h"
-#include "RuntimeEnabledFeatures.h"
 #include "SVGNames.h"
-#include "XMLNames.h"
-#include "core/animation/AnimatableValue.h"
-#include "core/animation/Animation.h"
-#include "core/css/CSSCalculationValue.h"
-#include "core/css/CSSCursorImageValue.h"
-#include "core/css/CSSDefaultStyleSheets.h"
-#include "core/css/CSSFontSelector.h"
-#include "core/css/CSSImageSetValue.h"
-#include "core/css/CSSKeyframeRule.h"
-#include "core/css/CSSKeyframesRule.h"
-#include "core/css/CSSLineBoxContainValue.h"
-#include "core/css/CSSParser.h"
-#include "core/css/CSSPrimitiveValueMappings.h"
-#include "core/css/CSSReflectValue.h"
-#include "core/css/CSSSVGDocumentValue.h"
-#include "core/css/CSSSelector.h"
-#include "core/css/CSSSelectorList.h"
-#include "core/css/CSSStyleRule.h"
-#include "core/css/CSSValueList.h"
-#include "core/css/CSSVariableValue.h"
-#include "core/css/Pair.h"
-#include "core/css/RuleSet.h"
-#include "core/css/StylePropertySet.h"
-#include "core/css/StylePropertyShorthand.h"
-#include "core/css/StyleSheetContents.h"
-#include "core/css/resolver/StyleResolver.h"
-#include "core/dom/DocumentStyleSheetCollection.h"
-#include "core/dom/FullscreenController.h"
-#include "core/dom/NodeRenderStyle.h"
-#include "core/dom/NodeRenderingContext.h"
-#include "core/dom/Text.h"
-#include "core/dom/shadow/ShadowRoot.h"
+#include "core/dom/ContainerNode.h"
+#include "core/dom/Document.h"
+#include "core/dom/Element.h"
 #include "core/html/HTMLHtmlElement.h"
 #include "core/html/HTMLIFrameElement.h"
 #include "core/html/HTMLInputElement.h"
-#include "core/html/HTMLOptGroupElement.h"
 #include "core/html/HTMLTableElement.h"
 #include "core/html/HTMLTextAreaElement.h"
-#include "core/html/track/WebVTTElement.h"
-#include "core/page/Frame.h"
 #include "core/page/FrameView.h"
 #include "core/page/Page.h"
 #include "core/page/Settings.h"
-#include "core/platform/LinkHash.h"
-#include "core/platform/graphics/filters/custom/CustomFilterConstants.h"
+#include "core/platform/Length.h"
+#include "core/rendering/Pagination.h"
 #include "core/rendering/RenderTheme.h"
-#include "core/rendering/RenderView.h"
-#include "core/rendering/style/ContentData.h"
-#include "core/rendering/style/CursorList.h"
-#include "core/rendering/style/KeyframeList.h"
+#include "core/rendering/style/GridPosition.h"
 #include "core/rendering/style/RenderStyle.h"
 #include "core/rendering/style/RenderStyleConstants.h"
-#include "core/rendering/style/StyleCachedImage.h"
-#include "core/rendering/style/StyleCachedImageSet.h"
-#include "core/rendering/style/StyleCustomFilterProgramCache.h"
-#include "core/rendering/style/StyleGeneratedImage.h"
-#include "core/svg/SVGDocumentExtensions.h"
-#include "core/svg/SVGElement.h"
-#include "core/svg/SVGFontFaceElement.h"
-#include "wtf/StdLibExtras.h"
-#include "wtf/Vector.h"
-
+#include "wtf/Assertions.h"
 
 namespace WebCore {
 
diff --git a/Source/core/css/resolver/StyleAdjuster.h b/Source/core/css/resolver/StyleAdjuster.h
index e9fba10..25b9411 100644
--- a/Source/core/css/resolver/StyleAdjuster.h
+++ b/Source/core/css/resolver/StyleAdjuster.h
@@ -25,7 +25,6 @@
 namespace WebCore {
 
 class CachedUAStyle;
-class Document;
 class Element;
 class RenderStyle;
 
diff --git a/Source/core/css/resolver/StyleBuilderCustom.cpp b/Source/core/css/resolver/StyleBuilderCustom.cpp
index 5953642..c05f8a1 100644
--- a/Source/core/css/resolver/StyleBuilderCustom.cpp
+++ b/Source/core/css/resolver/StyleBuilderCustom.cpp
@@ -39,81 +39,43 @@
 #include "config.h"
 #include "core/css/resolver/StyleBuilder.h"
 
-// FIXME: This is way more than we need to include!
 #include "CSSPropertyNames.h"
 #include "CSSValueKeywords.h"
 #include "StyleBuilderFunctions.h"
-#include "core/animation/AnimatableValue.h"
-#include "core/animation/Animation.h"
+#include "StylePropertyShorthand.h"
 #include "core/css/BasicShapeFunctions.h"
 #include "core/css/CSSAspectRatioValue.h"
-#include "core/css/CSSCalculationValue.h"
 #include "core/css/CSSCursorImageValue.h"
-#include "core/css/CSSDefaultStyleSheets.h"
-#include "core/css/CSSFontSelector.h"
+#include "core/css/CSSGradientValue.h"
 #include "core/css/CSSImageSetValue.h"
-#include "core/css/CSSKeyframeRule.h"
-#include "core/css/CSSKeyframesRule.h"
 #include "core/css/CSSLineBoxContainValue.h"
-#include "core/css/CSSParser.h"
 #include "core/css/CSSPrimitiveValueMappings.h"
+#include "core/css/CSSProperty.h"
 #include "core/css/CSSReflectValue.h"
-#include "core/css/CSSSVGDocumentValue.h"
-#include "core/css/CSSSelector.h"
-#include "core/css/CSSSelectorList.h"
-#include "core/css/CSSStyleRule.h"
-#include "core/css/CSSValueList.h"
 #include "core/css/CSSVariableValue.h"
 #include "core/css/Counter.h"
-#include "core/css/ElementRuleCollector.h"
-#include "core/css/FontFeatureValue.h"
-#include "core/css/FontSize.h"
 #include "core/css/FontValue.h"
-#include "core/css/MediaQueryEvaluator.h"
-#include "core/css/PageRuleCollector.h"
 #include "core/css/Pair.h"
 #include "core/css/Rect.h"
-#include "core/css/RuleSet.h"
 #include "core/css/ShadowValue.h"
-#include "core/css/StylePropertySet.h"
-#include "core/css/StylePropertyShorthand.h"
-#include "core/css/StyleSheetContents.h"
 #include "core/css/resolver/ElementStyleResources.h"
 #include "core/css/resolver/FilterOperationResolver.h"
+#include "core/css/resolver/FontBuilder.h"
 #include "core/css/resolver/StyleResolver.h"
 #include "core/css/resolver/StyleResolverState.h"
 #include "core/css/resolver/TransformBuilder.h"
-#include "core/css/resolver/ViewportStyleResolver.h"
-#include "core/dom/DocumentStyleSheetCollection.h"
-#include "core/dom/Text.h"
-#include "core/dom/shadow/ShadowRoot.h"
 #include "core/page/Frame.h"
-#include "core/page/FrameView.h"
-#include "core/page/Page.h"
 #include "core/page/Settings.h"
-#include "core/platform/LinkHash.h"
 #include "core/platform/graphics/FontDescription.h"
-#include "core/platform/graphics/filters/custom/CustomFilterConstants.h"
-#include "core/platform/text/LocaleToScriptMapping.h"
-#include "core/rendering/RenderTheme.h"
-#include "core/rendering/RenderView.h"
-#include "core/rendering/style/ContentData.h"
 #include "core/rendering/style/CounterContent.h"
 #include "core/rendering/style/CursorList.h"
-#include "core/rendering/style/KeyframeList.h"
 #include "core/rendering/style/QuotesData.h"
 #include "core/rendering/style/RenderStyle.h"
 #include "core/rendering/style/RenderStyleConstants.h"
 #include "core/rendering/style/SVGRenderStyle.h"
 #include "core/rendering/style/SVGRenderStyleDefs.h"
 #include "core/rendering/style/ShadowData.h"
-#include "core/rendering/style/StyleCachedImage.h"
-#include "core/rendering/style/StyleCachedImageSet.h"
-#include "core/rendering/style/StyleCustomFilterProgramCache.h"
 #include "core/rendering/style/StyleGeneratedImage.h"
-#include "core/rendering/style/StylePendingImage.h"
-#include "core/rendering/style/StylePendingShader.h"
-#include "core/rendering/style/StyleShader.h"
 #include "core/svg/SVGColor.h"
 #include "core/svg/SVGPaint.h"
 #include "core/svg/SVGURIReference.h"
@@ -121,7 +83,6 @@
 #include "wtf/StdLibExtras.h"
 #include "wtf/Vector.h"
 
-
 namespace WebCore {
 
 static Length clipConvertToLength(StyleResolverState& state, CSSPrimitiveValue* value)
@@ -572,7 +533,7 @@
 
     CSSValueList* valueList = toCSSValueList(value);
     CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->itemWithoutBoundsCheck(0));
-    Length lengthOrPercentageValue = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom());
+    Length lengthOrPercentageValue = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom());
     ASSERT(!lengthOrPercentageValue.isUndefined());
     state.style()->setTextIndent(lengthOrPercentageValue);
 
@@ -598,7 +559,7 @@
     if (primitiveValue->getValueID())
         return state.style()->setVerticalAlign(*primitiveValue);
 
-    state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()));
+    state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()));
 }
 
 static void resetEffectiveZoom(StyleResolverState& state)
@@ -726,7 +687,7 @@
             break;
         }
     } else {
-        Length marqueeLength = primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(state.style(), state.rootElementStyle()) : Length(Undefined);
+        Length marqueeLength = primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion>(state.style(), state.rootElementStyle()) : Length(Undefined);
         if (!marqueeLength.isUndefined())
             state.style()->setMarqueeIncrement(marqueeLength);
     }
@@ -904,7 +865,7 @@
         return true;
     }
 
-    workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom());
+    workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom());
     if (workingLength.length().isUndefined())
         return false;
 
@@ -1215,36 +1176,17 @@
         return;
     // Shorthand properties.
     case CSSPropertyFont:
-        // Short-hand properties are expanded by the parser and normally
-        // do not go through applyProperty() at all. CSSPropertyFont
-        // is special as system font names are sent through here.
-        // FIXME: Unclear why this special casing is handled this way.
-        // See isExpandedShorthand for more comments.
+        // Only System Font identifiers should come through this method
+        // all other values should have been handled when the shorthand
+        // was expanded by the parser.
+        // FIXME: System Font identifiers should not hijack this
+        // short-hand CSSProperty like this.
         ASSERT(!isInitial);
         ASSERT(!isInherit);
-        if (primitiveValue) {
-            state.style()->setLineHeight(RenderStyle::initialLineHeight());
-            state.setLineHeightValue(0);
-            state.fontBuilder().fromSystemFont(primitiveValue->getValueID(), state.style()->effectiveZoom());
-        } else if (value->isFontValue()) {
-            FontValue* font = static_cast<FontValue*>(value);
-            if (!font->style || !font->variant || !font->weight
-                || !font->size || !font->lineHeight || !font->family)
-                return;
-            styleResolver->applyProperty(CSSPropertyFontStyle, font->style.get());
-            styleResolver->applyProperty(CSSPropertyFontVariant, font->variant.get());
-            styleResolver->applyProperty(CSSPropertyFontWeight, font->weight.get());
-            // The previous properties can dirty our font but they don't try to read the font's
-            // properties back, which is safe. However if font-size is using the 'ex' unit, it will
-            // need query the dirtied font's x-height to get the computed size. To be safe in this
-            // case, let's just update the font now.
-            styleResolver->updateFont();
-            styleResolver->applyProperty(CSSPropertyFontSize, font->size.get());
-
-            state.setLineHeightValue(font->lineHeight.get());
-
-            styleResolver->applyProperty(CSSPropertyFontFamily, font->family.get());
-        }
+        ASSERT(primitiveValue);
+        state.style()->setLineHeight(RenderStyle::initialLineHeight());
+        state.setLineHeightValue(0);
+        state.fontBuilder().fromSystemFont(primitiveValue->getValueID(), state.style()->effectiveZoom());
         return;
     case CSSPropertyBackground:
     case CSSPropertyBackgroundPosition:
@@ -1347,7 +1289,7 @@
         RefPtr<StyleReflection> reflection = StyleReflection::create();
         reflection->setDirection(*reflectValue->direction());
         if (reflectValue->offset())
-            reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(state.style(), state.rootElementStyle(), zoomFactor));
+            reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion>(state.style(), state.rootElementStyle(), zoomFactor));
         NinePieceImage mask;
         mask.setMaskDefaults();
         state.styleMap().mapNinePieceImage(id, reflectValue->mask(), mask);
diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp
index 96c05c7..e27626d 100644
--- a/Source/core/css/resolver/StyleResolver.cpp
+++ b/Source/core/css/resolver/StyleResolver.cpp
@@ -29,43 +29,29 @@
 #include "config.h"
 #include "core/css/resolver/StyleResolver.h"
 
-// FIXME: This include list is way more than we need!
 #include "CSSPropertyNames.h"
 #include "HTMLNames.h"
 #include "RuntimeEnabledFeatures.h"
-#include "SVGNames.h"
-#include "XMLNames.h"
+#include "StylePropertyShorthand.h"
 #include "core/animation/AnimatableValue.h"
 #include "core/animation/Animation.h"
 #include "core/css/CSSCalculationValue.h"
-#include "core/css/CSSCursorImageValue.h"
 #include "core/css/CSSDefaultStyleSheets.h"
 #include "core/css/CSSFontSelector.h"
-#include "core/css/CSSImageSetValue.h"
 #include "core/css/CSSKeyframeRule.h"
 #include "core/css/CSSKeyframesRule.h"
-#include "core/css/CSSLineBoxContainValue.h"
 #include "core/css/CSSParser.h"
-#include "core/css/CSSPrimitiveValueMappings.h"
 #include "core/css/CSSReflectValue.h"
-#include "core/css/CSSSVGDocumentValue.h"
+#include "core/css/CSSRuleList.h"
 #include "core/css/CSSSelector.h"
-#include "core/css/CSSSelectorList.h"
 #include "core/css/CSSStyleRule.h"
 #include "core/css/CSSValueList.h"
 #include "core/css/CSSVariableValue.h"
 #include "core/css/ElementRuleCollector.h"
-#include "core/css/FontFeatureValue.h"
-#include "core/css/FontSize.h"
 #include "core/css/MediaQueryEvaluator.h"
 #include "core/css/PageRuleCollector.h"
-#include "core/css/Pair.h"
 #include "core/css/RuleSet.h"
 #include "core/css/StylePropertySet.h"
-#include "core/css/StylePropertyShorthand.h"
-#include "core/css/StyleSheetContents.h"
-#include "core/css/resolver/ElementStyleResources.h"
-#include "core/css/resolver/FilterOperationResolver.h"
 #include "core/css/resolver/MatchResult.h"
 #include "core/css/resolver/MediaQueryResult.h"
 #include "core/css/resolver/SharedStyleFinder.h"
@@ -73,22 +59,14 @@
 #include "core/css/resolver/StyleBuilder.h"
 #include "core/css/resolver/ViewportStyleResolver.h"
 #include "core/dom/DocumentStyleSheetCollection.h"
-#include "core/dom/FullscreenController.h"
 #include "core/dom/NodeRenderStyle.h"
 #include "core/dom/NodeRenderingContext.h"
 #include "core/dom/Text.h"
 #include "core/dom/shadow/ShadowRoot.h"
-#include "core/html/HTMLHtmlElement.h"
 #include "core/html/HTMLIFrameElement.h"
 #include "core/inspector/InspectorInstrumentation.h"
-#include "core/loader/cache/CachedDocument.h"
-#include "core/loader/cache/CachedSVGDocumentReference.h"
 #include "core/page/Frame.h"
 #include "core/page/FrameView.h"
-#include "core/page/Page.h"
-#include "core/page/Settings.h"
-#include "core/platform/graphics/filters/custom/CustomFilterConstants.h"
-#include "core/platform/text/LocaleToScriptMapping.h"
 #include "core/rendering/RenderView.h"
 #include "core/rendering/style/KeyframeList.h"
 #include "core/rendering/style/StyleCustomFilterProgramCache.h"
@@ -127,6 +105,7 @@
     , m_matchAuthorAndUserStyles(matchAuthorAndUserStyles)
     , m_fontSelector(CSSFontSelector::create(document))
     , m_viewportStyleResolver(ViewportStyleResolver::create(document))
+    , m_state(0)
     , m_styleResourceLoader(document->cachedResourceLoader())
 {
     Element* root = document->documentElement();
@@ -335,7 +314,7 @@
 
 void StyleResolver::matchHostRules(ScopedStyleResolver* resolver, ElementRuleCollector& collector, bool includeEmptyRules)
 {
-    if (m_state.element() != resolver->scopingNode())
+    if (m_state->element() != resolver->scopingNode())
         return;
     resolver->matchHostRules(collector, includeEmptyRules);
 }
@@ -349,11 +328,11 @@
     }
 
     Vector<ScopedStyleResolver*, 8> stack;
-    m_styleTree.resolveScopedStyles(m_state.element(), stack);
+    m_styleTree.resolveScopedStyles(m_state->element(), stack);
     if (stack.isEmpty())
         return;
 
-    bool applyAuthorStyles = m_state.element()->treeScope()->applyAuthorStyles();
+    bool applyAuthorStyles = m_state->element()->treeScope()->applyAuthorStyles();
     for (int i = stack.size() - 1; i >= 0; --i)
         stack.at(i)->matchAuthorRules(collector, includeEmptyRules, applyAuthorStyles);
 
@@ -425,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 (m_state->element()->isStyledElement()) {
+        collector.addElementStyleProperties(m_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(m_state->element()->additionalPresentationAttributeStyle());
 
-        if (m_state.element()->isHTMLElement()) {
+        if (m_state->element()->isHTMLElement()) {
             bool isAuto;
-            TextDirection textDirection = toHTMLElement(m_state.element())->directionalityIfhasDirAutoAttribute(isAuto);
+            TextDirection textDirection = toHTMLElement(m_state->element())->directionalityIfhasDirAutoAttribute(isAuto);
             if (isAuto)
                 collector.matchedResult().addMatchedProperties(textDirection == LTR ? leftToRightDeclaration() : rightToLeftDeclaration());
         }
@@ -445,21 +424,21 @@
     if (matchAuthorAndUserStyles)
         matchAuthorRules(collector, false);
 
-    if (m_state.element()->isStyledElement()) {
+    if (m_state->element()->isStyledElement()) {
         // Now check our inline style attribute.
-        if (matchAuthorAndUserStyles && m_state.element()->inlineStyle()) {
+        if (matchAuthorAndUserStyles && m_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 = !m_state->element()->inlineStyle()->isMutable() && !m_state->element()->isInShadowTree();
             // FIXME: Constify.
-            collector.addElementStyleProperties(m_state.element()->inlineStyle(), isInlineStyleCacheable);
+            collector.addElementStyleProperties(m_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 && m_state->element()->isSVGElement())
+            collector.addElementStyleProperties(toSVGElement(m_state->element())->animatedSMILStyleProperties(), false /* isCacheable */);
 
-        if (m_state.element()->hasActiveAnimations())
+        if (m_state->element()->hasActiveAnimations())
             collector.matchedResult().isCacheable = false;
     }
 }
@@ -469,50 +448,10 @@
     if (!ruleSet)
         return false;
 
-    ElementRuleCollector collector(context, m_selectorFilter, m_state.style(), m_inspectorCSSOMWrappers);
+    ElementRuleCollector collector(context, m_selectorFilter, m_state->style(), m_inspectorCSSOMWrappers);
     return collector.hasAnyMatchingRules(ruleSet);
 }
 
-static void setStylesForPaginationMode(Pagination::Mode paginationMode, RenderStyle* style)
-{
-    if (paginationMode == Pagination::Unpaginated)
-        return;
-
-    switch (paginationMode) {
-    case Pagination::LeftToRightPaginated:
-        style->setColumnAxis(HorizontalColumnAxis);
-        if (style->isHorizontalWritingMode())
-            style->setColumnProgression(style->isLeftToRightDirection() ? NormalColumnProgression : ReverseColumnProgression);
-        else
-            style->setColumnProgression(style->isFlippedBlocksWritingMode() ? ReverseColumnProgression : NormalColumnProgression);
-        break;
-    case Pagination::RightToLeftPaginated:
-        style->setColumnAxis(HorizontalColumnAxis);
-        if (style->isHorizontalWritingMode())
-            style->setColumnProgression(style->isLeftToRightDirection() ? ReverseColumnProgression : NormalColumnProgression);
-        else
-            style->setColumnProgression(style->isFlippedBlocksWritingMode() ? NormalColumnProgression : ReverseColumnProgression);
-        break;
-    case Pagination::TopToBottomPaginated:
-        style->setColumnAxis(VerticalColumnAxis);
-        if (style->isHorizontalWritingMode())
-            style->setColumnProgression(style->isFlippedBlocksWritingMode() ? ReverseColumnProgression : NormalColumnProgression);
-        else
-            style->setColumnProgression(style->isLeftToRightDirection() ? NormalColumnProgression : ReverseColumnProgression);
-        break;
-    case Pagination::BottomToTopPaginated:
-        style->setColumnAxis(VerticalColumnAxis);
-        if (style->isHorizontalWritingMode())
-            style->setColumnProgression(style->isFlippedBlocksWritingMode() ? NormalColumnProgression : ReverseColumnProgression);
-        else
-            style->setColumnProgression(style->isLeftToRightDirection() ? ReverseColumnProgression : NormalColumnProgression);
-        break;
-    case Pagination::Unpaginated:
-        ASSERT_NOT_REACHED();
-        break;
-    }
-}
-
 PassRefPtr<RenderStyle> StyleResolver::styleForDocument(const Document* document, CSSFontSelector* fontSelector)
 {
     const Frame* frame = document->frame();
@@ -618,8 +557,7 @@
 
     if (element == document()->documentElement())
         resetDirectionAndWritingModeOnDocument(document());
-    StyleResolverState& state = m_state;
-    StyleResolveScope resolveScope(&state, document(), element, defaultParent, regionForStyling);
+    StyleResolverState state(&m_state, document(), element, defaultParent, regionForStyling);
 
     if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoint() && state.parentStyle()) {
         SharedStyleFinder styleFinder(m_features, m_siblingRuleSet.get(), m_uncommonAttributeRuleSet.get(), this);
@@ -676,7 +614,7 @@
         applyMatchedProperties(collector.matchedResult(), element);
     }
     {
-        StyleAdjuster adjuster(m_state.cachedUAStyle(), m_document->inQuirksMode());
+        StyleAdjuster adjuster(m_state->cachedUAStyle(), m_document->inQuirksMode());
         adjuster.adjustRenderStyle(state.style(), state.parentStyle(), element);
     }
     document()->didAccessStyleResolver();
@@ -696,13 +634,12 @@
 
     if (e == document()->documentElement())
         resetDirectionAndWritingModeOnDocument(document());
-    StyleResolveScope resolveScope(&m_state, document(), e);
+    StyleResolverState state(&m_state, document(), e);
 
     MatchResult result;
     if (keyframe->properties())
         result.addMatchedProperties(keyframe->properties());
 
-    StyleResolverState& state = m_state;
     ASSERT(!state.style());
 
     // Create the style
@@ -838,8 +775,7 @@
 
     if (e == document()->documentElement())
         resetDirectionAndWritingModeOnDocument(document());
-    StyleResolverState& state = m_state;
-    StyleResolveScope resolveScope(&state, document(), e, parentStyle);
+    StyleResolverState state(&m_state, document(), e, parentStyle);
 
     if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) {
         state.setStyle(RenderStyle::create());
@@ -873,7 +809,7 @@
         applyMatchedProperties(collector.matchedResult(), e);
     }
     {
-        StyleAdjuster adjuster(m_state.cachedUAStyle(), m_document->inQuirksMode());
+        StyleAdjuster adjuster(m_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);
@@ -891,8 +827,7 @@
 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
 {
     resetDirectionAndWritingModeOnDocument(document());
-    StyleResolverState& state = m_state;
-    StyleResolveScope resolveScope(&state, document(), document()->documentElement()); // m_rootElementStyle will be set to the document style.
+    StyleResolverState state(&m_state, document(), document()->documentElement()); // m_rootElementStyle will be set to the document style.
 
     state.setStyle(RenderStyle::create());
     state.style()->inheritFrom(state.rootElementStyle());
@@ -959,13 +894,14 @@
 
 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement()
 {
-    m_state.setStyle(RenderStyle::create());
-    m_state.fontBuilder().initForStyleResolve(document(), m_state.style(), m_state.useSVGZoomRules());
-    m_state.style()->setLineHeight(RenderStyle::initialLineHeight());
-    m_state.setLineHeightValue(0);
-    m_state.fontBuilder().setInitial(m_state.style()->effectiveZoom());
-    m_state.style()->font().update(fontSelector());
-    return m_state.takeStyle();
+    StyleResolverState state(0, document(), 0);
+    state.setStyle(RenderStyle::create());
+    state.fontBuilder().initForStyleResolve(document(), state.style(), state.useSVGZoomRules());
+    state.style()->setLineHeight(RenderStyle::initialLineHeight());
+    state.setLineHeightValue(0);
+    state.fontBuilder().setInitial(state.style()->effectiveZoom());
+    state.style()->font().update(fontSelector());
+    return state.takeStyle();
 }
 
 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode)
@@ -1001,7 +937,7 @@
 
 void StyleResolver::updateFont()
 {
-    m_state.fontBuilder().createFont(m_fontSelector, m_state.parentStyle(), m_state.style());
+    m_state->fontBuilder().createFont(m_fontSelector, m_state->parentStyle(), m_state->style());
 }
 
 PassRefPtr<CSSRuleList> StyleResolver::styleRulesForElement(Element* e, unsigned rulesToInclude)
@@ -1016,9 +952,9 @@
 
     if (e == document()->documentElement())
         resetDirectionAndWritingModeOnDocument(document());
-    StyleResolveScope resolveScope(&m_state, document(), e);
+    StyleResolverState state(&m_state, document(), e);
 
-    ElementRuleCollector collector(m_state.elementContext(), m_selectorFilter, m_state.style(), m_inspectorCSSOMWrappers);
+    ElementRuleCollector collector(m_state->elementContext(), m_selectorFilter, m_state->style(), m_inspectorCSSOMWrappers);
     collector.setMode(SelectorChecker::CollectingRules);
     collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId));
 
@@ -1063,7 +999,7 @@
                 continue;
             RefPtr<CSSValue> value = iter->value->compositeOnto(AnimatableValue::neutralValue())->toCSSValue();
             if (pass == HighPriorityProperties && property == CSSPropertyLineHeight)
-                m_state.setLineHeightValue(value.get());
+                m_state->setLineHeightValue(value.get());
             else
                 applyProperty(property, value.get());
         }
@@ -1142,10 +1078,16 @@
     case CSSPropertyOutlineWidth:
     case CSSPropertyVisibility:
     case CSSPropertyWhiteSpace:
+    // FIXME: 'text-decoration' shorthand to be handled when available.
+    // See https://chromiumcodereview.appspot.com/19516002 for details.
     case CSSPropertyTextDecoration:
     case CSSPropertyTextShadow:
     case CSSPropertyBorderStyle:
         return true;
+    case CSSPropertyTextDecorationLine:
+    case CSSPropertyTextDecorationStyle:
+    case CSSPropertyTextDecorationColor:
+        return RuntimeEnabledFeatures::css3TextDecorationsEnabled();
     default:
         break;
     }
@@ -1181,7 +1123,7 @@
 template <StyleResolver::StyleApplicationPass pass>
 void StyleResolver::applyProperties(const StylePropertySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType)
 {
-    ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || m_state.regionForStyling());
+    ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || m_state->regionForStyling());
     InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), rule, this);
 
     unsigned propertyCount = properties->propertyCount();
@@ -1205,7 +1147,7 @@
         if (!isPropertyForPass<pass>(property))
             continue;
         if (pass == HighPriorityProperties && property == CSSPropertyLineHeight)
-            m_state.setLineHeightValue(current.value());
+            m_state->setLineHeightValue(current.value());
         else
             applyProperty(current.id(), current.value());
     }
@@ -1218,7 +1160,7 @@
     if (startIndex == -1)
         return;
 
-    StyleResolverState& state = m_state;
+    StyleResolverState& state = *m_state;
     if (state.style()->insideLink() != NotInsideLink) {
         for (int i = startIndex; i <= endIndex; ++i) {
             const MatchedProperties& matchedProperties = matchResult.matchedProperties[i];
@@ -1252,11 +1194,11 @@
 void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const Element* element)
 {
     ASSERT(element);
-    StyleResolverState& state = m_state;
+    StyleResolverState& state = *m_state;
     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, *m_state, matchResult))) {
         // 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.
@@ -1348,10 +1290,10 @@
 
 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, size_t count, RenderStyle* style)
 {
-    StyleResolveScope resolveScope(&m_state, document(), 0, style);
-    m_state.setStyle(style);
+    StyleResolverState state(&m_state, document(), 0, style);
+    state.setStyle(style);
 
-    m_state.fontBuilder().initForStyleResolve(document(), style, m_state.useSVGZoomRules());
+    state.fontBuilder().initForStyleResolve(document(), style, state.useSVGZoomRules());
 
     for (size_t i = 0; i < count; ++i) {
         if (properties[i].value) {
@@ -1399,7 +1341,7 @@
 
 void StyleResolver::resolveVariables(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(*m_state->style()->variables()));
 
     if (knownExpressions.contains(expression))
         return; // cycle detected.
@@ -1413,10 +1355,13 @@
 
     for (unsigned i = 0; i < resultSet->propertyCount(); i++) {
         StylePropertySet::PropertyReference property = resultSet->propertyAt(i);
-        if (property.id() != CSSPropertyVariable && hasVariableReference(property.value()))
+        if (property.id() != CSSPropertyVariable && hasVariableReference(property.value())) {
             resolveVariables(property.id(), property.value(), knownExpressions);
-        else
+        } else {
             applyProperty(property.id(), property.value());
+            // All properties become dependent on their parent style when they use variables.
+            m_state->style()->setHasExplicitlyInheritedProperties();
+        }
     }
 }
 
@@ -1431,7 +1376,7 @@
     // 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;
+    StyleResolverState& state = *m_state;
     bool isInherit = state.parentNode() && value->isInheritedValue();
     bool isInitial = value->isInitialValue() || (!state.parentNode() && value->isInheritedValue());
 
@@ -1452,7 +1397,7 @@
 
     if (id == CSSPropertyVariable) {
         ASSERT_WITH_SECURITY_IMPLICATION(value->isVariableValue());
-        CSSVariableValue* variable = static_cast<CSSVariableValue*>(value);
+        CSSVariableValue* variable = toCSSVariableValue(value);
         ASSERT(!variable->name().isEmpty());
         ASSERT(!variable->value().isEmpty());
         state.style()->setVariable(variable->name(), variable->value());
@@ -1481,4 +1426,31 @@
     return false;
 }
 
+#ifdef STYLE_STATS
+StyleSharingStats StyleResolver::m_styleSharingStats;
+
+static void printStyleStats(unsigned searches, unsigned elementsEligibleForSharing, unsigned stylesShared, unsigned searchFoundSiblingForSharing, unsigned searchesMissedSharing)
+{
+    double percentOfElementsSharingStyle = (stylesShared * 100.0) / searches;
+    double percentOfNodesEligibleForSharing = (elementsEligibleForSharing * 100.0) / searches;
+    double percentOfEligibleSharingRelativesFound = (searchFoundSiblingForSharing * 100.0) / searches;
+
+    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);
+
+}
+
+void StyleSharingStats::printStats() const
+{
+    fprintf(stderr, "--------------------------------------------------------------------------------\n");
+    fprintf(stderr, "This recalc style:\n");
+    printStyleStats(m_searches, m_elementsEligibleForSharing, m_stylesShared, m_searchFoundSiblingForSharing, m_searchesMissedSharing);
+
+    fprintf(stderr, "Total:\n");
+    printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalStylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing);
+    fprintf(stderr, "--------------------------------------------------------------------------------\n");
+}
+#endif
+
 } // namespace WebCore
diff --git a/Source/core/css/resolver/StyleResolver.h b/Source/core/css/resolver/StyleResolver.h
index 1cf4420..dc2f017 100644
--- a/Source/core/css/resolver/StyleResolver.h
+++ b/Source/core/css/resolver/StyleResolver.h
@@ -22,9 +22,6 @@
 #ifndef StyleResolver_h
 #define StyleResolver_h
 
-#include "RuntimeEnabledFeatures.h"
-#include "core/css/CSSRuleList.h"
-#include "core/css/CSSToStyleMap.h"
 #include "core/css/DocumentRuleSets.h"
 #include "core/css/InspectorCSSOMWrappers.h"
 #include "core/css/PseudoStyleRequest.h"
@@ -38,8 +35,6 @@
 #include "core/css/resolver/StyleBuilder.h"
 #include "core/css/resolver/StyleResolverState.h"
 #include "core/css/resolver/StyleResourceLoader.h"
-#include "core/css/resolver/ViewportStyleResolver.h"
-#include "core/rendering/style/RenderStyle.h"
 #include "wtf/HashMap.h"
 #include "wtf/HashSet.h"
 #include "wtf/RefPtr.h"
@@ -47,14 +42,7 @@
 
 namespace WebCore {
 
-class CSSCursorImageValue;
 class CSSFontSelector;
-class CSSImageGeneratorValue;
-class CSSImageSetValue;
-class CSSImageValue;
-class CSSPageRule;
-class CSSPrimitiveValue;
-class CSSProperty;
 class CSSRuleList;
 class CSSSelector;
 class CSSStyleSheet;
@@ -63,30 +51,20 @@
 class Document;
 class Element;
 class ElementRuleCollector;
-class Frame;
-class FrameView;
 class KeyframeList;
 class KeyframeValue;
 class MediaQueryEvaluator;
 class MediaQueryExp;
 class MediaQueryResult;
-class Node;
 class RenderRegion;
 class RuleData;
-class RuleSet;
 class Settings;
-class StyleImage;
 class StyleKeyframe;
-class StylePendingImage;
 class StylePropertySet;
 class StyleRule;
-class StyleRuleHost;
 class StyleRuleKeyframes;
 class StyleRulePage;
-class StyleRuleRegion;
-class StyleShader;
-class StyleSheet;
-class StyleSheetList;
+class ViewportStyleResolver;
 
 struct MatchResult;
 
@@ -104,6 +82,53 @@
     MatchOnlyUserAgentRules,
 };
 
+#undef STYLE_STATS
+
+#ifdef STYLE_STATS
+struct StyleSharingStats {
+    void addSearch() { ++m_searches; ++m_totalSearches; }
+    void addElementEligibleForSharing() { ++m_elementsEligibleForSharing; ++m_totalElementsEligibleForSharing; }
+    void addStyleShared() { ++m_stylesShared; ++m_totalStylesShared; }
+    void addSearchFoundSiblingForSharing() { ++m_searchFoundSiblingForSharing; ++m_totalSearchFoundSiblingForSharing; }
+    void addSearchMissedSharing() { ++m_searchesMissedSharing; ++m_totalSearchesMissedSharing; }
+
+    void clear()
+    {
+        m_searches = m_elementsEligibleForSharing = m_stylesShared = m_searchesMissedSharing = m_searchFoundSiblingForSharing = 0;
+    }
+
+    void printStats() const;
+
+    unsigned m_searches;
+    unsigned m_elementsEligibleForSharing;
+    unsigned m_stylesShared;
+    unsigned m_searchFoundSiblingForSharing;
+    unsigned m_searchesMissedSharing;
+
+    unsigned m_totalSearches;
+    unsigned m_totalElementsEligibleForSharing;
+    unsigned m_totalStylesShared;
+    unsigned m_totalSearchFoundSiblingForSharing;
+    unsigned m_totalSearchesMissedSharing;
+};
+
+#define STYLE_STATS_ADD_SEARCH() StyleResolver::styleSharingStats().addSearch();
+#define STYLE_STATS_ADD_ELEMENT_ELIGIBLE_FOR_SHARING() StyleResolver::styleSharingStats().addElementEligibleForSharing();
+#define STYLE_STATS_ADD_STYLE_SHARED() StyleResolver::styleSharingStats().addStyleShared();
+#define STYLE_STATS_ADD_SEARCH_FOUND_SIBLING_FOR_SHARING() StyleResolver::styleSharingStats().addSearchFoundSiblingForSharing();
+#define STYLE_STATS_ADD_SEARCH_MISSED_SHARING() StyleResolver::styleSharingStats().addSearchMissedSharing();
+#define STYLE_STATS_PRINT() StyleResolver::styleSharingStats().printStats();
+#define STYLE_STATS_CLEAR() StyleResolver::styleSharingStats().clear();
+#else
+#define STYLE_STATS_ADD_SEARCH() (void(0));
+#define STYLE_STATS_ADD_ELEMENT_ELIGIBLE_FOR_SHARING() (void(0));
+#define STYLE_STATS_ADD_STYLE_SHARED() (void(0));
+#define STYLE_STATS_ADD_SEARCH_FOUND_SIBLING_FOR_SHARING() (void(0));
+#define STYLE_STATS_ADD_SEARCH_MISSED_SHARING() (void(0));
+#define STYLE_STATS_PRINT() (void(0));
+#define STYLE_STATS_CLEAR() (void(0));
+#endif
+
 // FIXME: Move to separate file.
 class MatchRequest {
 public:
@@ -138,6 +163,9 @@
     StyleResolver(Document*, bool matchAuthorAndUserStyles);
     ~StyleResolver();
 
+    // FIXME: StyleResolver should not be keeping tree-walk state.
+    // These should move to some global tree-walk state, or should be contained in a
+    // TreeWalkContext or similar which is passed in to StyleResolver methods when available.
     // Using these during tree walk will allow style selector to optimize child and descendant selector lookups.
     void pushParentElement(Element*);
     void popParentElement(Element*);
@@ -157,6 +185,8 @@
 
     static PassRefPtr<RenderStyle> styleForDocument(const Document*, CSSFontSelector* = 0);
 
+    // FIXME: This only has 5 callers and should be removed. Callers should be explicit about
+    // their dependency on Document* instead of grabbing one through StyleResolver.
     Document* document() { return m_document; }
 
     // FIXME: It could be better to call m_ruleSets.appendAuthorStyleSheets() directly after we factor StyleRsolver further.
@@ -200,38 +230,42 @@
     // |properties| is an array with |count| elements.
     void applyPropertiesToStyle(const CSSPropertyValue* properties, size_t count, RenderStyle*);
 
-    // FIXME: This should probably go away, folded into FontBuilder.
-    void updateFont();
-
-    bool hasSelectorForId(const AtomicString&) const;
-    bool hasSelectorForClass(const AtomicString&) const;
-    bool hasSelectorForAttribute(const AtomicString&) const;
-
     CSSFontSelector* fontSelector() const { return m_fontSelector.get(); }
     ViewportStyleResolver* viewportStyleResolver() { return m_viewportStyleResolver.get(); }
 
+    // FIXME: This logic belongs in MediaQueryEvaluator.
     void addViewportDependentMediaQueryResult(const MediaQueryExp*, bool result);
     bool hasViewportDependentMediaQueries() const { return !m_viewportDependentMediaQueryResults.isEmpty(); }
     bool affectedByViewportChange() const;
 
+    // FIXME: This likely belongs on RuleSet.
     void addKeyframeStyle(PassRefPtr<StyleRuleKeyframes>);
 
+    // FIXME: Regions should not require special logic in StyleResolver.
     bool checkRegionStyle(Element* regionElement);
 
-    bool usesSiblingRules() const { return !m_features.siblingRules.isEmpty(); }
-    bool usesFirstLineRules() const { return m_features.usesFirstLineRules; }
-    bool usesBeforeAfterRules() const { return m_features.usesBeforeAfterRules; }
-
     // FIXME: Rename to reflect the purpose, like didChangeFontSize or something.
     void invalidateMatchedPropertiesCache();
 
+    // Exposed for RenderStyle::isStyleAvilable().
     static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable; }
 
+    // FIXME: StyleResolver should not have this member or method.
     InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWrappers; }
 
+    // Exposed for ScopedStyleResolver.
+    // FIXME: Likely belongs on viewportStyleResolver.
     void collectViewportRules(RuleSet*);
 
+    const RuleFeatureSet& ruleFeatureSet() const { return m_features; }
+
+#ifdef STYLE_STATS
+    ALWAYS_INLINE static StyleSharingStats& styleSharingStats() { return m_styleSharingStats; }
+#endif
 private:
+    // FIXME: This should probably go away, folded into FontBuilder.
+    void updateFont();
+
     void matchUARules(ElementRuleCollector&, RuleSet*);
     void matchAuthorRules(ElementRuleCollector&, bool includeEmptyRules);
     void matchShadowDistributedRules(ElementRuleCollector&, bool includeEmptyRules);
@@ -273,6 +307,7 @@
 
     DocumentRuleSets m_ruleSets;
 
+    // FIXME: This likely belongs on RuleSet.
     typedef HashMap<AtomicStringImpl*, RefPtr<StyleRuleKeyframes> > KeyframesRuleMap;
     KeyframesRuleMap m_keyframesRuleMap;
 
@@ -305,31 +340,17 @@
 
     InspectorCSSOMWrappers m_inspectorCSSOMWrappers;
 
-    StyleResolverState m_state;
+    StyleResolverState* m_state;
     StyleResourceLoader m_styleResourceLoader;
 
+#ifdef STYLE_STATS
+    static StyleSharingStats m_styleSharingStats;
+#endif
+
     friend void StyleBuilder::oldApplyProperty(CSSPropertyID, StyleResolver*, StyleResolverState&, CSSValue*, bool isInitial, bool isInherit);
 
 };
 
-inline bool StyleResolver::hasSelectorForAttribute(const AtomicString &attributeName) const
-{
-    ASSERT(!attributeName.isEmpty());
-    return m_features.attrsInRules.contains(attributeName.impl());
-}
-
-inline bool StyleResolver::hasSelectorForClass(const AtomicString& classValue) const
-{
-    ASSERT(!classValue.isEmpty());
-    return m_features.classesInRules.contains(classValue.impl());
-}
-
-inline bool StyleResolver::hasSelectorForId(const AtomicString& idValue) const
-{
-    ASSERT(!idValue.isEmpty());
-    return m_features.idsInRules.contains(idValue.impl());
-}
-
 inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regionElement)
 {
     if (!regionSelector || !regionElement)
diff --git a/Source/core/css/resolver/StyleResolverState.cpp b/Source/core/css/resolver/StyleResolverState.cpp
index 22abd10..4b5d25f 100644
--- a/Source/core/css/resolver/StyleResolverState.cpp
+++ b/Source/core/css/resolver/StyleResolverState.cpp
@@ -47,29 +47,16 @@
     m_rootElementStyle = documentElement && element != documentElement ? documentElement->renderStyle() : documentStyle;
 }
 
-StyleResolveScope::StyleResolveScope(StyleResolverState* state, const Document* document, Element* e, RenderStyle* parentStyle, RenderRegion* regionForStyling)
-    : m_state(state)
+StyleResolverState::StyleResolverState(StyleResolverState** thisPointer, 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)
 {
-    m_state->initForStyleResolve(document, e, parentStyle, regionForStyling);
-}
-
-StyleResolveScope::~StyleResolveScope()
-{
-    m_state->clear();
-}
-
-void StyleResolverState::clear()
-{
-    m_elementContext = ElementResolveContext();
-    m_style = 0;
-    m_parentStyle = 0;
-    m_regionForStyling = 0;
-    m_elementStyleResources.clear();
-    m_fontBuilder.clear();
-}
-
-void StyleResolverState::initForStyleResolve(const Document* newDocument, Element* newElement, RenderStyle* parentStyle, RenderRegion* regionForStyling)
-{
+    if (m_thisPointer)
+        *m_thisPointer = this;
     ASSERT(!element() || document() == newDocument);
     if (newElement)
         m_elementContext = ElementResolveContext(newElement);
@@ -98,4 +85,16 @@
         m_elementStyleResources.setDeviceScaleFactor(page->deviceScaleFactor());
 }
 
+StyleResolverState::~StyleResolverState()
+{
+    if (m_thisPointer)
+        *m_thisPointer = 0;
+    m_elementContext = ElementResolveContext();
+    m_style = 0;
+    m_parentStyle = 0;
+    m_regionForStyling = 0;
+    m_elementStyleResources.clear();
+    m_fontBuilder.clear();
+}
+
 } // namespace WebCore
diff --git a/Source/core/css/resolver/StyleResolverState.h b/Source/core/css/resolver/StyleResolverState.h
index c376448..0740fb7 100644
--- a/Source/core/css/resolver/StyleResolverState.h
+++ b/Source/core/css/resolver/StyleResolverState.h
@@ -29,11 +29,9 @@
 #include "core/css/resolver/ElementStyleResources.h"
 #include "core/css/resolver/FontBuilder.h"
 #include "core/dom/Element.h"
-#include "core/platform/graphics/Color.h"
 #include "core/rendering/style/CachedUAStyle.h"
 #include "core/rendering/style/RenderStyle.h"
 #include "core/rendering/style/StyleInheritedData.h"
-#include "wtf/HashMap.h"
 
 namespace WebCore {
 
@@ -74,25 +72,11 @@
     bool m_resetStyleInheritance;
 };
 
-// Initializes a StyleResolverState within a scope.
-class StyleResolveScope {
-public:
-    StyleResolveScope(StyleResolverState*, const Document*, Element*, RenderStyle* parentStyle = 0, RenderRegion* regionForStyling = 0);
-    ~StyleResolveScope();
-private:
-    StyleResolverState* m_state;
-};
-
 class StyleResolverState {
 WTF_MAKE_NONCOPYABLE(StyleResolverState);
 public:
-    StyleResolverState()
-    : m_regionForStyling(0)
-    , m_applyPropertyToRegularStyle(true)
-    , m_applyPropertyToVisitedLinkStyle(false)
-    , m_lineHeightValue(0)
-    , m_styleMap(*this, m_elementStyleResources)
-    { }
+    StyleResolverState(StyleResolverState**, const Document*, Element*, RenderStyle* parentStyle = 0, RenderRegion* regionForStyling = 0);
+    ~StyleResolverState();
 
     // These are all just pass-through methods to ElementResolveContext.
     Document* document() const { return m_elementContext.document(); }
@@ -166,9 +150,6 @@
 private:
     friend class StyleResolveScope;
 
-    void initForStyleResolve(const Document*, Element*, RenderStyle* parentStyle = 0, RenderRegion* regionForStyling = 0);
-    void clear();
-
     void initElement(Element*);
 
     ElementResolveContext m_elementContext;
@@ -198,6 +179,8 @@
     // 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 f4f1df6..bad03c4 100644
--- a/Source/core/css/resolver/TransformBuilder.cpp
+++ b/Source/core/css/resolver/TransformBuilder.cpp
@@ -53,7 +53,7 @@
 
 static Length convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
 {
-    return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
+    return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | FractionConversion>(style, rootStyle, multiplier) : Length(Undefined);
 }
 
 static TransformOperation::OperationType getTransformOperationType(CSSTransformValue::TransformOperationType type)
diff --git a/Source/core/css/resolver/TransformBuilder.h b/Source/core/css/resolver/TransformBuilder.h
index 8807205..5e5d111 100644
--- a/Source/core/css/resolver/TransformBuilder.h
+++ b/Source/core/css/resolver/TransformBuilder.h
@@ -36,8 +36,8 @@
 
 namespace WebCore {
 
-class RenderStyle;
 class CSSValue;
+class RenderStyle;
 
 class TransformBuilder {
     WTF_MAKE_NONCOPYABLE(TransformBuilder); WTF_MAKE_FAST_ALLOCATED;
diff --git a/Source/core/css/resolver/ViewportStyleResolver.cpp b/Source/core/css/resolver/ViewportStyleResolver.cpp
index 539cb0e..4480d7f 100644
--- a/Source/core/css/resolver/ViewportStyleResolver.cpp
+++ b/Source/core/css/resolver/ViewportStyleResolver.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -146,6 +146,8 @@
         return ViewportArguments::ValuePortrait;
     case CSSValueZoom:
         return defaultValue;
+    case CSSValueInternalExtendToZoom:
+        return ViewportArguments::ValueExtendToZoom;
     case CSSValueFixed:
         return 0;
     default:
diff --git a/Source/core/css/resolver/ViewportStyleResolver.h b/Source/core/css/resolver/ViewportStyleResolver.h
index a523bc5..9f86309 100644
--- a/Source/core/css/resolver/ViewportStyleResolver.h
+++ b/Source/core/css/resolver/ViewportStyleResolver.h
@@ -36,7 +36,6 @@
 
 namespace WebCore {
 
-class CSSPrimitiveValue;
 class Document;
 class MutableStylePropertySet;
 class StyleRuleViewport;
diff --git a/Source/core/dom/ChildNode.idl b/Source/core/dom/ChildNode.idl
index c5fdbba..80ba9f1 100644
--- a/Source/core/dom/ChildNode.idl
+++ b/Source/core/dom/ChildNode.idl
@@ -20,8 +20,10 @@
  * Boston, MA 02110-1301, USA.
  */
 
-[NoInterfaceObject]
-interface ChildNode {
+[
+    NoInterfaceObject,
+    LegacyImplementedInBaseClass
+] interface ChildNode {
     [PerWorldBindings] readonly attribute Element previousElementSibling;
     [PerWorldBindings] readonly attribute Element nextElementSibling;
     [RaisesException, DeliverCustomElementCallbacks] void remove();
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
index d58f224..0738935 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -466,7 +466,7 @@
 
     RefPtr<Node> child = oldChild;
 
-    document()->removeFocusedNodeOfSubtree(child.get());
+    document()->removeFocusedElementOfSubtree(child.get());
 
     if (FullscreenController* fullscreen = FullscreenController::fromIfExists(document()))
         fullscreen->removeFullScreenElementOfSubtree(child.get());
@@ -562,11 +562,11 @@
     // and remove... e.g. stop loading frames, fire unload events.
     willRemoveChildren(protect.get());
 
-    // Exclude this node when looking for removed focusedNode since only
+    // Exclude this node when looking for removed focusedElement since only
     // children will be removed.
     // This must be later than willRemvoeChildren, which might change focus
     // state of a child.
-    document()->removeFocusedNodeOfSubtree(this, true);
+    document()->removeFocusedElementOfSubtree(this, true);
 
     NodeVector removedChildren;
     {
diff --git a/Source/core/dom/CustomElementCallbackDispatcher.cpp b/Source/core/dom/CustomElementCallbackDispatcher.cpp
index 10db728..7904e73 100644
--- a/Source/core/dom/CustomElementCallbackDispatcher.cpp
+++ b/Source/core/dom/CustomElementCallbackDispatcher.cpp
@@ -47,49 +47,6 @@
     return instance;
 }
 
-void CustomElementCallbackDispatcher::enqueueAttributeChangedCallback(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, PassRefPtr<Element> element, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue)
-{
-    if (!callbacks->hasAttributeChangedCallback())
-        return;
-
-    CustomElementCallbackQueue* queue = scheduleInCurrentElementQueue(element);
-    queue->append(CustomElementCallbackInvocation::createAttributeChangedInvocation(callbacks, name, oldValue, newValue));
-}
-
-void CustomElementCallbackDispatcher::enqueueCreatedCallback(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, PassRefPtr<Element> element)
-{
-    if (!callbacks->hasCreatedCallback())
-        return;
-
-    CustomElementCallbackQueue* queue = createCallbackQueue(element);
-    queue->setOwner(currentElementQueue());
-
-    // The created callback is unique in being prepended to the front
-    // of the element queue
-    m_flattenedProcessingStack.insert(inCallbackDeliveryScope() ? s_elementQueueStart : /* skip null sentinel */ 1, queue);
-    ++s_elementQueueEnd;
-
-    queue->append(CustomElementCallbackInvocation::createInvocation(callbacks, CustomElementLifecycleCallbacks::Created));
-}
-
-void CustomElementCallbackDispatcher::enqueueEnteredDocumentCallback(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, PassRefPtr<Element> element)
-{
-    if (!callbacks->hasEnteredDocumentCallback())
-        return;
-
-    CustomElementCallbackQueue* queue = scheduleInCurrentElementQueue(element);
-    queue->append(CustomElementCallbackInvocation::createInvocation(callbacks, CustomElementLifecycleCallbacks::EnteredDocument));
-}
-
-void CustomElementCallbackDispatcher::enqueueLeftDocumentCallback(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, PassRefPtr<Element> element)
-{
-    if (!callbacks->hasLeftDocumentCallback())
-        return;
-
-    CustomElementCallbackQueue* queue = scheduleInCurrentElementQueue(element);
-    queue->append(CustomElementCallbackInvocation::createInvocation(callbacks, CustomElementLifecycleCallbacks::LeftDocument));
-}
-
 // Dispatches callbacks at microtask checkpoint.
 bool CustomElementCallbackDispatcher::dispatch()
 {
@@ -168,7 +125,7 @@
 // its owner is set to the element queue on the top of the processing
 // stack. Because callback queues are processed exhaustively, this
 // effectively moves the callback queue to the top of the stack.
-CustomElementCallbackQueue* CustomElementCallbackDispatcher::scheduleInCurrentElementQueue(PassRefPtr<Element> element)
+CustomElementCallbackQueue* CustomElementCallbackDispatcher::ensureInCurrentElementQueue(PassRefPtr<Element> element)
 {
     CustomElementCallbackQueue* queue = ensureCallbackQueue(element);
     bool isInCurrentQueue = queue->owner() == currentElementQueue();
@@ -180,4 +137,17 @@
     return queue;
 }
 
+CustomElementCallbackQueue* CustomElementCallbackDispatcher::createAtFrontOfCurrentElementQueue(PassRefPtr<Element> element)
+{
+    CustomElementCallbackQueue* queue = createCallbackQueue(element);
+    queue->setOwner(currentElementQueue());
+
+    // The created callback is unique in being prepended to the front
+    // of the element queue
+    m_flattenedProcessingStack.insert(inCallbackDeliveryScope() ? s_elementQueueStart : /* skip null sentinel */ 1, queue);
+    ++s_elementQueueEnd;
+
+    return queue;
+}
+
 } // namespace WebCore
diff --git a/Source/core/dom/CustomElementCallbackDispatcher.h b/Source/core/dom/CustomElementCallbackDispatcher.h
index 9b6f10d..4c44910 100644
--- a/Source/core/dom/CustomElementCallbackDispatcher.h
+++ b/Source/core/dom/CustomElementCallbackDispatcher.h
@@ -32,7 +32,6 @@
 #define CustomElementCallbackDispatcher_h
 
 #include "core/dom/CustomElementCallbackQueue.h"
-#include "core/dom/CustomElementLifecycleCallbacks.h"
 #include "core/dom/Element.h"
 #include "wtf/HashMap.h"
 #include "wtf/OwnPtr.h"
@@ -66,16 +65,17 @@
         size_t m_savedElementQueueStart;
     };
 
-    void enqueueAttributeChangedCallback(PassRefPtr<CustomElementLifecycleCallbacks>, PassRefPtr<Element>, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue);
-    void enqueueCreatedCallback(PassRefPtr<CustomElementLifecycleCallbacks>, PassRefPtr<Element>);
-    void enqueueEnteredDocumentCallback(PassRefPtr<CustomElementLifecycleCallbacks>, PassRefPtr<Element>);
-    void enqueueLeftDocumentCallback(PassRefPtr<CustomElementLifecycleCallbacks>, PassRefPtr<Element>);
-
     // Returns true if more work may have to be performed at the
     // checkpoint by this or other workers (for example, this work
     // invoked author scripts)
     bool dispatch();
 
+protected:
+    friend class CustomElementCallbackScheduler;
+
+    CustomElementCallbackQueue* createAtFrontOfCurrentElementQueue(PassRefPtr<Element>);
+    CustomElementCallbackQueue* ensureInCurrentElementQueue(PassRefPtr<Element>);
+
 private:
     CustomElementCallbackDispatcher()
     {
@@ -107,7 +107,6 @@
 
     CustomElementCallbackQueue* createCallbackQueue(PassRefPtr<Element>);
     CustomElementCallbackQueue* ensureCallbackQueue(PassRefPtr<Element>);
-    CustomElementCallbackQueue* scheduleInCurrentElementQueue(PassRefPtr<Element>);
 
     // The processing stack, flattened. Element queues lower in the
     // stack appear toward the head of the vector. The first element
diff --git a/Source/core/dom/CustomElementCallbackInvocation.cpp b/Source/core/dom/CustomElementCallbackInvocation.cpp
index 2d81c89..38ea76d 100644
--- a/Source/core/dom/CustomElementCallbackInvocation.cpp
+++ b/Source/core/dom/CustomElementCallbackInvocation.cpp
@@ -31,7 +31,8 @@
 #include "config.h"
 #include "core/dom/CustomElementCallbackInvocation.h"
 
-#include "core/dom/CustomElementCallbackDispatcher.h"
+#include "core/dom/CustomElementCallbackScheduler.h"
+#include "core/dom/Element.h"
 
 namespace WebCore {
 
@@ -49,7 +50,7 @@
 void CreatedInvocation::dispatch(Element* element)
 {
     if (element->inDocument())
-        CustomElementCallbackDispatcher::instance().enqueueEnteredDocumentCallback(callbacks(), element);
+        CustomElementCallbackScheduler::scheduleEnteredDocumentCallback(callbacks(), element);
     callbacks()->created(element);
 }
 
diff --git a/Source/core/dom/CustomElementCallbackScheduler.cpp b/Source/core/dom/CustomElementCallbackScheduler.cpp
new file mode 100644
index 0000000..4a95d2b
--- /dev/null
+++ b/Source/core/dom/CustomElementCallbackScheduler.cpp
@@ -0,0 +1,77 @@
+/*
+ * 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/CustomElementCallbackScheduler.h"
+
+#include "core/dom/CustomElementCallbackDispatcher.h"
+#include "core/dom/CustomElementCallbackQueue.h"
+#include "core/dom/CustomElementLifecycleCallbacks.h"
+#include "core/dom/Element.h"
+
+namespace WebCore {
+
+void CustomElementCallbackScheduler::scheduleAttributeChangedCallback(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, PassRefPtr<Element> element, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue)
+{
+    if (!callbacks->hasAttributeChangedCallback())
+        return;
+
+    CustomElementCallbackQueue* queue = CustomElementCallbackDispatcher::instance().ensureInCurrentElementQueue(element);
+    queue->append(CustomElementCallbackInvocation::createAttributeChangedInvocation(callbacks, name, oldValue, newValue));
+}
+
+void CustomElementCallbackScheduler::scheduleCreatedCallback(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, PassRefPtr<Element> element)
+{
+    if (!callbacks->hasCreatedCallback())
+        return;
+
+    CustomElementCallbackQueue* queue = CustomElementCallbackDispatcher::instance().createAtFrontOfCurrentElementQueue(element);
+    queue->append(CustomElementCallbackInvocation::createInvocation(callbacks, CustomElementLifecycleCallbacks::Created));
+}
+
+void CustomElementCallbackScheduler::scheduleEnteredDocumentCallback(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, PassRefPtr<Element> element)
+{
+    if (!callbacks->hasEnteredDocumentCallback())
+        return;
+
+    CustomElementCallbackQueue* queue = CustomElementCallbackDispatcher::instance().ensureInCurrentElementQueue(element);
+    queue->append(CustomElementCallbackInvocation::createInvocation(callbacks, CustomElementLifecycleCallbacks::EnteredDocument));
+}
+
+void CustomElementCallbackScheduler::scheduleLeftDocumentCallback(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, PassRefPtr<Element> element)
+{
+    if (!callbacks->hasLeftDocumentCallback())
+        return;
+
+    CustomElementCallbackQueue* queue = CustomElementCallbackDispatcher::instance().ensureInCurrentElementQueue(element);
+    queue->append(CustomElementCallbackInvocation::createInvocation(callbacks, CustomElementLifecycleCallbacks::LeftDocument));
+}
+
+} // namespace WebCore
diff --git a/Source/core/dom/CustomElementCallbackScheduler.h b/Source/core/dom/CustomElementCallbackScheduler.h
new file mode 100644
index 0000000..3f5194e
--- /dev/null
+++ b/Source/core/dom/CustomElementCallbackScheduler.h
@@ -0,0 +1,55 @@
+/*
+ * 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 CustomElementCallbackScheduler_h
+#define CustomElementCallbackScheduler_h
+
+#include "wtf/PassRefPtr.h"
+#include "wtf/text/AtomicString.h"
+
+namespace WebCore {
+
+class CustomElementLifecycleCallbacks;
+class Element;
+
+class CustomElementCallbackScheduler {
+public:
+    static void scheduleAttributeChangedCallback(PassRefPtr<CustomElementLifecycleCallbacks>, PassRefPtr<Element>, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue);
+    static void scheduleCreatedCallback(PassRefPtr<CustomElementLifecycleCallbacks>, PassRefPtr<Element>);
+    static void scheduleEnteredDocumentCallback(PassRefPtr<CustomElementLifecycleCallbacks>, PassRefPtr<Element>);
+    static void scheduleLeftDocumentCallback(PassRefPtr<CustomElementLifecycleCallbacks>, PassRefPtr<Element>);
+
+private:
+    CustomElementCallbackScheduler();
+};
+
+}
+
+#endif // CustomElementCallbackScheduler_h
diff --git a/Source/core/dom/CustomElementRegistrationContext.cpp b/Source/core/dom/CustomElementRegistrationContext.cpp
index 57b43b6..4ed6abf 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/CustomElementCallbackDispatcher.h"
+#include "core/dom/CustomElementCallbackScheduler.h"
 #include "core/dom/CustomElementDefinition.h"
 #include "core/dom/CustomElementRegistry.h"
 #include "core/dom/CustomElementUpgradeCandidateMap.h"
@@ -145,7 +145,6 @@
         return Element::create(tagName, document);
     }
 
-    element->setIsCustomElement();
     resolve(element.get());
     return element.release();
 }
@@ -157,8 +156,6 @@
 
 void ActiveRegistrationContext::resolve(Element* element)
 {
-    ASSERT(element->isCustomElement());
-    ASSERT(!element->isUpgradedCustomElement());
     const CustomElementDescriptor& descriptor = describe(element);
     CustomElementDefinition* definition = m_registry.find(descriptor);
     if (definition)
@@ -169,16 +166,19 @@
 
 void ActiveRegistrationContext::didResolveElement(CustomElementDefinition* definition, Element* element)
 {
-    CustomElementCallbackDispatcher::instance().enqueueCreatedCallback(definition->callbacks(), element);
+    element->setCustomElementState(Element::Defined);
+    CustomElementCallbackScheduler::scheduleCreatedCallback(definition->callbacks(), element);
 }
 
 void ActiveRegistrationContext::didCreateUnresolvedElement(const CustomElementDescriptor& descriptor, Element* element)
 {
+    element->setCustomElementState(Element::UpgradeCandidate);
     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);
@@ -186,29 +186,29 @@
 
 void ActiveRegistrationContext::customElementAttributeDidChange(Element* element, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue)
 {
-    ASSERT(element->isUpgradedCustomElement());
+    ASSERT(element->customElementState() == Element::Upgraded);
     CustomElementDefinition* definition = definitionFor(element);
-    CustomElementCallbackDispatcher::instance().enqueueAttributeChangedCallback(definition->callbacks(), element, name, oldValue, newValue);
+    CustomElementCallbackScheduler::scheduleAttributeChangedCallback(definition->callbacks(), element, name, oldValue, newValue);
 }
 
 void ActiveRegistrationContext::customElementDidEnterDocument(Element* element)
 {
-    ASSERT(element->isUpgradedCustomElement());
+    ASSERT(element->customElementState() == Element::Upgraded);
     CustomElementDefinition* definition = definitionFor(element);
-    CustomElementCallbackDispatcher::instance().enqueueEnteredDocumentCallback(definition->callbacks(), element);
+    CustomElementCallbackScheduler::scheduleEnteredDocumentCallback(definition->callbacks(), element);
 }
 
 void ActiveRegistrationContext::customElementDidLeaveDocument(Element* element)
 {
-    ASSERT(element->isUpgradedCustomElement());
+    ASSERT(element->customElementState() == Element::Upgraded);
     CustomElementDefinition* definition = definitionFor(element);
-    CustomElementCallbackDispatcher::instance().enqueueLeftDocumentCallback(definition->callbacks(), element);
+    CustomElementCallbackScheduler::scheduleLeftDocumentCallback(definition->callbacks(), element);
 }
 
 void ActiveRegistrationContext::customElementIsBeingDestroyed(Element* element)
 {
-    CustomElementRegistrationContext::customElementIsBeingDestroyed(element);
     m_candidates.remove(element);
+    CustomElementRegistrationContext::customElementIsBeingDestroyed(element);
 }
 
 PassRefPtr<CustomElementRegistrationContext> CustomElementRegistrationContext::create()
@@ -246,8 +246,6 @@
 
 CustomElementDescriptor CustomElementRegistrationContext::describe(Element* element)
 {
-    ASSERT(element->isCustomElement());
-
     // If an element has a custom tag name it takes precedence over
     // the "is" attribute (if any).
     const AtomicString& type = isCustomTagName(element->localName())
@@ -275,7 +273,6 @@
 
     TypeExtensionMap::AddResult result = typeExtensionMap()->add(element, type);
     ASSERT(result.isNewEntry); // Type extensions should only be set once
-    element->setIsCustomElement();
     element->document()->registrationContext()->didGiveTypeExtension(element);
 }
 
diff --git a/Source/core/dom/CustomElementUpgradeCandidateMap.cpp b/Source/core/dom/CustomElementUpgradeCandidateMap.cpp
index 0c3049a..e3bcd0d 100644
--- a/Source/core/dom/CustomElementUpgradeCandidateMap.cpp
+++ b/Source/core/dom/CustomElementUpgradeCandidateMap.cpp
@@ -45,13 +45,14 @@
 
 void CustomElementUpgradeCandidateMap::remove(Element* element)
 {
-    UpgradeCandidateMap::iterator it = m_upgradeCandidates.find(element);
-    if (it == m_upgradeCandidates.end())
+    UpgradeCandidateMap::iterator candidate = m_upgradeCandidates.find(element);
+    if (candidate == m_upgradeCandidates.end())
         return;
 
-    const CustomElementDescriptor& descriptor = it->value;
-    m_unresolvedDefinitions.get(descriptor).remove(element);
-    m_upgradeCandidates.remove(it);
+    UnresolvedDefinitionMap::iterator elements = m_unresolvedDefinitions.find(candidate->value);
+    ASSERT(elements != m_unresolvedDefinitions.end());
+    elements->value.remove(element);
+    m_upgradeCandidates.remove(candidate);
 }
 
 ListHashSet<Element*> CustomElementUpgradeCandidateMap::takeUpgradeCandidatesFor(const CustomElementDescriptor& descriptor)
diff --git a/Source/core/dom/CustomEvent.cpp b/Source/core/dom/CustomEvent.cpp
index bad25d2..c79ecac 100644
--- a/Source/core/dom/CustomEvent.cpp
+++ b/Source/core/dom/CustomEvent.cpp
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "core/dom/CustomEvent.h"
 
+#include "bindings/v8/SerializedScriptValue.h"
 #include "core/dom/EventNames.h"
 
 namespace WebCore {
diff --git a/Source/core/dom/CustomEvent.h b/Source/core/dom/CustomEvent.h
index 22466bf..fc7bb11 100644
--- a/Source/core/dom/CustomEvent.h
+++ b/Source/core/dom/CustomEvent.h
@@ -26,12 +26,12 @@
 #ifndef CustomEvent_h
 #define CustomEvent_h
 
-#include "bindings/v8/ScriptValue.h"
-#include "bindings/v8/SerializedScriptValue.h"
 #include "core/dom/Event.h"
 
 namespace WebCore {
 
+class SerializedScriptValue;
+
 typedef EventInit CustomEventInit;
 
 class CustomEvent : public Event {
@@ -54,6 +54,12 @@
 
     SerializedScriptValue* serializedScriptValue() { return m_serializedScriptValue.get(); }
 
+    void setSerializedDetail(PassRefPtr<SerializedScriptValue> detail)
+    {
+        ASSERT(!m_serializedScriptValue);
+        m_serializedScriptValue = detail;
+    }
+
 private:
     CustomEvent();
     CustomEvent(const AtomicString& type, const CustomEventInit& initializer);
diff --git a/Source/core/dom/DOMException.cpp b/Source/core/dom/DOMException.cpp
index 1a4126c..5883eba 100644
--- a/Source/core/dom/DOMException.cpp
+++ b/Source/core/dom/DOMException.cpp
@@ -86,7 +86,7 @@
     return tableIndex < tableSize ? &coreExceptions[tableIndex] : 0;
 }
 
-DOMException::DOMException(unsigned short code, const char* name, const char * message)
+DOMException::DOMException(unsigned short code, const String& name, const String& message)
 {
     ASSERT(name);
     m_code = code;
@@ -95,11 +95,13 @@
     ScriptWrappable::init(this);
 }
 
-PassRefPtr<DOMException> DOMException::create(ExceptionCode ec, const char* message)
+PassRefPtr<DOMException> DOMException::create(ExceptionCode ec, const String& message)
 {
     const CoreException* entry = getErrorEntry(ec);
     ASSERT(entry);
-    return adoptRef(new DOMException(entry->code, entry->name ? entry->name : "Error", message ? message : entry->message));
+    return adoptRef(new DOMException(entry->code,
+        ASCIILiteral(entry->name ? entry->name : "Error"),
+        message.isNull() ? String(ASCIILiteral(entry->message)) : message));
 }
 
 String DOMException::toString() const
@@ -112,9 +114,9 @@
     const CoreException* entry = getErrorEntry(ec);
     ASSERT(entry);
     if (!entry)
-        return "UnknownError";
+        return ASCIILiteral("UnknownError");
 
-    return entry->name;
+    return ASCIILiteral(entry->name);
 }
 
 String DOMException::getErrorMessage(ExceptionCode ec)
@@ -122,9 +124,9 @@
     const CoreException* entry = getErrorEntry(ec);
     ASSERT(entry);
     if (!entry)
-        return "Unknown error.";
+        return ASCIILiteral("Unknown error.");
 
-    return entry->message;
+    return ASCIILiteral(entry->message);
 }
 
 unsigned short DOMException::getLegacyErrorCode(ExceptionCode ec)
diff --git a/Source/core/dom/DOMException.h b/Source/core/dom/DOMException.h
index fb1163f..ca96483 100644
--- a/Source/core/dom/DOMException.h
+++ b/Source/core/dom/DOMException.h
@@ -40,7 +40,7 @@
 
 class DOMException : public RefCounted<DOMException>, public ScriptWrappable {
 public:
-    static PassRefPtr<DOMException> create(ExceptionCode, const char* message = 0);
+    static PassRefPtr<DOMException> create(ExceptionCode, const String& message = String());
 
     unsigned short code() const { return m_code; }
     String name() const { return m_name; }
@@ -53,7 +53,7 @@
     static unsigned short getLegacyErrorCode(ExceptionCode);
 
 private:
-    DOMException(unsigned short m_code, const char* name, const char* message);
+    DOMException(unsigned short m_code, const String& name, const String& message);
 
     unsigned short m_code;
     String m_name;
diff --git a/Source/core/dom/DeviceOrientationController.cpp b/Source/core/dom/DeviceOrientationController.cpp
index 460e1fb..9071098 100644
--- a/Source/core/dom/DeviceOrientationController.cpp
+++ b/Source/core/dom/DeviceOrientationController.cpp
@@ -28,8 +28,8 @@
 #include "core/dom/DeviceOrientationController.h"
 
 #include "core/dom/DeviceOrientationClient.h"
-#include "core/dom/DeviceOrientationEvent.h"
 #include "core/inspector/InspectorInstrumentation.h"
+#include "modules/device_orientation/DeviceOrientationEvent.h"
 
 namespace WebCore {
 
diff --git a/Source/core/dom/DeviceOrientationData.cpp b/Source/core/dom/DeviceOrientationData.cpp
deleted file mode 100644
index 781a466..0000000
--- a/Source/core/dom/DeviceOrientationData.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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/DeviceOrientationData.h"
-
-namespace WebCore {
-
-PassRefPtr<DeviceOrientationData> DeviceOrientationData::create()
-{
-    return adoptRef(new DeviceOrientationData);
-}
-
-PassRefPtr<DeviceOrientationData> DeviceOrientationData::create(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma, bool canProvideAbsolute, bool absolute)
-{
-    return adoptRef(new DeviceOrientationData(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma, canProvideAbsolute, absolute));
-}
-
-
-DeviceOrientationData::DeviceOrientationData()
-    : m_canProvideAlpha(false)
-    , m_canProvideBeta(false)
-    , m_canProvideGamma(false)
-    , m_canProvideAbsolute(false)
-    , m_alpha(0)
-    , m_beta(0)
-    , m_gamma(0)
-    , m_absolute(false)
-{
-}
-
-DeviceOrientationData::DeviceOrientationData(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma, bool canProvideAbsolute, bool absolute)
-    : m_canProvideAlpha(canProvideAlpha)
-    , m_canProvideBeta(canProvideBeta)
-    , m_canProvideGamma(canProvideGamma)
-    , m_canProvideAbsolute(canProvideAbsolute)
-    , m_alpha(alpha)
-    , m_beta(beta)
-    , m_gamma(gamma)
-    , m_absolute(absolute)
-{
-}
-
-double DeviceOrientationData::alpha() const
-{
-    return m_alpha;
-}
-
-double DeviceOrientationData::beta() const
-{
-    return m_beta;
-}
-
-double DeviceOrientationData::gamma() const
-{
-    return m_gamma;
-}
-
-bool DeviceOrientationData::absolute() const
-{
-    return m_absolute;
-}
-
-bool DeviceOrientationData::canProvideAlpha() const
-{
-    return m_canProvideAlpha;
-}
-
-bool DeviceOrientationData::canProvideBeta() const
-{
-    return m_canProvideBeta;
-}
-
-bool DeviceOrientationData::canProvideGamma() const
-{
-    return m_canProvideGamma;
-}
-
-bool DeviceOrientationData::canProvideAbsolute() const
-{
-    return m_canProvideAbsolute;
-}
-
-} // namespace WebCore
diff --git a/Source/core/dom/DeviceOrientationData.h b/Source/core/dom/DeviceOrientationData.h
deleted file mode 100644
index 2c37a13..0000000
--- a/Source/core/dom/DeviceOrientationData.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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 DeviceOrientationData_h
-#define DeviceOrientationData_h
-
-#include "wtf/PassRefPtr.h"
-#include "wtf/RefCounted.h"
-
-namespace WebCore {
-
-class DeviceOrientationData : public RefCounted<DeviceOrientationData> {
-public:
-    static PassRefPtr<DeviceOrientationData> create();
-    static PassRefPtr<DeviceOrientationData> create(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma, bool canProvideAbsolute = false, bool absolute = false);
-
-    double alpha() const;
-    double beta() const;
-    double gamma() const;
-    bool absolute() const;
-    bool canProvideAlpha() const;
-    bool canProvideBeta() const;
-    bool canProvideGamma() const;
-    bool canProvideAbsolute() const;
-
-private:
-    DeviceOrientationData();
-    DeviceOrientationData(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma, bool canProvideAbsolute, bool absolute);
-
-    bool m_canProvideAlpha;
-    bool m_canProvideBeta;
-    bool m_canProvideGamma;
-    bool m_canProvideAbsolute;
-    double m_alpha;
-    double m_beta;
-    double m_gamma;
-    bool m_absolute;
-};
-
-} // namespace WebCore
-
-#endif // DeviceOrientationData_h
diff --git a/Source/core/dom/DeviceOrientationEvent.cpp b/Source/core/dom/DeviceOrientationEvent.cpp
deleted file mode 100644
index 5875edc..0000000
--- a/Source/core/dom/DeviceOrientationEvent.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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/DeviceOrientationEvent.h"
-
-#include "core/dom/DeviceOrientationData.h"
-#include "core/dom/EventNames.h"
-
-namespace WebCore {
-
-DeviceOrientationEvent::~DeviceOrientationEvent()
-{
-}
-
-DeviceOrientationEvent::DeviceOrientationEvent()
-    : m_orientation(DeviceOrientationData::create())
-{
-    ScriptWrappable::init(this);
-}
-
-DeviceOrientationEvent::DeviceOrientationEvent(const AtomicString& eventType, DeviceOrientationData* orientation)
-    : Event(eventType, false, false) // Can't bubble, not cancelable
-    , m_orientation(orientation)
-{
-    ScriptWrappable::init(this);
-}
-
-void DeviceOrientationEvent::initDeviceOrientationEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceOrientationData* orientation)
-{
-    if (dispatched())
-        return;
-
-    initEvent(type, bubbles, cancelable);
-    m_orientation = orientation;
-}
-
-double DeviceOrientationEvent::alpha(bool& isNull) const
-{
-    if (m_orientation->canProvideAlpha())
-        return m_orientation->alpha();
-
-    isNull = true;
-    return 0;
-}
-
-double DeviceOrientationEvent::beta(bool& isNull) const
-{
-    if (m_orientation->canProvideBeta())
-        return m_orientation->beta();
-
-    isNull = true;
-    return 0;
-}
-
-double DeviceOrientationEvent::gamma(bool& isNull) const
-{
-    if (m_orientation->canProvideGamma())
-        return m_orientation->gamma();
-
-    isNull = true;
-    return 0;
-}
-
-bool DeviceOrientationEvent::absolute(bool& isNull) const
-{
-    if (m_orientation->canProvideAbsolute())
-        return m_orientation->absolute();
-
-    isNull = true;
-    return 0;
-}
-
-const AtomicString& DeviceOrientationEvent::interfaceName() const
-{
-    return eventNames().interfaceForDeviceOrientationEvent;
-}
-
-} // namespace WebCore
diff --git a/Source/core/dom/DeviceOrientationEvent.h b/Source/core/dom/DeviceOrientationEvent.h
deleted file mode 100644
index dc55e67..0000000
--- a/Source/core/dom/DeviceOrientationEvent.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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 DeviceOrientationEvent_h
-#define DeviceOrientationEvent_h
-
-#include "core/dom/Event.h"
-
-namespace WebCore {
-
-class DeviceOrientationData;
-
-class DeviceOrientationEvent : public Event {
-public:
-    ~DeviceOrientationEvent();
-    static PassRefPtr<DeviceOrientationEvent> create()
-    {
-        return adoptRef(new DeviceOrientationEvent);
-    }
-    static PassRefPtr<DeviceOrientationEvent> create(const AtomicString& eventType, DeviceOrientationData* orientation)
-    {
-        return adoptRef(new DeviceOrientationEvent(eventType, orientation));
-    }
-
-    void initDeviceOrientationEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceOrientationData*);
-
-    DeviceOrientationData* orientation() const { return m_orientation.get(); }
-
-    double alpha(bool& isNull) const;
-    double beta(bool& isNull) const;
-    double gamma(bool& isNull) const;
-    bool absolute(bool& isNull) const;
-
-    virtual const AtomicString& interfaceName() const;
-
-private:
-    DeviceOrientationEvent();
-    DeviceOrientationEvent(const AtomicString& eventType, DeviceOrientationData*);
-
-    RefPtr<DeviceOrientationData> m_orientation;
-};
-
-} // namespace WebCore
-
-#endif // DeviceOrientationEvent_h
diff --git a/Source/core/dom/DeviceOrientationEvent.idl b/Source/core/dom/DeviceOrientationEvent.idl
deleted file mode 100644
index 286f2bb..0000000
--- a/Source/core/dom/DeviceOrientationEvent.idl
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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.
- */
-
-interface DeviceOrientationEvent : Event {
-    readonly attribute double? alpha;
-    readonly attribute double? beta;
-    readonly attribute double? gamma;
-    readonly attribute boolean? absolute;
-    [Custom] void initDeviceOrientationEvent([Default=Undefined] optional DOMString type, 
-                                             [Default=Undefined] optional boolean bubbles, 
-                                             [Default=Undefined] optional boolean cancelable, 
-                                             [Default=Undefined] optional double alpha, 
-                                             [Default=Undefined] optional double beta, 
-                                             [Default=Undefined] optional double gamma,
-                                             [Default=Undefined] optional boolean absolute);
-};
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 2f47ff4..d4b4fc7 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -275,23 +275,23 @@
     return url.isEmpty() || url.isBlankURL();
 }
 
-static Widget* widgetForNode(Node* focusedNode)
+static Widget* widgetForElement(Element* focusedElement)
 {
-    if (!focusedNode)
+    if (!focusedElement)
         return 0;
-    RenderObject* renderer = focusedNode->renderer();
+    RenderObject* renderer = focusedElement->renderer();
     if (!renderer || !renderer->isWidget())
         return 0;
     return toRenderWidget(renderer)->widget();
 }
 
-static bool acceptsEditingFocus(Node* node)
+static bool acceptsEditingFocus(Element* element)
 {
-    ASSERT(node);
-    ASSERT(node->rendererIsEditable());
+    ASSERT(element);
+    ASSERT(element->rendererIsEditable());
 
-    Node* root = node->rootEditableElement();
-    Frame* frame = node->document()->frame();
+    Element* root = element->rootEditableElement();
+    Frame* frame = element->document()->frame();
     if (!frame || !root)
         return false;
 
@@ -331,34 +331,35 @@
     String message = "Unsafe JavaScript attempt to initiate navigation for frame with URL '" + frame->document()->url().string() + "' from frame with URL '" + activeURL.string() + "'. " + reason + "\n";
 
     // FIXME: should we print to the console of the document performing the navigation instead?
-    frame->document()->domWindow()->printErrorMessage(message);
+    frame->domWindow()->printErrorMessage(message);
 }
 
 uint64_t Document::s_globalTreeVersion = 0;
 
 // This class should be passed only to Document::postTask.
-class CheckFocusedNodeTask FINAL : public ScriptExecutionContext::Task {
+class CheckFocusedElementTask FINAL : public ScriptExecutionContext::Task {
 public:
-    static PassOwnPtr<CheckFocusedNodeTask> create()
+    static PassOwnPtr<CheckFocusedElementTask> create()
     {
-        return adoptPtr(new CheckFocusedNodeTask());
+        return adoptPtr(new CheckFocusedElementTask());
     }
-    virtual ~CheckFocusedNodeTask() { }
+    virtual ~CheckFocusedElementTask() { }
 
 private:
-    CheckFocusedNodeTask() { }
+    CheckFocusedElementTask() { }
     virtual void performTask(ScriptExecutionContext* context) OVERRIDE
     {
         ASSERT(context->isDocument());
         Document* document = toDocument(context);
-        document->didRunCheckFocusedNodeTask();
-        if (!document->focusedNode())
+        document->didRunCheckFocusedElementTask();
+        Element* element = document->focusedElement();
+        if (!element)
             return;
         if (document->childNeedsStyleRecalc())
             return;
-        if (document->focusedNode()->renderer() && document->focusedNode()->renderer()->needsLayout())
+        if (element->renderer() && element->renderer()->needsLayout())
             return;
-        if (!document->focusedNode()->isFocusable())
+        if (!element->isFocusable())
             document->setFocusedElement(0);
     }
 };
@@ -384,7 +385,7 @@
     , m_ignoreAutofocus(false)
     , m_compatibilityMode(NoQuirksMode)
     , m_compatibilityModeLocked(false)
-    , m_didPostCheckFocusedNodeTask(false)
+    , m_didPostCheckFocusedElementTask(false)
     , m_domTreeVersion(++s_globalTreeVersion)
     , m_listenerTypes(0)
     , m_mutationObserverTypes(0)
@@ -583,7 +584,7 @@
     // We must make sure not to be retaining any of our children through
     // these extra pointers or we will create a reference cycle.
     m_docType = 0;
-    m_focusedNode = 0;
+    m_focusedElement = 0;
     m_hoverNode = 0;
     m_activeElement = 0;
     m_titleElement = 0;
@@ -1103,8 +1104,11 @@
 
 String Document::encoding() const
 {
+    // TextEncoding::domName() returns a char*, no need to allocate a new
+    // String for it each time.
+    // FIXME: We should fix TextEncoding to speak AtomicString anyway.
     if (TextResourceDecoder* d = decoder())
-        return d->encoding().domName();
+        return AtomicString(d->encoding().domName());
     return String();
 }
 
@@ -1655,7 +1659,7 @@
 
         // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc.
         if (m_styleResolver)
-            m_styleSheetCollection->resetCSSFeatureFlags();
+            m_styleSheetCollection->resetCSSFeatureFlags(m_styleResolver->ruleFeatureSet());
 
         if (frameView) {
             frameView->resumeScheduledEvents();
@@ -1669,6 +1673,9 @@
         implicitClose();
     }
 
+    STYLE_STATS_PRINT();
+    STYLE_STATS_CLEAR();
+
     InspectorInstrumentation::didRecalculateStyle(cookie);
 
     // As a result of the style recalculation, the currently hovered element might have been
@@ -1725,9 +1732,9 @@
         frameView->layout();
 
     // FIXME: Using a Task doesn't look a good idea.
-    if (m_focusedNode && !m_didPostCheckFocusedNodeTask) {
-        postTask(CheckFocusedNodeTask::create());
-        m_didPostCheckFocusedNodeTask = true;
+    if (m_focusedElement && !m_didPostCheckFocusedElementTask) {
+        postTask(CheckFocusedElementTask::create());
+        m_didPostCheckFocusedElementTask = true;
     }
 }
 
@@ -1837,7 +1844,7 @@
     if (Settings* docSettings = settings())
         matchAuthorAndUserStyles = docSettings->authorAndUserStylesEnabled();
     m_styleResolver = adoptPtr(new StyleResolver(this, matchAuthorAndUserStyles));
-    m_styleSheetCollection->combineCSSFeatureFlags();
+    m_styleSheetCollection->combineCSSFeatureFlags(m_styleResolver->ruleFeatureSet());
 }
 
 void Document::clearStyleResolver()
@@ -1902,7 +1909,7 @@
     setRenderer(0);
 
     m_hoverNode = 0;
-    m_focusedNode = 0;
+    m_focusedElement = 0;
     m_activeElement = 0;
 
     ContainerNode::detach(context);
@@ -2090,7 +2097,7 @@
     cancelParsing();
 
     removeChildren();
-    ASSERT(!m_focusedNode);
+    ASSERT(!m_focusedElement);
 
     setCompatibilityMode(NoQuirksMode);
 
@@ -2276,7 +2283,7 @@
         // The AX cache may have been cleared at this point, but we need to make sure it contains an
         // AX object to send the notification to. getOrCreate will make sure that an valid AX object
         // exists in the cache (we ignore the return value because we don't need it here). This is
-        // only safe to call when a layout is not in progress, so it can not be used in postNotification.    
+        // only safe to call when a layout is not in progress, so it can not be used in postNotification.
         if (AXObjectCache* cache = axObjectCache()) {
             cache->getOrCreate(renderObject);
             if (this == topDocument()) {
@@ -2393,7 +2400,7 @@
     return domWindow();
 }
 
-void Document::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack> callStack)
+void Document::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack> callStack)
 {
     addMessage(JSMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, callStack);
 }
@@ -2666,12 +2673,20 @@
             refreshUrl = m_url.string();
         else
             refreshUrl = completeURL(refreshUrl).string();
-        if (!protocolIsJavaScript(refreshUrl)) {
-            frame->navigationScheduler()->scheduleRedirect(delay, refreshUrl);
-        } else {
+
+        if (protocolIsJavaScript(refreshUrl)) {
             String message = "Refused to refresh " + m_url.elidedString() + " to a javascript: URL";
             addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message);
+            return;
         }
+
+        if (isSandboxed(SandboxAutomaticFeatures)) {
+            String message = "Refused to execute the redirect specified via '<meta http-equiv='refresh' content='...'>'. The document is sandboxed, and the 'allow-scripts' keyword is not set.";
+            addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message);
+            return;
+        }
+
+        frame->navigationScheduler()->scheduleRedirect(delay, refreshUrl);
     }
 }
 
@@ -3040,9 +3055,9 @@
     m_activeElement = newActiveElement;
 }
 
-void Document::removeFocusedNodeOfSubtree(Node* node, bool amongChildrenOnly)
+void Document::removeFocusedElementOfSubtree(Node* node, bool amongChildrenOnly)
 {
-    if (!m_focusedNode)
+    if (!m_focusedElement)
         return;
 
     Element* focusedElement = node->treeScope()->adjustedFocusedElement();
@@ -3106,64 +3121,59 @@
     setAnnotatedRegionsDirty(false);
 }
 
-bool Document::setFocusedElement(PassRefPtr<Element> prpNewFocusedNode, FocusDirection direction)
+bool Document::setFocusedElement(PassRefPtr<Element> prpNewFocusedElement, FocusDirection direction)
 {
-    RefPtr<Node> newFocusedNode = prpNewFocusedNode;
+    RefPtr<Element> newFocusedElement = prpNewFocusedElement;
 
     // Make sure newFocusedNode is actually in this document
-    if (newFocusedNode && (newFocusedNode->document() != this))
+    if (newFocusedElement && (newFocusedElement->document() != this))
         return true;
 
-    if (m_focusedNode == newFocusedNode)
+    if (m_focusedElement == newFocusedElement)
         return true;
 
     bool focusChangeBlocked = false;
-    RefPtr<Node> oldFocusedNode = m_focusedNode;
-    m_focusedNode = 0;
+    RefPtr<Element> oldFocusedElement = m_focusedElement;
+    m_focusedElement = 0;
 
     // Remove focus from the existing focus node (if any)
-    if (oldFocusedNode) {
-        ASSERT(!oldFocusedNode->inDetach());
+    if (oldFocusedElement) {
+        ASSERT(!oldFocusedElement->inDetach());
 
-        if (oldFocusedNode->active())
-            oldFocusedNode->setActive(false);
+        if (oldFocusedElement->active())
+            oldFocusedElement->setActive(false);
 
-        oldFocusedNode->setFocus(false);
+        oldFocusedElement->setFocus(false);
 
         // Dispatch a change event for text fields or textareas that have been edited
-        if (oldFocusedNode->isElementNode()) {
-            Element* element = toElement(oldFocusedNode.get());
-            if (element->wasChangedSinceLastFormControlChangeEvent())
-                element->dispatchFormControlChangeEvent();
-        }
+        if (oldFocusedElement->wasChangedSinceLastFormControlChangeEvent())
+            oldFocusedElement->dispatchFormControlChangeEvent();
 
         // Dispatch the blur event and let the node do any other blur related activities (important for text fields)
-        oldFocusedNode->dispatchBlurEvent(newFocusedNode);
+        oldFocusedElement->dispatchBlurEvent(newFocusedElement);
 
-        if (m_focusedNode) {
+        if (m_focusedElement) {
             // handler shifted focus
             focusChangeBlocked = true;
-            newFocusedNode = 0;
+            newFocusedElement = 0;
         }
 
-        oldFocusedNode->dispatchFocusOutEvent(eventNames().focusoutEvent, newFocusedNode); // DOM level 3 name for the bubbling blur event.
+        oldFocusedElement->dispatchFocusOutEvent(eventNames().focusoutEvent, newFocusedElement); // DOM level 3 name for the bubbling blur event.
         // FIXME: We should remove firing DOMFocusOutEvent event when we are sure no content depends
         // on it, probably when <rdar://problem/8503958> is resolved.
-        oldFocusedNode->dispatchFocusOutEvent(eventNames().DOMFocusOutEvent, newFocusedNode); // DOM level 2 name for compatibility.
+        oldFocusedElement->dispatchFocusOutEvent(eventNames().DOMFocusOutEvent, newFocusedElement); // DOM level 2 name for compatibility.
 
-        if (m_focusedNode) {
+        if (m_focusedElement) {
             // handler shifted focus
             focusChangeBlocked = true;
-            newFocusedNode = 0;
+            newFocusedElement = 0;
         }
-        if (oldFocusedNode == this && oldFocusedNode->hasOneRef())
-            return true;
 
-        if (oldFocusedNode->isRootEditableElement())
+        if (oldFocusedElement->isRootEditableElement())
             frame()->editor()->didEndEditing();
 
         if (view()) {
-            Widget* oldWidget = widgetForNode(oldFocusedNode.get());
+            Widget* oldWidget = widgetForElement(oldFocusedElement.get());
             if (oldWidget)
                 oldWidget->setFocus(false);
             else
@@ -3171,57 +3181,57 @@
         }
     }
 
-    if (newFocusedNode && newFocusedNode->isFocusable()) {
-        if (newFocusedNode->isRootEditableElement() && !acceptsEditingFocus(newFocusedNode.get())) {
+    if (newFocusedElement && newFocusedElement->isFocusable()) {
+        if (newFocusedElement->isRootEditableElement() && !acceptsEditingFocus(newFocusedElement.get())) {
             // delegate blocks focus change
             focusChangeBlocked = true;
-            goto SetFocusedNodeDone;
+            goto SetFocusedElementDone;
         }
         // Set focus on the new node
-        m_focusedNode = newFocusedNode;
+        m_focusedElement = newFocusedElement;
 
         // Dispatch the focus event and let the node do any other focus related activities (important for text fields)
-        m_focusedNode->dispatchFocusEvent(oldFocusedNode, direction);
+        m_focusedElement->dispatchFocusEvent(oldFocusedElement, direction);
 
-        if (m_focusedNode != newFocusedNode) {
+        if (m_focusedElement != newFocusedElement) {
             // handler shifted focus
             focusChangeBlocked = true;
-            goto SetFocusedNodeDone;
+            goto SetFocusedElementDone;
         }
 
-        m_focusedNode->dispatchFocusInEvent(eventNames().focusinEvent, oldFocusedNode); // DOM level 3 bubbling focus event.
+        m_focusedElement->dispatchFocusInEvent(eventNames().focusinEvent, oldFocusedElement); // DOM level 3 bubbling focus event.
 
-        if (m_focusedNode != newFocusedNode) {
+        if (m_focusedElement != newFocusedElement) {
             // handler shifted focus
             focusChangeBlocked = true;
-            goto SetFocusedNodeDone;
+            goto SetFocusedElementDone;
         }
 
         // FIXME: We should remove firing DOMFocusInEvent event when we are sure no content depends
         // on it, probably when <rdar://problem/8503958> is m.
-        m_focusedNode->dispatchFocusInEvent(eventNames().DOMFocusInEvent, oldFocusedNode); // DOM level 2 for compatibility.
+        m_focusedElement->dispatchFocusInEvent(eventNames().DOMFocusInEvent, oldFocusedElement); // DOM level 2 for compatibility.
 
-        if (m_focusedNode != newFocusedNode) {
+        if (m_focusedElement != newFocusedElement) {
             // handler shifted focus
             focusChangeBlocked = true;
-            goto SetFocusedNodeDone;
+            goto SetFocusedElementDone;
         }
-        m_focusedNode->setFocus(true);
+        m_focusedElement->setFocus(true);
 
-        if (m_focusedNode->isRootEditableElement())
+        if (m_focusedElement->isRootEditableElement())
             frame()->editor()->didBeginEditing();
 
         // eww, I suck. set the qt focus correctly
         // ### find a better place in the code for this
         if (view()) {
-            Widget* focusWidget = widgetForNode(m_focusedNode.get());
+            Widget* focusWidget = widgetForElement(m_focusedElement.get());
             if (focusWidget) {
                 // Make sure a widget has the right size before giving it focus.
                 // Otherwise, we are testing edge cases of the Widget code.
                 // Specifically, in WebCore this does not work well for text fields.
                 updateLayout();
                 // Re-get the widget in case updating the layout changed things.
-                focusWidget = widgetForNode(m_focusedNode.get());
+                focusWidget = widgetForElement(m_focusedElement.get());
             }
             if (focusWidget)
                 focusWidget->setFocus(true);
@@ -3230,16 +3240,16 @@
         }
     }
 
-    if (!focusChangeBlocked && m_focusedNode) {
+    if (!focusChangeBlocked && m_focusedElement) {
         // Create the AXObject cache in a focus change because Chromium relies on it.
         if (AXObjectCache* cache = axObjectCache())
-            cache->handleFocusedUIElementChanged(oldFocusedNode.get(), newFocusedNode.get());
+            cache->handleFocusedUIElementChanged(oldFocusedElement.get(), newFocusedElement.get());
     }
 
     if (!focusChangeBlocked)
-        page()->chrome().focusedNodeChanged(m_focusedNode.get());
+        page()->chrome().focusedNodeChanged(m_focusedElement.get());
 
-SetFocusedNodeDone:
+SetFocusedElementDone:
     updateStyleIfNeeded();
     if (Frame* frame = this->frame())
         frame->selection()->didChangeFocus();
@@ -3632,6 +3642,11 @@
     return String::format("%02d/%02d/%04d %02d:%02d:%02d", date.month() + 1, date.monthDay(), date.fullYear(), date.hour(), date.minute(), date.second());
 }
 
+const KURL& Document::firstPartyForCookies() const
+{
+    return topDocument()->url();
+}
+
 static bool isValidNameNonASCII(const LChar* characters, unsigned length)
 {
     if (!isValidNameStart(characters[0]))
@@ -4317,15 +4332,10 @@
 
 void Document::updateFocusAppearanceTimerFired(Timer<Document>*)
 {
-    Node* node = focusedNode();
-    if (!node)
+    Element* element = focusedElement();
+    if (!element)
         return;
-    if (!node->isElementNode())
-        return;
-
     updateLayout();
-
-    Element* element = toElement(node);
     if (element->isFocusable())
         element->updateFocusAppearance(m_updateFocusAppearanceRestoresSelection);
 }
@@ -4791,7 +4801,7 @@
 {
     if (!doc)
         return 0;
-    Node* node = doc->focusedNode();
+    Node* node = doc->focusedElement();
     if (!node && doc->isPluginDocument()) {
         PluginDocument* pluginDocument = toPluginDocument(doc);
         node =  pluginDocument->pluginNode();
diff --git a/Source/core/dom/Document.h b/Source/core/dom/Document.h
index 1cbb69b..cfd2f8f 100644
--- a/Source/core/dom/Document.h
+++ b/Source/core/dom/Document.h
@@ -629,10 +629,10 @@
     void setSelectedStylesheetSet(const String&);
 
     bool setFocusedElement(PassRefPtr<Element>, FocusDirection = FocusDirectionNone);
-    Node* focusedNode() const { return m_focusedNode.get(); }
+    Element* focusedElement() const { return m_focusedElement.get(); }
     UserActionElementSet& userActionElements()  { return m_userActionElements; }
     const UserActionElementSet& userActionElements() const { return m_userActionElements; }
-    void didRunCheckFocusedNodeTask() { m_didPostCheckFocusedNodeTask = false; }
+    void didRunCheckFocusedElementTask() { m_didPostCheckFocusedElementTask = false; }
 
     // The m_ignoreAutofocus flag specifies whether or not the document has been changed by the user enough 
     // for WebCore to ignore the autofocus attribute on any form controls
@@ -645,7 +645,7 @@
     void setActiveElement(PassRefPtr<Element>);
     Element* activeElement() const { return m_activeElement.get(); }
 
-    void removeFocusedNodeOfSubtree(Node*, bool amongChildrenOnly = false);
+    void removeFocusedElementOfSubtree(Node*, bool amongChildrenOnly = false);
     void hoveredNodeDetached(Node*);
     void activeChainNodeDetached(Node*);
 
@@ -780,18 +780,7 @@
     const KURL& cookieURL() const { return m_cookieURL; }
     void setCookieURL(const KURL& url) { m_cookieURL = url; }
 
-    // The firstPartyForCookies is used to compute whether this document
-    // appears in a "third-party" context for the purpose of third-party
-    // cookie blocking.  The document is in a third-party context if the
-    // cookieURL and the firstPartyForCookies are from different hosts.
-    //
-    // Note: Some ports (including possibly Apple's) only consider the
-    //       document in a third-party context if the cookieURL and the
-    //       firstPartyForCookies have a different registry-controlled
-    //       domain.
-    //
-    const KURL& firstPartyForCookies() const { return m_firstPartyForCookies; }
-    void setFirstPartyForCookies(const KURL& url) { m_firstPartyForCookies = url; }
+    const KURL& firstPartyForCookies() const;
     
     // The following implements the rule from HTML 4 for what valid names are.
     // To get this right for all the XML cases, we probably have to improve this or move it
@@ -958,7 +947,7 @@
     void serviceScriptedAnimations(double monotonicAnimationStartTime);
 
     virtual EventTarget* errorEventTarget();
-    virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>);
+    virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>);
 
     void initDNSPrefetch();
 
@@ -1157,7 +1146,6 @@
     KURL m_baseURLOverride; // An alternative base URL that takes precedence over m_baseURL (but not m_baseElementURL).
     KURL m_baseElementURL; // The URL set by the <base> element.
     KURL m_cookieURL; // The URL to use for cookie access.
-    KURL m_firstPartyForCookies; // The policy URL for third-party cookie blocking.
 
     // Document.documentURI:
     // Although URL-like, Document.documentURI can actually be set to any
@@ -1181,8 +1169,8 @@
     CompatibilityMode m_compatibilityMode;
     bool m_compatibilityModeLocked; // This is cheaper than making setCompatibilityMode virtual.
 
-    bool m_didPostCheckFocusedNodeTask;
-    RefPtr<Node> m_focusedNode;
+    bool m_didPostCheckFocusedElementTask;
+    RefPtr<Element> m_focusedElement;
     RefPtr<Node> m_hoverNode;
     RefPtr<Element> m_activeElement;
     RefPtr<Element> m_documentElement;
diff --git a/Source/core/dom/Document.idl b/Source/core/dom/Document.idl
index effc829..3e1af34 100644
--- a/Source/core/dom/Document.idl
+++ b/Source/core/dom/Document.idl
@@ -174,32 +174,32 @@
     [NotEnumerable] attribute EventListener onabort;
     [NotEnumerable] attribute EventListener onblur;
     [NotEnumerable] attribute EventListener onchange;
-    [NotEnumerable] attribute EventListener onclick;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onclick;
     [NotEnumerable] attribute EventListener oncontextmenu;
-    [NotEnumerable] attribute EventListener ondblclick;
-    [NotEnumerable] attribute EventListener ondrag;
-    [NotEnumerable] attribute EventListener ondragend;
-    [NotEnumerable] attribute EventListener ondragenter;
-    [NotEnumerable] attribute EventListener ondragleave;
-    [NotEnumerable] attribute EventListener ondragover;
-    [NotEnumerable] attribute EventListener ondragstart;
-    [NotEnumerable] attribute EventListener ondrop;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondblclick;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondrag;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragend;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragenter;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragleave;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragover;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragstart;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondrop;
     [NotEnumerable] attribute EventListener onerror;
     [NotEnumerable] attribute EventListener onfocus;
-    [NotEnumerable] attribute EventListener oninput;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener oninput;
     [NotEnumerable] attribute EventListener oninvalid;
-    [NotEnumerable] attribute EventListener onkeydown;
-    [NotEnumerable] attribute EventListener onkeypress;
-    [NotEnumerable] attribute EventListener onkeyup;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onkeydown;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onkeypress;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onkeyup;
     [NotEnumerable] attribute EventListener onload;
-    [NotEnumerable] attribute EventListener onmousedown;
-    [NotEnumerable] attribute EventListener onmouseenter;
-    [NotEnumerable] attribute EventListener onmouseleave;
-    [NotEnumerable] attribute EventListener onmousemove;
-    [NotEnumerable] attribute EventListener onmouseout;
-    [NotEnumerable] attribute EventListener onmouseover;
-    [NotEnumerable] attribute EventListener onmouseup;
-    [NotEnumerable] attribute EventListener onmousewheel;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmousedown;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseenter;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseleave;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmousemove;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseout;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseover;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseup;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmousewheel;
     [NotEnumerable] attribute EventListener onreadystatechange;
     [NotEnumerable] attribute EventListener onscroll;
     [NotEnumerable] attribute EventListener onselect;
diff --git a/Source/core/dom/DocumentStyleSheetCollection.cpp b/Source/core/dom/DocumentStyleSheetCollection.cpp
index 34b0816..e2088d8 100644
--- a/Source/core/dom/DocumentStyleSheetCollection.cpp
+++ b/Source/core/dom/DocumentStyleSheetCollection.cpp
@@ -90,36 +90,34 @@
     return m_collectionForDocument.activeAuthorStyleSheets();
 }
 
-void DocumentStyleSheetCollection::combineCSSFeatureFlags()
+void DocumentStyleSheetCollection::combineCSSFeatureFlags(const RuleFeatureSet& features)
 {
     // Delay resetting the flags until after next style recalc since unapplying the style may not work without these set (this is true at least with before/after).
-    StyleResolver* styleResolver = m_document->styleResolver();
-    m_usesSiblingRules = m_usesSiblingRules || styleResolver->usesSiblingRules();
-    m_usesFirstLineRules = m_usesFirstLineRules || styleResolver->usesFirstLineRules();
-    m_usesBeforeAfterRules = m_usesBeforeAfterRules || styleResolver->usesBeforeAfterRules();
+    m_usesSiblingRules = m_usesSiblingRules || features.usesSiblingRules();
+    m_usesFirstLineRules = m_usesFirstLineRules || features.usesFirstLineRules();
+    m_usesBeforeAfterRules = m_usesBeforeAfterRules || features.usesBeforeAfterRules();
 }
 
-void DocumentStyleSheetCollection::resetCSSFeatureFlags()
+void DocumentStyleSheetCollection::resetCSSFeatureFlags(const RuleFeatureSet& features)
 {
-    StyleResolver* styleResolver = m_document->styleResolver();
-    m_usesSiblingRules = styleResolver->usesSiblingRules();
-    m_usesFirstLineRules = styleResolver->usesFirstLineRules();
-    m_usesBeforeAfterRules = styleResolver->usesBeforeAfterRules();
+    m_usesSiblingRules = features.usesSiblingRules();
+    m_usesFirstLineRules = features.usesFirstLineRules();
+    m_usesBeforeAfterRules = features.usesBeforeAfterRules();
 }
 
 CSSStyleSheet* DocumentStyleSheetCollection::pageUserSheet()
 {
     if (m_pageUserSheet)
         return m_pageUserSheet.get();
-    
+
     Page* owningPage = m_document->page();
     if (!owningPage)
         return 0;
-    
+
     String userSheetText = owningPage->userStyleSheet();
     if (userSheetText.isEmpty())
         return 0;
-    
+
     // Parse the sheet and cache it.
     m_pageUserSheet = CSSStyleSheet::createInline(m_document, m_document->settings()->userStyleSheetLocation());
     m_pageUserSheet->contents()->setIsUserStyleSheet(true);
@@ -268,7 +266,7 @@
     m_needsUpdateActiveStylesheetsOnStyleRecalc = false;
 
     if (styleResolverUpdateType != StyleSheetCollection::Reconstruct)
-        resetCSSFeatureFlags();
+        resetCSSFeatureFlags(m_document->styleResolver()->ruleFeatureSet());
 
     InspectorInstrumentation::activeStyleSheetsUpdated(m_document, m_collectionForDocument.styleSheetsForStyleSheetList());
     m_usesRemUnits = styleSheetsUseRemUnits(m_collectionForDocument.activeAuthorStyleSheets());
diff --git a/Source/core/dom/DocumentStyleSheetCollection.h b/Source/core/dom/DocumentStyleSheetCollection.h
index c0e0327..0e220e2 100644
--- a/Source/core/dom/DocumentStyleSheetCollection.h
+++ b/Source/core/dom/DocumentStyleSheetCollection.h
@@ -41,6 +41,7 @@
 
 class CSSStyleSheet;
 class Node;
+class RuleFeatureSet;
 class StyleSheet;
 class StyleSheetContents;
 class StyleSheetList;
@@ -100,8 +101,8 @@
     bool usesRemUnits() const { return m_usesRemUnits; }
     void setUsesRemUnit(bool b) { m_usesRemUnits = b; }
 
-    void combineCSSFeatureFlags();
-    void resetCSSFeatureFlags();
+    void combineCSSFeatureFlags(const RuleFeatureSet&);
+    void resetCSSFeatureFlags(const RuleFeatureSet&);
 
 private:
     DocumentStyleSheetCollection(Document*);
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 5aa5f57..7affb64 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -29,6 +29,7 @@
 #include "CSSPropertyNames.h"
 #include "CSSValueKeywords.h"
 #include "HTMLNames.h"
+#include "RuntimeEnabledFeatures.h"
 #include "SVGNames.h"
 #include "XMLNames.h"
 #include "core/accessibility/AXObjectCache.h"
@@ -883,12 +884,12 @@
     return value;
 }
 
-static bool checkNeedsStyleInvalidationForIdChange(const AtomicString& oldId, const AtomicString& newId, StyleResolver* styleResolver)
+static bool checkNeedsStyleInvalidationForIdChange(const AtomicString& oldId, const AtomicString& newId, const RuleFeatureSet& features)
 {
     ASSERT(newId != oldId);
-    if (!oldId.isEmpty() && styleResolver->hasSelectorForId(oldId))
+    if (!oldId.isEmpty() && features.hasSelectorForId(oldId))
         return true;
-    if (!newId.isEmpty() && styleResolver->hasSelectorForId(newId))
+    if (!newId.isEmpty() && features.hasSelectorForId(newId))
         return true;
     return false;
 }
@@ -920,7 +921,7 @@
         AtomicString newId = makeIdForStyleResolution(newValue, document()->inQuirksMode());
         if (newId != oldId) {
             elementData()->setIdForStyleResolution(newId);
-            shouldInvalidateStyle = testShouldInvalidateStyle && checkNeedsStyleInvalidationForIdChange(oldId, newId, styleResolver);
+            shouldInvalidateStyle = testShouldInvalidateStyle && checkNeedsStyleInvalidationForIdChange(oldId, newId, styleResolver->ruleFeatureSet());
         }
     } else if (name == classAttr) {
         classAttributeChanged(newValue);
@@ -1028,10 +1029,10 @@
         const SpaceSplitString oldClasses = elementData()->classNames();
         elementData()->setClass(newClassString, shouldFoldCase);
         const SpaceSplitString& newClasses = elementData()->classNames();
-        shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForClassChange(oldClasses, newClasses, *styleResolver);
+        shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForClassChange(oldClasses, newClasses, styleResolver->ruleFeatureSet());
     } else {
         const SpaceSplitString& oldClasses = elementData()->classNames();
-        shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForClassChange(oldClasses, *styleResolver);
+        shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForClassChange(oldClasses, styleResolver->ruleFeatureSet());
         elementData()->clearClass();
     }
 
@@ -1363,7 +1364,7 @@
     if (hasRareData()) {
         ElementRareData* data = elementRareData();
         if (data->needsFocusAppearanceUpdateSoonAfterAttach()) {
-            if (isFocusable() && document()->focusedNode() == this)
+            if (isFocusable() && document()->focusedElement() == this)
                 document()->updateFocusAppearanceSoon(false /* don't restore selection */);
             data->setNeedsFocusAppearanceUpdateSoonAfterAttach(false);
         }
@@ -2024,7 +2025,7 @@
         return;
 
     Document* doc = document();
-    if (doc->focusedNode() == this)
+    if (doc->focusedElement() == this)
         return;
 
     // If the stylesheets have already been loaded we can reliably check isFocusable.
@@ -2407,7 +2408,7 @@
 {
     if (hasRareData())
         elementRareData()->setNeedsFocusAppearanceUpdateSoonAfterAttach(false);
-    if (document()->focusedNode() == this)
+    if (document()->focusedElement() == this)
         document()->cancelFocusAppearanceUpdate();
 }
 
@@ -2799,6 +2800,11 @@
         scope->addLabel(newForAttributeValue, toHTMLLabelElement(this));
 }
 
+static bool hasSelectorForAttribute(Document* document, const AtomicString& localName)
+{
+    return document->styleResolver() && document->styleResolver()->ruleFeatureSet().hasSelectorForAttribute(localName);
+}
+
 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue)
 {
     if (isIdAttributeName(name))
@@ -2812,7 +2818,7 @@
     }
 
     if (oldValue != newValue) {
-        if (attached() && document()->styleResolver() && document()->styleResolver()->hasSelectorForAttribute(name.localName()))
+        if (attached() && hasSelectorForAttribute(document(), name.localName()))
            setNeedsStyleRecalc();
 
         if (isUpgradedCustomElement())
diff --git a/Source/core/dom/Element.h b/Source/core/dom/Element.h
index 8575c9f..35f6e17 100644
--- a/Source/core/dom/Element.h
+++ b/Source/core/dom/Element.h
@@ -481,6 +481,7 @@
     void setIsInCanvasSubtree(bool);
     bool isInCanvasSubtree() const;
 
+    bool isUpgradedCustomElement() { return customElementState() == Upgraded; }
     bool isUnresolvedCustomElement() { return isCustomElement() && !isUpgradedCustomElement(); }
 
     void setIsInsideRegion(bool);
diff --git a/Source/core/dom/Element.idl b/Source/core/dom/Element.idl
index 2dd8467..db0aef0 100644
--- a/Source/core/dom/Element.idl
+++ b/Source/core/dom/Element.idl
@@ -126,32 +126,32 @@
     [NotEnumerable, PerWorldBindings] attribute EventListener onabort;
     [NotEnumerable, PerWorldBindings] attribute EventListener onblur;
     [NotEnumerable, PerWorldBindings] attribute EventListener onchange;
-    [NotEnumerable, PerWorldBindings] attribute EventListener onclick;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onclick;
     [NotEnumerable, PerWorldBindings] attribute EventListener oncontextmenu;
-    [NotEnumerable, PerWorldBindings] attribute EventListener ondblclick;
-    [NotEnumerable, PerWorldBindings] attribute EventListener ondrag;
-    [NotEnumerable, PerWorldBindings] attribute EventListener ondragend;
-    [NotEnumerable, PerWorldBindings] attribute EventListener ondragenter;
-    [NotEnumerable, PerWorldBindings] attribute EventListener ondragleave;
-    [NotEnumerable, PerWorldBindings] attribute EventListener ondragover;
-    [NotEnumerable, PerWorldBindings] attribute EventListener ondragstart;
-    [NotEnumerable, PerWorldBindings] attribute EventListener ondrop;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondblclick;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondrag;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragend;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragenter;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragleave;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragover;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragstart;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondrop;
     [NotEnumerable, PerWorldBindings] attribute EventListener onerror;
     [NotEnumerable, PerWorldBindings] attribute EventListener onfocus;
-    [NotEnumerable, PerWorldBindings] attribute EventListener oninput;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener oninput;
     [NotEnumerable, PerWorldBindings] attribute EventListener oninvalid;
-    [NotEnumerable, PerWorldBindings] attribute EventListener onkeydown;
-    [NotEnumerable, PerWorldBindings] attribute EventListener onkeypress;
-    [NotEnumerable, PerWorldBindings] attribute EventListener onkeyup;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onkeydown;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onkeypress;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onkeyup;
     [NotEnumerable, PerWorldBindings] attribute EventListener onload;
-    [NotEnumerable, PerWorldBindings] attribute EventListener onmousedown;
-    [NotEnumerable, PerWorldBindings] attribute EventListener onmouseenter;
-    [NotEnumerable, PerWorldBindings] attribute EventListener onmouseleave;
-    [NotEnumerable, PerWorldBindings] attribute EventListener onmousemove;
-    [NotEnumerable, PerWorldBindings] attribute EventListener onmouseout;
-    [NotEnumerable, PerWorldBindings] attribute EventListener onmouseover;
-    [NotEnumerable, PerWorldBindings] attribute EventListener onmouseup;
-    [NotEnumerable, PerWorldBindings] attribute EventListener onmousewheel;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmousedown;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseenter;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseleave;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmousemove;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseout;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseover;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseup;
+    [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmousewheel;
     [NotEnumerable, PerWorldBindings] attribute EventListener onscroll;
     [NotEnumerable, PerWorldBindings] attribute EventListener onselect;
     [NotEnumerable, PerWorldBindings] attribute EventListener onsubmit;
diff --git a/Source/core/dom/ErrorEvent.cpp b/Source/core/dom/ErrorEvent.cpp
index f9f4638..db11e53 100644
--- a/Source/core/dom/ErrorEvent.cpp
+++ b/Source/core/dom/ErrorEvent.cpp
@@ -52,15 +52,17 @@
     , m_message(initializer.message)
     , m_fileName(initializer.filename)
     , m_lineNumber(initializer.lineno)
+    , m_columnNumber(initializer.column)
 {
     ScriptWrappable::init(this);
 }
 
-ErrorEvent::ErrorEvent(const String& message, const String& fileName, unsigned lineNumber)
+ErrorEvent::ErrorEvent(const String& message, const String& fileName, unsigned lineNumber, unsigned columnNumber)
     : Event(eventNames().errorEvent, false, true)
     , m_message(message)
     , m_fileName(fileName)
     , m_lineNumber(lineNumber)
+    , m_columnNumber(columnNumber)
 {
     ScriptWrappable::init(this);
 }
diff --git a/Source/core/dom/ErrorEvent.h b/Source/core/dom/ErrorEvent.h
index 0c2a453..1e57e25 100644
--- a/Source/core/dom/ErrorEvent.h
+++ b/Source/core/dom/ErrorEvent.h
@@ -42,6 +42,7 @@
     String message;
     String filename;
     unsigned lineno;
+    unsigned column;
 };
 
 class ErrorEvent : public Event {
@@ -50,9 +51,9 @@
     {
         return adoptRef(new ErrorEvent);
     }
-    static PassRefPtr<ErrorEvent> create(const String& message, const String& fileName, unsigned lineNumber)
+    static PassRefPtr<ErrorEvent> create(const String& message, const String& fileName, unsigned lineNumber, unsigned columnNumber)
     {
-        return adoptRef(new ErrorEvent(message, fileName, lineNumber));
+        return adoptRef(new ErrorEvent(message, fileName, lineNumber, columnNumber));
     }
     static PassRefPtr<ErrorEvent> create(const AtomicString& type, const ErrorEventInit& initializer)
     {
@@ -63,17 +64,19 @@
     const String& message() const { return m_message; }
     const String& filename() const { return m_fileName; }
     unsigned lineno() const { return m_lineNumber; }
+    unsigned column() const { return m_columnNumber; }
 
     virtual const AtomicString& interfaceName() const;
 
 private:
     ErrorEvent();
-    ErrorEvent(const String& message, const String& fileName, unsigned lineNumber);
+    ErrorEvent(const String& message, const String& fileName, unsigned lineNumber, unsigned columnNumber);
     ErrorEvent(const AtomicString&, const ErrorEventInit&);
 
     String m_message;
     String m_fileName;
     unsigned m_lineNumber;
+    unsigned m_columnNumber;
 };
 
 } // namespace WebCore
diff --git a/Source/core/dom/ErrorEvent.idl b/Source/core/dom/ErrorEvent.idl
index 612a970..21195e9 100644
--- a/Source/core/dom/ErrorEvent.idl
+++ b/Source/core/dom/ErrorEvent.idl
@@ -34,5 +34,9 @@
     [InitializedByEventConstructor] readonly attribute DOMString message;
     [InitializedByEventConstructor] readonly attribute DOMString filename;
     [InitializedByEventConstructor] readonly attribute unsigned long lineno;
+
+    // FIXME: Part of the specification but not exposed yet.
+    // No other browser seems to support it (except IE10 as 'colno').
+    // [InitializedByEventConstructor] readonly attribute unsigned long column;
 };
 
diff --git a/Source/core/dom/EventRetargeter.h b/Source/core/dom/EventRetargeter.h
index f274e70..f2e66ca 100644
--- a/Source/core/dom/EventRetargeter.h
+++ b/Source/core/dom/EventRetargeter.h
@@ -85,7 +85,7 @@
     // At this time, SVG nodes are not supported in non-<use> shadow trees.
     if (!shadowHostElement || !shadowHostElement->hasTagName(SVGNames::useTag))
         return referenceNode;
-    SVGUseElement* useElement = static_cast<SVGUseElement*>(shadowHostElement);
+    SVGUseElement* useElement = toSVGUseElement(shadowHostElement);
     if (SVGElementInstance* instance = useElement->instanceForShadowTreeElement(referenceNode))
         return instance;
 
diff --git a/Source/core/dom/MessageEvent.h b/Source/core/dom/MessageEvent.h
index 80965bf..d68bac8 100644
--- a/Source/core/dom/MessageEvent.h
+++ b/Source/core/dom/MessageEvent.h
@@ -98,11 +98,17 @@
         DataTypeArrayBuffer
     };
     DataType dataType() const { return m_dataType; }
-    SerializedScriptValue* dataAsSerializedScriptValue() const { ASSERT(m_dataType == DataTypeSerializedScriptValue); return m_dataAsSerializedScriptValue.get(); }
+    SerializedScriptValue* dataAsSerializedScriptValue() const { ASSERT(m_dataType == DataTypeScriptValue || m_dataType == DataTypeSerializedScriptValue); return m_dataAsSerializedScriptValue.get(); }
     String dataAsString() const { ASSERT(m_dataType == DataTypeString); return m_dataAsString; }
     Blob* dataAsBlob() const { ASSERT(m_dataType == DataTypeBlob); return m_dataAsBlob.get(); }
     ArrayBuffer* dataAsArrayBuffer() const { ASSERT(m_dataType == DataTypeArrayBuffer); return m_dataAsArrayBuffer.get(); }
 
+    void setSerializedData(PassRefPtr<SerializedScriptValue> data)
+    {
+        ASSERT(!m_dataAsSerializedScriptValue);
+        m_dataAsSerializedScriptValue = data;
+    }
+
 private:
     MessageEvent();
     MessageEvent(const AtomicString&, const MessageEventInit&);
diff --git a/Source/core/dom/MessagePort.cpp b/Source/core/dom/MessagePort.cpp
index c83921e..07b4eb1 100644
--- a/Source/core/dom/MessagePort.cpp
+++ b/Source/core/dom/MessagePort.cpp
@@ -27,6 +27,7 @@
 #include "config.h"
 #include "core/dom/MessagePort.h"
 
+#include "bindings/v8/ExceptionState.h"
 #include "core/dom/Document.h"
 #include "core/dom/EventNames.h"
 #include "core/dom/ExceptionCode.h"
@@ -55,7 +56,7 @@
         m_scriptExecutionContext->destroyedMessagePort(this);
 }
 
-void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionCode& ec)
+void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionState& es)
 {
     if (!isEntangled())
         return;
@@ -67,12 +68,12 @@
         for (unsigned int i = 0; i < ports->size(); ++i) {
             MessagePort* dataPort = (*ports)[i].get();
             if (dataPort == this || m_entangledChannel->isConnectedTo(dataPort)) {
-                ec = InvalidStateError;
+                es.throwDOMException(InvalidStateError);
                 return;
             }
         }
-        channels = MessagePort::disentanglePorts(ports, ec);
-        if (ec)
+        channels = MessagePort::disentanglePorts(ports, es);
+        if (es.hadException())
             return;
     }
     m_entangledChannel->postMessageToRemote(message, channels.release());
@@ -188,7 +189,7 @@
     return m_entangledChannel ? m_entangledChannel->locallyEntangledPort(m_scriptExecutionContext) : 0;
 }
 
-PassOwnPtr<MessagePortChannelArray> MessagePort::disentanglePorts(const MessagePortArray* ports, ExceptionCode& ec)
+PassOwnPtr<MessagePortChannelArray> MessagePort::disentanglePorts(const MessagePortArray* ports, ExceptionState& es)
 {
     if (!ports || !ports->size())
         return nullptr;
@@ -200,7 +201,7 @@
     for (unsigned int i = 0; i < ports->size(); ++i) {
         MessagePort* port = (*ports)[i].get();
         if (!port || port->isNeutered() || portSet.contains(port)) {
-            ec = DataCloneError;
+            es.throwDOMException(DataCloneError);
             return nullptr;
         }
         portSet.add(port);
diff --git a/Source/core/dom/MessagePort.h b/Source/core/dom/MessagePort.h
index 5124eb2..f5f63c4 100644
--- a/Source/core/dom/MessagePort.h
+++ b/Source/core/dom/MessagePort.h
@@ -41,6 +41,7 @@
 namespace WebCore {
 
 class Event;
+class ExceptionState;
 class Frame;
 class MessagePort;
 class ScriptExecutionContext;
@@ -53,7 +54,7 @@
     static PassRefPtr<MessagePort> create(ScriptExecutionContext& scriptExecutionContext) { return adoptRef(new MessagePort(scriptExecutionContext)); }
     virtual ~MessagePort();
 
-    void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, ExceptionCode&);
+    void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, ExceptionState&);
 
     void start();
     void close();
@@ -62,7 +63,7 @@
     PassOwnPtr<MessagePortChannel> disentangle();
 
     // Returns 0 if there is an exception, or if the passed-in array is 0/empty.
-    static PassOwnPtr<MessagePortChannelArray> disentanglePorts(const MessagePortArray*, ExceptionCode&);
+    static PassOwnPtr<MessagePortChannelArray> disentanglePorts(const MessagePortArray*, ExceptionState&);
 
     // Returns 0 if the passed array is 0/empty.
     static PassOwnPtr<MessagePortArray> entanglePorts(ScriptExecutionContext&, PassOwnPtr<MessagePortChannelArray>);
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp
index 8860aee..8f63f06 100644
--- a/Source/core/dom/Node.cpp
+++ b/Source/core/dom/Node.cpp
@@ -2681,17 +2681,34 @@
     return document()->userActionElements().isFocused(this);
 }
 
-void Node::setIsCustomElement()
+void Node::setCustomElementState(CustomElementState newState)
 {
-    ASSERT(isHTMLElement() || isSVGElement());
-    setFlag(IsCustomElement);
-}
+    CustomElementState oldState = customElementState();
 
-void Node::setIsUpgradedCustomElement()
-{
-    ASSERT(isCustomElement());
-    setFlag(IsUpgradedCustomElement);
-    setNeedsStyleRecalc(); // :unresolved has changed
+    switch (newState) {
+    case NotCustomElement:
+        ASSERT_NOT_REACHED(); // Everything starts in this state
+        return;
+
+    case UpgradeCandidate:
+        ASSERT(NotCustomElement == oldState);
+        break;
+
+    case Defined:
+        ASSERT(UpgradeCandidate == oldState || NotCustomElement == oldState);
+        break;
+
+    case Upgraded:
+        ASSERT(Defined == oldState);
+        break;
+    }
+
+    ASSERT(isHTMLElement() || isSVGElement());
+    setFlag(newState & 1, CustomElementIsUpgradeCandidateOrUpgraded);
+    setFlag(newState & 2, CustomElementHasDefinitionOrIsUpgraded);
+
+    if (oldState == NotCustomElement || newState == Upgraded)
+        setNeedsStyleRecalc(); // :unresolved has changed
 }
 
 } // namespace WebCore
diff --git a/Source/core/dom/Node.h b/Source/core/dom/Node.h
index 8567496..f71a14a 100644
--- a/Source/core/dom/Node.h
+++ b/Source/core/dom/Node.h
@@ -244,10 +244,15 @@
     bool isAfterPseudoElement() const { return pseudoId() == AFTER; }
     PseudoId pseudoId() const { return (isElementNode() && hasCustomStyleCallbacks()) ? customPseudoId() : NOPSEUDO; }
 
-    bool isCustomElement() const { return getFlag(IsCustomElement); }
-    void setIsCustomElement();
-    bool isUpgradedCustomElement() const { return getFlag(IsUpgradedCustomElement); }
-    void setIsUpgradedCustomElement();
+    enum CustomElementState {
+        NotCustomElement,
+        UpgradeCandidate,
+        Defined,
+        Upgraded
+    };
+    bool isCustomElement() const { return customElementState() != NotCustomElement; }
+    CustomElementState customElementState() const { return CustomElementState((getFlag(CustomElementHasDefinitionOrIsUpgraded) ? 2 : 0) | (getFlag(CustomElementIsUpgradeCandidateOrUpgraded) ? 1 : 0)); }
+    void setCustomElementState(CustomElementState newState);
 
     virtual bool isMediaControlElement() const { return false; }
     virtual bool isMediaControls() const { return false; }
@@ -744,11 +749,11 @@
         V8CollectableDuringMinorGCFlag = 1 << 23,
         IsInsertionPointFlag = 1 << 24,
         IsInShadowTreeFlag = 1 << 25,
-        IsCustomElement = 1 << 26,
 
-        NotifyRendererWithIdenticalStyles = 1 << 27,
+        NotifyRendererWithIdenticalStyles = 1 << 26,
 
-        IsUpgradedCustomElement = 1 << 28,
+        CustomElementIsUpgradeCandidateOrUpgraded = 1 << 27,
+        CustomElementHasDefinitionOrIsUpgraded = 1 << 28,
 
         DefaultNodeFlags = IsParsingChildrenFinishedFlag
     };
diff --git a/Source/core/dom/NodeRenderingContext.cpp b/Source/core/dom/NodeRenderingContext.cpp
index 8ea7f81..f403465 100644
--- a/Source/core/dom/NodeRenderingContext.cpp
+++ b/Source/core/dom/NodeRenderingContext.cpp
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "core/dom/NodeRenderingContext.h"
 
+#include "RuntimeEnabledFeatures.h"
 #include "SVGNames.h"
 #include "core/css/resolver/StyleResolver.h"
 #include "core/dom/ContainerNode.h"
diff --git a/Source/core/dom/ParentNode.idl b/Source/core/dom/ParentNode.idl
index 10b418e..358271b 100644
--- a/Source/core/dom/ParentNode.idl
+++ b/Source/core/dom/ParentNode.idl
@@ -1,5 +1,6 @@
 [
-    NoInterfaceObject
+    NoInterfaceObject,
+    LegacyImplementedInBaseClass
 ] interface ParentNode {
     [PerWorldBindings] readonly attribute HTMLCollection children;
     [PerWorldBindings] readonly attribute Element firstElementChild;
diff --git a/Source/core/dom/PopStateEvent.cpp b/Source/core/dom/PopStateEvent.cpp
index 78456c8..6bd19f3 100644
--- a/Source/core/dom/PopStateEvent.cpp
+++ b/Source/core/dom/PopStateEvent.cpp
@@ -43,7 +43,6 @@
 
 PopStateEvent::PopStateEvent(const AtomicString& type, const PopStateEventInit& initializer)
     : Event(type, initializer)
-    , m_serializedState(0)
     , m_history(0)
 {
     ScriptWrappable::init(this);
diff --git a/Source/core/dom/PopStateEvent.h b/Source/core/dom/PopStateEvent.h
index cbe4627..46f6dd8 100644
--- a/Source/core/dom/PopStateEvent.h
+++ b/Source/core/dom/PopStateEvent.h
@@ -31,11 +31,11 @@
 
 namespace WebCore {
 
-typedef EventInit PopStateEventInit;
-
 class History;
 class SerializedScriptValue;
 
+typedef EventInit PopStateEventInit;
+
 class PopStateEvent : public Event {
 public:
     virtual ~PopStateEvent();
@@ -44,6 +44,11 @@
     static PassRefPtr<PopStateEvent> create(const AtomicString&, const PopStateEventInit&);
 
     SerializedScriptValue* serializedState() const { return m_serializedState.get(); }
+    void setSerializedState(PassRefPtr<SerializedScriptValue> state)
+    {
+        ASSERT(!m_serializedState);
+        m_serializedState = state;
+    }
     History* history() const { return m_history.get(); }
 
     virtual const AtomicString& interfaceName() const;
diff --git a/Source/core/dom/ScriptExecutionContext.cpp b/Source/core/dom/ScriptExecutionContext.cpp
index b292094..6c0b210 100644
--- a/Source/core/dom/ScriptExecutionContext.cpp
+++ b/Source/core/dom/ScriptExecutionContext.cpp
@@ -60,15 +60,17 @@
 class ScriptExecutionContext::PendingException {
     WTF_MAKE_NONCOPYABLE(PendingException);
 public:
-    PendingException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)
+    PendingException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)
         : m_errorMessage(errorMessage)
         , m_lineNumber(lineNumber)
+        , m_columnNumber(columnNumber)
         , m_sourceURL(sourceURL)
         , m_callStack(callStack)
     {
     }
     String m_errorMessage;
     int m_lineNumber;
+    int m_columnNumber;
     String m_sourceURL;
     RefPtr<ScriptCallStack> m_callStack;
 };
@@ -193,7 +195,7 @@
     }
 }
 
-bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& lineNumber, String& sourceURL, CachedScript* cachedScript)
+bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& lineNumber, int& columnNumber, String& sourceURL, CachedScript* cachedScript)
 {
     KURL targetURL = completeURL(sourceURL);
     if (securityOrigin()->canRequest(targetURL) || (cachedScript && cachedScript->passesAccessControlCheck(securityOrigin())))
@@ -201,28 +203,29 @@
     errorMessage = "Script error.";
     sourceURL = String();
     lineNumber = 0;
+    columnNumber = 0;
     return true;
 }
 
-void ScriptExecutionContext::reportException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack, CachedScript* cachedScript)
+void ScriptExecutionContext::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack, CachedScript* cachedScript)
 {
     if (m_inDispatchErrorEvent) {
         if (!m_pendingExceptions)
             m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException> >());
-        m_pendingExceptions->append(adoptPtr(new PendingException(errorMessage, lineNumber, sourceURL, callStack)));
+        m_pendingExceptions->append(adoptPtr(new PendingException(errorMessage, lineNumber, columnNumber, sourceURL, callStack)));
         return;
     }
 
     // First report the original exception and only then all the nested ones.
-    if (!dispatchErrorEvent(errorMessage, lineNumber, sourceURL, cachedScript))
-        logExceptionToConsole(errorMessage, sourceURL, lineNumber, callStack);
+    if (!dispatchErrorEvent(errorMessage, lineNumber, columnNumber, sourceURL, cachedScript))
+        logExceptionToConsole(errorMessage, sourceURL, lineNumber, columnNumber, callStack);
 
     if (!m_pendingExceptions)
         return;
 
     for (size_t i = 0; i < m_pendingExceptions->size(); i++) {
         PendingException* e = m_pendingExceptions->at(i).get();
-        logExceptionToConsole(e->m_errorMessage, e->m_sourceURL, e->m_lineNumber, e->m_callStack);
+        logExceptionToConsole(e->m_errorMessage, e->m_sourceURL, e->m_lineNumber, e->m_columnNumber, e->m_callStack);
     }
     m_pendingExceptions.clear();
 }
@@ -232,7 +235,7 @@
     addMessage(source, level, message, sourceURL, lineNumber, 0, state, requestIdentifier);
 }
 
-bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int lineNumber, const String& sourceURL, CachedScript* cachedScript)
+bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, CachedScript* cachedScript)
 {
     EventTarget* target = errorEventTarget();
     if (!target)
@@ -240,12 +243,13 @@
 
     String message = errorMessage;
     int line = lineNumber;
+    int column = columnNumber;
     String sourceName = sourceURL;
-    sanitizeScriptError(message, line, sourceName, cachedScript);
+    sanitizeScriptError(message, line, column, sourceName, cachedScript);
 
     ASSERT(!m_inDispatchErrorEvent);
     m_inDispatchErrorEvent = true;
-    RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(message, sourceName, line);
+    RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(message, sourceName, line, column);
     target->dispatchEvent(errorEvent);
     m_inDispatchErrorEvent = false;
     return errorEvent->defaultPrevented();
@@ -259,7 +263,7 @@
     return m_circularSequentialID;
 }
 
-int ScriptExecutionContext::installNewTimeout(PassOwnPtr<ScheduledAction> action, int timeout, bool singleShot)
+int ScriptExecutionContext::installNewTimeout(DOMTimer::Type timerType, PassOwnPtr<ScheduledAction> action, int timeout)
 {
     int timeoutID;
     while (true) {
@@ -267,20 +271,25 @@
         if (!m_timeouts.contains(timeoutID))
             break;
     }
-    TimeoutMap::AddResult result = m_timeouts.add(timeoutID, DOMTimer::create(this, action, timeout, singleShot, timeoutID));
+    TimeoutMap::AddResult result = m_timeouts.add(timeoutID, DOMTimer::create(this, timerType, action, timeout, timeoutID));
     ASSERT(result.isNewEntry);
     DOMTimer* timer = result.iterator->value.get();
 
     timer->suspendIfNeeded();
 
-    return timer->timeoutID();
+    return timeoutID;
 }
 
-void ScriptExecutionContext::removeTimeoutByID(int timeoutID)
+bool ScriptExecutionContext::removeTimeoutByIDIfTypeMatches(DOMTimer::Type timerType, int timeoutID)
 {
     if (timeoutID <= 0)
-        return;
-    m_timeouts.remove(timeoutID);
+        return false;
+    TimeoutMap::iterator iter = m_timeouts.find(timeoutID);
+    if (iter != m_timeouts.end() && iter->value->type() == timerType) {
+        m_timeouts.remove(iter);
+        return true;
+    }
+    return false;
 }
 
 PublicURLManager& ScriptExecutionContext::publicURLManager()
diff --git a/Source/core/dom/ScriptExecutionContext.h b/Source/core/dom/ScriptExecutionContext.h
index d438f53..48be118 100644
--- a/Source/core/dom/ScriptExecutionContext.h
+++ b/Source/core/dom/ScriptExecutionContext.h
@@ -69,8 +69,8 @@
 
     virtual void disableEval(const String& errorMessage) = 0;
 
-    bool sanitizeScriptError(String& errorMessage, int& lineNumber, String& sourceURL, CachedScript* = 0);
-    void reportException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>, CachedScript* = 0);
+    bool sanitizeScriptError(String& errorMessage, int& lineNumber, int& columnNumber, String& sourceURL, CachedScript* = 0);
+    void reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>, CachedScript* = 0);
 
     void addConsoleMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, ScriptState* = 0, unsigned long requestIdentifier = 0);
     virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) = 0;
@@ -158,8 +158,8 @@
 
     virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack>, ScriptState* = 0, unsigned long requestIdentifier = 0) = 0;
     virtual EventTarget* errorEventTarget() = 0;
-    virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) = 0;
-    bool dispatchErrorEvent(const String& errorMessage, int lineNumber, const String& sourceURL, CachedScript*);
+    virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) = 0;
+    bool dispatchErrorEvent(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, CachedScript*);
 
     void closeMessagePorts();
 
@@ -168,8 +168,8 @@
     virtual PassOwnPtr<LifecycleNotifier> createLifecycleNotifier() OVERRIDE;
 
     // Implementation details for DOMTimer. No other classes should call these functions.
-    int installNewTimeout(PassOwnPtr<ScheduledAction>, int timeout, bool singleShot);
-    void removeTimeoutByID(int timeoutID); // This makes underlying DOMTimer instance destructed.
+    int installNewTimeout(DOMTimer::Type, PassOwnPtr<ScheduledAction>, int timeout);
+    bool removeTimeoutByIDIfTypeMatches(DOMTimer::Type, int timeoutID); // This makes underlying DOMTimer instance destructed. Returns true if removed.
 
     HashSet<MessagePort*> m_messagePorts;
 
diff --git a/Source/core/dom/TreeScope.cpp b/Source/core/dom/TreeScope.cpp
index df9209c..a5f47dd 100644
--- a/Source/core/dom/TreeScope.cpp
+++ b/Source/core/dom/TreeScope.cpp
@@ -339,7 +339,7 @@
         adopter.execute();
 }
 
-static Node* focusedFrameOwnerElement(Frame* focusedFrame, Frame* currentFrame)
+static Element* focusedFrameOwnerElement(Frame* focusedFrame, Frame* currentFrame)
 {
     for (; focusedFrame; focusedFrame = focusedFrame->tree()->parent()) {
         if (focusedFrame->tree()->parent() == currentFrame)
@@ -351,20 +351,26 @@
 Element* TreeScope::adjustedFocusedElement()
 {
     Document* document = rootNode()->document();
-    Node* node = document->focusedNode();
-    if (!node && document->page())
-        node = focusedFrameOwnerElement(document->page()->focusController()->focusedFrame(), document->frame());
-    if (!node)
+    Element* element = document->focusedElement();
+    if (!element && document->page())
+        element = focusedFrameOwnerElement(document->page()->focusController()->focusedFrame(), document->frame());
+    if (!element)
         return 0;
     Vector<Node*> targetStack;
-    for (EventPathWalker walker(node); walker.node(); walker.moveToParent()) {
+    for (EventPathWalker walker(element); walker.node(); walker.moveToParent()) {
         Node* node = walker.node();
         if (targetStack.isEmpty())
             targetStack.append(node);
         else if (walker.isVisitingInsertionPointInReprojection())
             targetStack.append(targetStack.last());
-        if (node == rootNode())
+        if (node == rootNode()) {
+            // targetStack.last() is one of the followings:
+            // - InsertionPoint
+            // - shadow host
+            // - Document::focusedElement()
+            // So, it's safe to do toElement().
             return toElement(targetStack.last());
+        }
         if (node->isShadowRoot()) {
             ASSERT(!targetStack.isEmpty());
             targetStack.removeLast();
diff --git a/Source/core/dom/UserTypingGestureIndicator.cpp b/Source/core/dom/UserTypingGestureIndicator.cpp
index 1200868..e05967e 100644
--- a/Source/core/dom/UserTypingGestureIndicator.cpp
+++ b/Source/core/dom/UserTypingGestureIndicator.cpp
@@ -27,9 +27,8 @@
 #include "core/dom/UserTypingGestureIndicator.h"
 
 #include "core/dom/Document.h"
-#include "core/dom/Node.h"
+#include "core/dom/Element.h"
 #include "core/page/Frame.h"
-#include "wtf/StdLibExtras.h"
 
 namespace WebCore {
 
@@ -39,29 +38,29 @@
     return s_processingUserTypingGesture;
 }
 
-static RefPtr<Node>& focusedNode()
+static RefPtr<Element>& focusedElement()
 {
-    DEFINE_STATIC_LOCAL(RefPtr<Node>, node, ());
-    return node;
+    DEFINE_STATIC_LOCAL(RefPtr<Element>, element, ());
+    return element;
 }
 
-Node* UserTypingGestureIndicator::focusedElementAtGestureStart()
+Element* UserTypingGestureIndicator::focusedElementAtGestureStart()
 {
-    return focusedNode().get();
+    return focusedElement().get();
 }
 
 UserTypingGestureIndicator::UserTypingGestureIndicator(Frame* frame)
     : m_previousProcessingUserTypingGesture(s_processingUserTypingGesture)
-    , m_previousFocusedNode(focusedNode())
+    , m_previousFocusedElement(focusedElement())
 {
     s_processingUserTypingGesture = true;
-    focusedNode() = frame->document() ? frame->document()->focusedNode() : 0;
+    focusedElement() = frame->document() ? frame->document()->focusedElement() : 0;
 }
 
 UserTypingGestureIndicator::~UserTypingGestureIndicator()
 {
     s_processingUserTypingGesture = m_previousProcessingUserTypingGesture;
-    focusedNode() = m_previousFocusedNode;
+    focusedElement() = m_previousFocusedElement;
 }
 
 } // namespace WebCore
diff --git a/Source/core/dom/UserTypingGestureIndicator.h b/Source/core/dom/UserTypingGestureIndicator.h
index 149c430..02a9794 100644
--- a/Source/core/dom/UserTypingGestureIndicator.h
+++ b/Source/core/dom/UserTypingGestureIndicator.h
@@ -32,20 +32,20 @@
 namespace WebCore {
 
 class Frame;
-class Node;
+class Element;
 
 class UserTypingGestureIndicator {
     WTF_MAKE_NONCOPYABLE(UserTypingGestureIndicator);
 public:
     static bool processingUserTypingGesture();
-    static Node* focusedElementAtGestureStart();
+    static Element* focusedElementAtGestureStart();
 
     explicit UserTypingGestureIndicator(Frame*);
     ~UserTypingGestureIndicator();
 
 private:
     bool m_previousProcessingUserTypingGesture;
-    RefPtr<Node> m_previousFocusedNode;
+    RefPtr<Element> m_previousFocusedElement;
 };    
 
 } // namespace WebCore
diff --git a/Source/core/dom/ViewportArguments.cpp b/Source/core/dom/ViewportArguments.cpp
index d6a56f9..92ae2cf 100644
--- a/Source/core/dom/ViewportArguments.cpp
+++ b/Source/core/dom/ViewportArguments.cpp
@@ -6,7 +6,7 @@
  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2012-2013 Intel Corporation. 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
@@ -37,8 +37,6 @@
 
 static const float& compareIgnoringAuto(const float& value1, const float& value2, const float& (*compare) (const float&, const float&))
 {
-    ASSERT(value1 != ViewportArguments::ValueAuto || value2 != ViewportArguments::ValueAuto);
-
     if (value1 == ViewportArguments::ValueAuto)
         return value2;
 
@@ -78,29 +76,12 @@
     float resultHeight = height;
     float resultMinHeight = minHeight;
     float resultMaxHeight = maxHeight;
+
     float resultZoom = zoom;
     float resultMinZoom = minZoom;
     float resultMaxZoom = maxZoom;
     float resultUserZoom = userZoom;
 
-    switch (int(resultWidth)) {
-    case ViewportArguments::ValueDeviceWidth:
-        resultWidth = deviceSize.width();
-        break;
-    case ViewportArguments::ValueDeviceHeight:
-        resultWidth = deviceSize.height();
-        break;
-    }
-
-    switch (int(resultHeight)) {
-    case ViewportArguments::ValueDeviceWidth:
-        resultHeight = deviceSize.width();
-        break;
-    case ViewportArguments::ValueDeviceHeight:
-        resultHeight = deviceSize.height();
-        break;
-    }
-
     if (type == ViewportArguments::CSSDeviceAdaptation) {
 
         // device-width/device-height not supported for @viewport.
@@ -113,35 +94,97 @@
         ASSERT(resultMaxHeight != ViewportArguments::ValueDeviceWidth);
         ASSERT(resultMaxHeight != ViewportArguments::ValueDeviceHeight);
 
-        if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth != ViewportArguments::ValueAuto)
-            resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAuto(resultMaxWidth, initialViewportSize.width(), min), max);
-
-        if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight != ViewportArguments::ValueAuto)
-            resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringAuto(resultMaxHeight, initialViewportSize.height(), min), max);
-
+        // 1. Resolve min-zoom and max-zoom values.
         if (resultMinZoom != ViewportArguments::ValueAuto && resultMaxZoom != ViewportArguments::ValueAuto)
             resultMaxZoom = max(resultMinZoom, resultMaxZoom);
 
+        // 2. Constrain zoom value to the [min-zoom, max-zoom] range.
         if (resultZoom != ViewportArguments::ValueAuto)
             resultZoom = compareIgnoringAuto(resultMinZoom, compareIgnoringAuto(resultMaxZoom, resultZoom, min), max);
 
-        if (resultWidth == ViewportArguments::ValueAuto && (resultHeight == ViewportArguments::ValueAuto || !initialViewportSize.height()))
-            resultWidth = initialViewportSize.width();
+        float extendZoom = compareIgnoringAuto(resultZoom, resultMaxZoom, min);
 
-        if (resultWidth == ViewportArguments::ValueAuto) {
-            ASSERT(initialViewportSize.height()); // If height is 0, resultWidth should be resolved above.
-            resultWidth = resultHeight * initialViewportSize.width() / initialViewportSize.height();
+        if (extendZoom == ViewportArguments::ValueAuto) {
+            if (resultMaxWidth == ViewportArguments::ValueExtendToZoom)
+                resultMaxWidth = ViewportArguments::ValueAuto;
+
+            if (resultMaxHeight == ViewportArguments::ValueExtendToZoom)
+                resultMaxHeight = ViewportArguments::ValueAuto;
+
+            if (resultMinWidth == ViewportArguments::ValueExtendToZoom)
+                resultMinWidth = resultMaxWidth;
+
+            if (resultMinHeight == ViewportArguments::ValueExtendToZoom)
+                resultMinHeight = resultMaxHeight;
+        } else {
+            float extendWidth = initialViewportSize.width() / extendZoom;
+            float extendHeight = initialViewportSize.height() / extendZoom;
+
+            if (resultMaxWidth == ViewportArguments::ValueExtendToZoom)
+                resultMaxWidth = extendWidth;
+
+            if (resultMaxHeight == ViewportArguments::ValueExtendToZoom)
+                resultMaxHeight = extendHeight;
+
+            if (resultMinWidth == ViewportArguments::ValueExtendToZoom)
+                resultMinWidth = compareIgnoringAuto(extendWidth, resultMaxWidth, max);
+
+            if (resultMinHeight == ViewportArguments::ValueExtendToZoom)
+                resultMinHeight = compareIgnoringAuto(extendHeight, resultMaxHeight, max);
         }
 
+        // 4. Resolve initial width from min/max descriptors.
+        if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth != ViewportArguments::ValueAuto)
+            resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAuto(resultMaxWidth, initialViewportSize.width(), min), max);
+
+        // 5. Resolve initial height from min/max descriptors.
+        if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight != ViewportArguments::ValueAuto)
+            resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringAuto(resultMaxHeight, initialViewportSize.height(), min), max);
+
+        // 6-7. Resolve width value.
+        if (resultWidth == ViewportArguments::ValueAuto) {
+            if (resultHeight == ViewportArguments::ValueAuto || !initialViewportSize .height())
+                resultWidth = initialViewportSize.width();
+            else
+                resultWidth = resultHeight * (initialViewportSize.width() / initialViewportSize.height());
+        }
+
+        // 8. Resolve height value.
         if (resultHeight == ViewportArguments::ValueAuto) {
             if (!initialViewportSize.width())
                 resultHeight = initialViewportSize.height();
             else
                 resultHeight = resultWidth * initialViewportSize.height() / initialViewportSize.width();
         }
+
+        PageScaleConstraints result;
+        result.minimumScale = resultMinZoom;
+        result.maximumScale = resultMaxZoom;
+        result.initialScale = resultZoom;
+        result.layoutSize.setWidth(resultWidth);
+        result.layoutSize.setHeight(resultHeight);
+        return result;
     }
 
-    if (type != ViewportArguments::CSSDeviceAdaptation && type != ViewportArguments::Implicit) {
+    switch (static_cast<int>(resultWidth)) {
+    case ViewportArguments::ValueDeviceWidth:
+        resultWidth = deviceSize.width();
+        break;
+    case ViewportArguments::ValueDeviceHeight:
+        resultWidth = deviceSize.height();
+        break;
+    }
+
+    switch (static_cast<int>(resultHeight)) {
+    case ViewportArguments::ValueDeviceWidth:
+        resultHeight = deviceSize.width();
+        break;
+    case ViewportArguments::ValueDeviceHeight:
+        resultHeight = deviceSize.height();
+        break;
+    }
+
+    if (type != ViewportArguments::Implicit) {
         // Clamp values to a valid range, but not for @viewport since is
         // not mandated by the specification.
         resultWidth = clampLengthValue(resultWidth);
diff --git a/Source/core/dom/ViewportArguments.h b/Source/core/dom/ViewportArguments.h
index 925604a..5afacfe 100644
--- a/Source/core/dom/ViewportArguments.h
+++ b/Source/core/dom/ViewportArguments.h
@@ -6,7 +6,7 @@
  * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2012-2013 Intel Corporation. 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
@@ -65,7 +65,8 @@
         ValueDeviceDPI = -6,
         ValueLowDPI = -7,
         ValueMediumDPI = -8,
-        ValueHighDPI = -9
+        ValueHighDPI = -9,
+        ValueExtendToZoom = -10
     };
 
     ViewportArguments(Type type = Implicit)
diff --git a/Source/core/dom/shadow/ElementShadow.cpp b/Source/core/dom/shadow/ElementShadow.cpp
index 4518e29..b767737 100644
--- a/Source/core/dom/shadow/ElementShadow.cpp
+++ b/Source/core/dom/shadow/ElementShadow.cpp
@@ -56,7 +56,7 @@
 
     while (RefPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) {
         InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get());
-        shadowHost->document()->removeFocusedNodeOfSubtree(oldRoot.get());
+        shadowHost->document()->removeFocusedElementOfSubtree(oldRoot.get());
 
         if (oldRoot->attached())
             oldRoot->detach();
diff --git a/Source/core/editing/Editor.cpp b/Source/core/editing/Editor.cpp
index f55face..5f42c16 100644
--- a/Source/core/editing/Editor.cpp
+++ b/Source/core/editing/Editor.cpp
@@ -324,7 +324,7 @@
     Node* target = findEventTargetFromSelection();
     if (!target)
         return;
-    target->dispatchEvent(TextEvent::createForPlainTextPaste(m_frame->document()->domWindow(), pastingText, smartReplace), IGNORE_EXCEPTION);
+    target->dispatchEvent(TextEvent::createForPlainTextPaste(m_frame->domWindow(), pastingText, smartReplace), IGNORE_EXCEPTION);
 }
 
 void Editor::pasteAsFragment(PassRefPtr<DocumentFragment> pastingFragment, bool smartReplace, bool matchStyle)
@@ -332,7 +332,7 @@
     Node* target = findEventTargetFromSelection();
     if (!target)
         return;
-    target->dispatchEvent(TextEvent::createForFragmentPaste(m_frame->document()->domWindow(), pastingFragment, smartReplace, matchStyle), IGNORE_EXCEPTION);
+    target->dispatchEvent(TextEvent::createForFragmentPaste(m_frame->domWindow(), pastingFragment, smartReplace, matchStyle), IGNORE_EXCEPTION);
 }
 
 void Editor::pasteAsPlainTextBypassingDHTML()
@@ -1064,12 +1064,12 @@
 
 void Editor::setBaseWritingDirection(WritingDirection direction)
 {
-    Node* focusedNode = frame()->document()->focusedNode();
-    if (focusedNode && isHTMLTextFormControlElement(focusedNode)) {
+    Node* focusedElement = frame()->document()->focusedElement();
+    if (focusedElement && isHTMLTextFormControlElement(focusedElement)) {
         if (direction == NaturalWritingDirection)
             return;
-        toHTMLElement(focusedNode)->setAttribute(dirAttr, direction == LeftToRightWritingDirection ? "ltr" : "rtl");
-        focusedNode->dispatchInputEvent();
+        toHTMLElement(focusedElement)->setAttribute(dirAttr, direction == LeftToRightWritingDirection ? "ltr" : "rtl");
+        focusedElement->dispatchInputEvent();
         frame()->document()->updateStyleIfNeeded();
         return;
     }
@@ -1183,9 +1183,8 @@
     // Dispatch a compositionend event to the focused node.
     // We should send this event before sending a TextEvent as written in Section 6.2.2 and 6.2.3 of
     // the DOM Event specification.
-    Node* target = m_frame->document()->focusedNode();
-    if (target) {
-        RefPtr<CompositionEvent> event = CompositionEvent::create(eventNames().compositionendEvent, m_frame->document()->domWindow(), text);
+    if (Element* target = m_frame->document()->focusedElement()) {
+        RefPtr<CompositionEvent> event = CompositionEvent::create(eventNames().compositionendEvent, m_frame->domWindow(), text);
         target->dispatchEvent(event, IGNORE_EXCEPTION);
     }
 
@@ -1225,8 +1224,7 @@
         return;
     }
 
-    Node* target = m_frame->document()->focusedNode();
-    if (target) {
+    if (Element* target = m_frame->document()->focusedElement()) {
         // Dispatch an appropriate composition event to the focused node.
         // We check the composition status and choose an appropriate composition event since this
         // function is used for three purposes:
@@ -1247,14 +1245,14 @@
             // We should send a compositionstart event only when the given text is not empty because this
             // function doesn't create a composition node when the text is empty.
             if (!text.isEmpty()) {
-                target->dispatchEvent(CompositionEvent::create(eventNames().compositionstartEvent, m_frame->document()->domWindow(), selectedText()));
-                event = CompositionEvent::create(eventNames().compositionupdateEvent, m_frame->document()->domWindow(), text);
+                target->dispatchEvent(CompositionEvent::create(eventNames().compositionstartEvent, m_frame->domWindow(), selectedText()));
+                event = CompositionEvent::create(eventNames().compositionupdateEvent, m_frame->domWindow(), text);
             }
         } else {
             if (!text.isEmpty())
-                event = CompositionEvent::create(eventNames().compositionupdateEvent, m_frame->document()->domWindow(), text);
+                event = CompositionEvent::create(eventNames().compositionupdateEvent, m_frame->domWindow(), text);
             else
-              event = CompositionEvent::create(eventNames().compositionendEvent, m_frame->document()->domWindow(), text);
+                event = CompositionEvent::create(eventNames().compositionendEvent, m_frame->domWindow(), text);
         }
         if (event.get())
             target->dispatchEvent(event, IGNORE_EXCEPTION);
diff --git a/Source/core/editing/EditorCommand.cpp b/Source/core/editing/EditorCommand.cpp
index ce72ca2..dda179f 100644
--- a/Source/core/editing/EditorCommand.cpp
+++ b/Source/core/editing/EditorCommand.cpp
@@ -247,16 +247,16 @@
 
 static unsigned verticalScrollDistance(Frame* frame)
 {
-    Node* focusedNode = frame->document()->focusedNode();
-    if (!focusedNode)
+    Element* focusedElement = frame->document()->focusedElement();
+    if (!focusedElement)
         return 0;
-    RenderObject* renderer = focusedNode->renderer();
+    RenderObject* renderer = focusedElement->renderer();
     if (!renderer || !renderer->isBox())
         return 0;
     RenderStyle* style = renderer->style();
     if (!style)
         return 0;
-    if (!(style->overflowY() == OSCROLL || style->overflowY() == OAUTO || focusedNode->rendererIsEditable()))
+    if (!(style->overflowY() == OSCROLL || style->overflowY() == OAUTO || focusedElement->rendererIsEditable()))
         return 0;
     int height = std::min<int>(toRenderBox(renderer)->clientHeight(), frame->view()->visibleHeight());
     return static_cast<unsigned>(max(max<int>(height * Scrollbar::minFractionToStepWhenPaging(), height - Scrollbar::maxOverlapBetweenPages()), 1));
diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp
index 4ff8d91..9c662c4 100644
--- a/Source/core/editing/FrameSelection.cpp
+++ b/Source/core/editing/FrameSelection.cpp
@@ -1616,8 +1616,8 @@
 {
     Document* document = m_frame->document();
 
-    if (document->focusedNode() && document->focusedNode()->hasTagName(selectTag)) {
-        HTMLSelectElement* selectElement = toHTMLSelectElement(document->focusedNode());
+    if (document->focusedElement() && document->focusedElement()->hasTagName(selectTag)) {
+        HTMLSelectElement* selectElement = toHTMLSelectElement(document->focusedElement());
         if (selectElement->canSelectAll()) {
             selectElement->selectAll();
             return;
@@ -1713,11 +1713,12 @@
     // Because StyleResolver::checkOneSelector() and
     // RenderTheme::isFocused() check if the frame is active, we have to
     // update style and theme state that depended on those.
-    if (Node* node = m_frame->document()->focusedNode()) {
-        node->setNeedsStyleRecalc();
-        if (RenderObject* renderer = node->renderer())
+    if (Element* element = m_frame->document()->focusedElement()) {
+        element->setNeedsStyleRecalc();
+        if (RenderObject* renderer = element->renderer()) {
             if (renderer && renderer->style()->hasAppearance())
                 renderer->theme()->stateChanged(renderer, FocusState);
+        }
     }
 
     // Secure keyboard entry is set by the active frame.
@@ -1860,11 +1861,11 @@
     if (!root)
         return false;
 
-    Node* focusedNode = root->document()->focusedNode();
-    if (!focusedNode)
+    Element* focusedElement = root->document()->focusedElement();
+    if (!focusedElement)
         return false;
 
-    return focusedNode->containsIncludingShadowDOM(m_selection.start().anchorNode());
+    return focusedElement->containsIncludingShadowDOM(m_selection.start().anchorNode());
 }
 
 void FrameSelection::caretBlinkTimerFired(Timer<FrameSelection>*)
@@ -2003,7 +2004,7 @@
 HTMLFormElement* FrameSelection::currentForm() const
 {
     // Start looking either at the active (first responder) node, or where the selection is.
-    Node* start = m_frame->document()->focusedNode();
+    Node* start = m_frame->document()->focusedElement();
     if (!start)
         start = this->start().deprecatedNode();
 
diff --git a/Source/core/editing/TextCheckingHelper.cpp b/Source/core/editing/TextCheckingHelper.cpp
index 6a62891..e45ebf5 100644
--- a/Source/core/editing/TextCheckingHelper.cpp
+++ b/Source/core/editing/TextCheckingHelper.cpp
@@ -237,15 +237,14 @@
     int currentChunkOffset = 0;
 
     while (!it.atEnd()) {
-        const UChar* chars = it.characters();
-        int len = it.length();
+        int length = it.length();
         
         // Skip some work for one-space-char hunks
-        if (!(len == 1 && chars[0] == ' ')) {
+        if (!(length == 1 && it.characterAt(0) == ' ')) {
             
             int misspellingLocation = -1;
             int misspellingLength = 0;
-            m_client->textChecker()->checkSpellingOfString(String(chars, len), &misspellingLocation, &misspellingLength);
+            m_client->textChecker()->checkSpellingOfString(it.substring(0, length), &misspellingLocation, &misspellingLength);
 
             // 5490627 shows that there was some code path here where the String constructor below crashes.
             // We don't know exactly what combination of bad input caused this, so we're making this much
@@ -253,11 +252,11 @@
             ASSERT(misspellingLength >= 0);
             ASSERT(misspellingLocation >= -1);
             ASSERT(!misspellingLength || misspellingLocation >= 0);
-            ASSERT(misspellingLocation < len);
-            ASSERT(misspellingLength <= len);
-            ASSERT(misspellingLocation + misspellingLength <= len);
+            ASSERT(misspellingLocation < length);
+            ASSERT(misspellingLength <= length);
+            ASSERT(misspellingLocation + misspellingLength <= length);
             
-            if (misspellingLocation >= 0 && misspellingLength > 0 && misspellingLocation < len && misspellingLength <= len && misspellingLocation + misspellingLength <= len) {
+            if (misspellingLocation >= 0 && misspellingLength > 0 && misspellingLocation < length && misspellingLength <= length && misspellingLocation + misspellingLength <= length) {
                 
                 // Compute range of misspelled word
                 RefPtr<Range> misspellingRange = TextIterator::subrange(m_range.get(), currentChunkOffset + misspellingLocation, misspellingLength);
@@ -265,7 +264,7 @@
                 // Remember first-encountered misspelling and its offset.
                 if (!firstMisspelling) {
                     firstMisspellingOffset = currentChunkOffset + misspellingLocation;
-                    firstMisspelling = String(chars + misspellingLocation, misspellingLength);
+                    firstMisspelling = it.substring(misspellingLocation, misspellingLength);
                     firstMisspellingRange = misspellingRange;
                 }
 
@@ -277,8 +276,8 @@
                     break;
             }
         }
-        
-        currentChunkOffset += len;
+
+        currentChunkOffset += length;
         it.advance();
     }
     
diff --git a/Source/core/editing/TextIterator.cpp b/Source/core/editing/TextIterator.cpp
index 6e8d1ea..693af04 100644
--- a/Source/core/editing/TextIterator.cpp
+++ b/Source/core/editing/TextIterator.cpp
@@ -71,7 +71,10 @@
     ~SearchBuffer();
 
     // Returns number of characters appended; guaranteed to be in the range [1, length].
-    size_t append(const UChar*, size_t length);
+    template<typename CharType>
+    void append(const CharType*, size_t length);
+    size_t numberOfCharactersJustAppended() const { return m_numberOfCharactersJustAppended; }
+
     bool needsMoreContext() const;
     void prependContext(const UChar*, size_t length);
     void reachedBreak();
@@ -91,6 +94,7 @@
     Vector<UChar> m_buffer;
     size_t m_overlap;
     size_t m_prefixLength;
+    size_t m_numberOfCharactersJustAppended;
     bool m_atBreak;
     bool m_needsMoreContext;
 
@@ -230,7 +234,6 @@
     , m_endContainer(0)
     , m_endOffset(0)
     , m_positionNode(0)
-    , m_textCharacters(0)
     , m_textLength(0)
     , m_remainingTextBox(0)
     , m_firstLetterText(0)
@@ -425,18 +428,40 @@
     if (!(index < static_cast<unsigned>(length())))
         return 0;
 
-    if (!m_textCharacters)
-        return string()[startOffset() + index];
+    if (m_singleCharacterBuffer) {
+        ASSERT(!index);
+        ASSERT(length() == 1);
+        return m_singleCharacterBuffer;
+    }
 
-    return m_textCharacters[index];
+    return string()[startOffset() + index];
 }
 
-void TextIterator::appendTextToStringBuilder(StringBuilder& builder) const
+String TextIterator::substring(unsigned position, unsigned length) const
 {
-    if (!m_textCharacters)
-        builder.append(string(), startOffset(), length());
-    else
-        builder.append(characters(), length());
+    ASSERT_WITH_SECURITY_IMPLICATION(position < static_cast<unsigned>(this->length()));
+    ASSERT_WITH_SECURITY_IMPLICATION(position + length <= static_cast<unsigned>(this->length()));
+    if (!length)
+        return emptyString();
+    if (m_singleCharacterBuffer) {
+        ASSERT(!position);
+        ASSERT(length == 1);
+        return String(&m_singleCharacterBuffer, 1);
+    }
+    return string().substring(startOffset() + position, length);
+}
+
+void TextIterator::appendTextToStringBuilder(StringBuilder& builder, unsigned position, unsigned maxLength) const
+{
+    unsigned lengthToAppend = std::min(static_cast<unsigned>(length()) - position, maxLength);
+    if (!lengthToAppend)
+        return;
+    if (m_singleCharacterBuffer) {
+        ASSERT(!position);
+        builder.append(m_singleCharacterBuffer);
+    } else {
+        builder.append(string(), startOffset() + position, lengthToAppend);
+    }
 }
 
 bool TextIterator::handleTextNode()
@@ -667,7 +692,7 @@
     m_positionOffsetBaseNode = m_node;
     m_positionStartOffset = 0;
     m_positionEndOffset = 1;
-    m_textCharacters = 0;
+    m_singleCharacterBuffer = 0;
 
     if (m_emitsImageAltText && renderer->isImage() && renderer->isRenderImage()) {
         m_text = toRenderImage(renderer)->altText();
@@ -980,7 +1005,7 @@
  
     // remember information with which to construct the TextIterator::characters() and length()
     m_singleCharacterBuffer = c;
-    m_textCharacters = &m_singleCharacterBuffer;
+    ASSERT(m_singleCharacterBuffer);
     m_textLength = 1;
 
     // remember some iteration state
@@ -1001,7 +1026,7 @@
     m_positionOffsetBaseNode = 0;
     m_positionStartOffset = textStartOffset;
     m_positionEndOffset = textEndOffset;
-    m_textCharacters = 0;
+    m_singleCharacterBuffer = 0;
     m_textLength = textEndOffset - textStartOffset;
     m_lastCharacter = m_text[textEndOffset - 1];
 
@@ -1063,7 +1088,7 @@
     , m_positionNode(0)
     , m_positionStartOffset(0)
     , m_positionEndOffset(0)
-    , m_textCharacters(0)
+    , m_textOffset(0)
     , m_textLength(0)
     , m_lastTextNode(0)
     , m_lastCharacter(0)
@@ -1228,9 +1253,10 @@
     ASSERT(m_positionStartOffset <= m_positionEndOffset);
 
     m_textLength = m_positionEndOffset - m_positionStartOffset;
-    m_textCharacters = text.bloatedCharacters() + (m_positionStartOffset - offsetInNode);
-    ASSERT(m_textCharacters >= text.bloatedCharacters());
-    RELEASE_ASSERT(m_textCharacters + m_textLength <= text.bloatedCharacters() + static_cast<int>(text.length()));
+    m_textOffset = m_positionStartOffset - offsetInNode;
+    m_textContainer = text;
+    m_singleCharacterBuffer = 0;
+    RELEASE_ASSERT(static_cast<unsigned>(m_textOffset + m_textLength) <= text.length());
 
     m_lastCharacter = text[m_positionEndOffset - 1];
 
@@ -1305,7 +1331,7 @@
     m_positionNode = node;
     m_positionStartOffset = startOffset;
     m_positionEndOffset = endOffset;
-    m_textCharacters = &m_singleCharacterBuffer;
+    m_textOffset = 0;
     m_textLength = 1;
     m_lastCharacter = c;
 }
@@ -1405,15 +1431,15 @@
 
 String CharacterIterator::string(int numChars)
 {
-    Vector<UChar> result;
-    result.reserveInitialCapacity(numChars);
+    StringBuilder result;
+    result.reserveCapacity(numChars);
     while (numChars > 0 && !atEnd()) {
         int runSize = min(numChars, length());
-        result.append(characters(), runSize);
+        m_textIterator.appendTextToStringBuilder(result, m_runOffset, runSize);
         numChars -= runSize;
         advance(runSize);
     }
-    return String::adopt(result);
+    return result.toString();
 }
 
 static PassRefPtr<Range> characterSubrange(CharacterIterator& it, int offset, int length)
@@ -1498,31 +1524,22 @@
 
 // --------
 
-WordAwareIterator::WordAwareIterator(const Range* r)
-    : m_previousText(0)
-    , m_didLookAhead(true) // so we consider the first chunk from the text iterator
-    , m_textIterator(r)
+WordAwareIterator::WordAwareIterator(const Range* range)
+    : m_didLookAhead(true) // So we consider the first chunk from the text iterator.
+    , m_textIterator(range)
 {
-    advance(); // get in position over the first chunk of text
+    advance(); // Get in position over the first chunk of text.
 }
 
 WordAwareIterator::~WordAwareIterator()
 {
 }
 
-// We're always in one of these modes:
-// - The current chunk in the text iterator is our current chunk
-//      (typically its a piece of whitespace, or text that ended with whitespace)
-// - The previous chunk in the text iterator is our current chunk
-//      (we looked ahead to the next chunk and found a word boundary)
-// - We built up our own chunk of text from many chunks from the text iterator
-
 // FIXME: Performance could be bad for huge spans next to each other that don't fall on word boundaries.
 
 void WordAwareIterator::advance()
 {
-    m_previousText = 0;
-    m_buffer.clear();      // toss any old buffer we built up
+    m_buffer.clear();
 
     // If last time we did a look-ahead, start with that looked-ahead chunk now
     if (!m_didLookAhead) {
@@ -1531,9 +1548,10 @@
     }
     m_didLookAhead = false;
 
-    // Go to next non-empty chunk 
+    // Go to next non-empty chunk.
     while (!m_textIterator.atEnd() && m_textIterator.length() == 0)
         m_textIterator.advance();
+
     m_range = m_textIterator.range();
 
     if (m_textIterator.atEnd())
@@ -1541,28 +1559,22 @@
     
     while (1) {
         // If this chunk ends in whitespace we can just use it as our chunk.
-        if (isSpaceOrNewline(m_textIterator.characters()[m_textIterator.length() - 1]))
+        if (isSpaceOrNewline(m_textIterator.characterAt(m_textIterator.length() - 1)))
             return;
 
-        // If this is the first chunk that failed, save it in previousText before look ahead
-        if (m_buffer.isEmpty()) {
-            m_previousText = m_textIterator.characters();
-            m_previousLength = m_textIterator.length();
-        }
+        // If this is the first chunk that failed, save it in m_buffer before look ahead.
+        if (m_buffer.isEmpty())
+            m_textIterator.appendTextTo(m_buffer);
 
-        // Look ahead to next chunk.  If it is whitespace or a break, we can use the previous stuff
+        // Look ahead to next chunk. If it is whitespace or a break, we can use the previous stuff
         m_textIterator.advance();
-        if (m_textIterator.atEnd() || m_textIterator.length() == 0 || isSpaceOrNewline(m_textIterator.characters()[0])) {
+        if (m_textIterator.atEnd() || !m_textIterator.length() || isSpaceOrNewline(m_textIterator.characterAt(0))) {
             m_didLookAhead = true;
             return;
         }
 
-        if (m_buffer.isEmpty()) {
-            // Start gobbling chunks until we get to a suitable stopping point
-            m_buffer.append(m_previousText, m_previousLength);
-            m_previousText = 0;
-        }
-        m_buffer.append(m_textIterator.characters(), m_textIterator.length());
+        // Start gobbling chunks until we get to a suitable stopping point
+        m_textIterator.appendTextTo(m_buffer);
         int exception = 0;
         m_range->setEnd(m_textIterator.range()->endContainer(), m_textIterator.range()->endOffset(), exception);
     }
@@ -1572,18 +1584,21 @@
 {
     if (!m_buffer.isEmpty())
         return m_buffer.size();
-    if (m_previousText)
-        return m_previousLength;
     return m_textIterator.length();
 }
 
-const UChar* WordAwareIterator::characters() const
+String WordAwareIterator::substring(unsigned position, unsigned length) const
 {
     if (!m_buffer.isEmpty())
-        return m_buffer.data();
-    if (m_previousText)
-        return m_previousText;
-    return m_textIterator.characters();
+        return String(m_buffer.data() + position, length);
+    return m_textIterator.substring(position, length);
+}
+
+UChar WordAwareIterator::characterAt(unsigned index) const
+{
+    if (!m_buffer.isEmpty())
+        return m_buffer[index];
+    return m_textIterator.characterAt(index);
 }
 
 // --------
@@ -1892,6 +1907,7 @@
 inline SearchBuffer::SearchBuffer(const String& target, FindOptions options)
     : m_options(options)
     , m_prefixLength(0)
+    , m_numberOfCharactersJustAppended(0)
     , m_atBreak(true)
     , m_needsMoreContext(options & AtWordStarts)
     , m_targetRequiresKanaWorkaround(containsKanaLetters(target))
@@ -1952,7 +1968,8 @@
     unlockSearcher();
 }
 
-inline size_t SearchBuffer::append(const UChar* characters, size_t length)
+template<typename CharType>
+inline void SearchBuffer::append(const CharType* characters, size_t length)
 {
     ASSERT(length);
 
@@ -1969,9 +1986,11 @@
     size_t oldLength = m_buffer.size();
     size_t usableLength = min(m_buffer.capacity() - oldLength, length);
     ASSERT(usableLength);
-    m_buffer.append(characters, usableLength);
-    foldQuoteMarksAndSoftHyphens(m_buffer.data() + oldLength, usableLength);
-    return usableLength;
+    m_buffer.resize(oldLength + usableLength);
+    UChar* destination = m_buffer.data() + oldLength;
+    StringImpl::copyChars(destination, characters, usableLength);
+    foldQuoteMarksAndSoftHyphens(destination, usableLength);
+    m_numberOfCharactersJustAppended = usableLength;
 }
 
 inline bool SearchBuffer::needsMoreContext() const
@@ -2380,14 +2399,17 @@
         RefPtr<Range> beforeStartRange = startRange->ownerDocument()->createRange();
         beforeStartRange->setEnd(startRange->startContainer(), startRange->startOffset(), IGNORE_EXCEPTION);
         for (SimplifiedBackwardsTextIterator backwardsIterator(beforeStartRange.get()); !backwardsIterator.atEnd(); backwardsIterator.advance()) {
-            buffer.prependContext(backwardsIterator.characters(), backwardsIterator.length());
+            Vector<UChar, 1024> characters;
+            backwardsIterator.prependTextTo(characters);
+            buffer.prependContext(characters.data(), characters.size());
             if (!buffer.needsMoreContext())
                 break;
         }
     }
 
     while (!it.atEnd()) {
-        it.advance(buffer.append(it.characters(), it.length()));
+        it.appendTextTo(buffer);
+        it.advance(buffer.numberOfCharactersJustAppended());
 tryAgain:
         size_t matchStartOffset;
         if (size_t newMatchLength = buffer.search(matchStartOffset)) {
diff --git a/Source/core/editing/TextIterator.h b/Source/core/editing/TextIterator.h
index ff0f4a2..716e73c 100644
--- a/Source/core/editing/TextIterator.h
+++ b/Source/core/editing/TextIterator.h
@@ -93,10 +93,26 @@
     void advance();
     
     int length() const { return m_textLength; }
-    const UChar* characters() const { return m_textCharacters ? m_textCharacters : m_text.bloatedCharacters() + startOffset(); }
     UChar characterAt(unsigned index) const;
-    void appendTextToStringBuilder(StringBuilder&) const;
-    
+    String substring(unsigned position, unsigned length) const;
+    void appendTextToStringBuilder(StringBuilder&, unsigned position = 0, unsigned maxLength = UINT_MAX) const;
+
+    template<typename BufferType>
+    void appendTextTo(BufferType& output, unsigned position = 0)
+    {
+        ASSERT_WITH_SECURITY_IMPLICATION(position <= static_cast<unsigned>(length()));
+        unsigned lengthToAppend = length() - position;
+        if (!lengthToAppend)
+            return;
+        if (m_singleCharacterBuffer) {
+            ASSERT(!position);
+            ASSERT(length() == 1);
+            output.append(&m_singleCharacterBuffer, 1);
+        } else {
+            string().appendTo(output, startOffset() + position, lengthToAppend);
+        }
+    }
+
     PassRefPtr<Range> range() const;
     Node* node() const;
      
@@ -142,9 +158,7 @@
     mutable Node* m_positionOffsetBaseNode;
     mutable int m_positionStartOffset;
     mutable int m_positionEndOffset;
-    const UChar* m_textCharacters; // If null, then use m_text for character data.
     int m_textLength;
-    // Hold string m_textCharacters points to so we ensure it won't be deleted.
     String m_text;
 
     // Used when there is still some pending text from the current node; when these
@@ -161,8 +175,9 @@
     Node* m_lastTextNode;    
     bool m_lastTextNodeEndedWithCollapsedSpace;
     UChar m_lastCharacter;
-    
+
     // Used for whitespace characters that aren't in the DOM, so we can point at them.
+    // If non-zero, overrides m_text.
     UChar m_singleCharacterBuffer;
     
     // Used when text boxes are out of order (Hebrew/Arabic w/ embeded LTR text)
@@ -203,15 +218,25 @@
 class SimplifiedBackwardsTextIterator {
 public:
     explicit SimplifiedBackwardsTextIterator(const Range*, TextIteratorBehavior = TextIteratorDefaultBehavior);
-    
+
     bool atEnd() const { return !m_positionNode || m_shouldStop; }
     void advance();
-    
+
     int length() const { return m_textLength; }
-    const UChar* characters() const { return m_textCharacters; }
-    
+
+    template<typename BufferType>
+    void prependTextTo(BufferType& output)
+    {
+        if (!m_textLength)
+            return;
+        if (m_singleCharacterBuffer)
+            output.prepend(&m_singleCharacterBuffer, 1);
+        else
+            m_textContainer.prependTo(output, m_textOffset, m_textLength);
+    }
+
     PassRefPtr<Range> range() const;
-        
+
 private:
     void exitNode();
     bool handleTextNode();
@@ -235,12 +260,14 @@
     // Start of the range.
     Node* m_endNode;
     int m_endOffset;
-    
+
     // The current text and its position, in the form to be returned from the iterator.
     Node* m_positionNode;
     int m_positionStartOffset;
     int m_positionEndOffset;
-    const UChar* m_textCharacters;
+
+    String m_textContainer; // We're interested in the range [m_textOffset, m_textOffset + m_textLength) of m_textContainer.
+    int m_textOffset;
     int m_textLength;
 
     // Used to do the whitespace logic.
@@ -278,12 +305,16 @@
     bool atEnd() const { return m_textIterator.atEnd(); }
     
     int length() const { return m_textIterator.length() - m_runOffset; }
-    const UChar* characters() const { return m_textIterator.characters() + m_runOffset; }
+    UChar characterAt(unsigned index) const { return m_textIterator.characterAt(m_runOffset + index); }
+
+    template<typename BufferType>
+    void appendTextTo(BufferType& output) { m_textIterator.appendTextTo(output, m_runOffset); }
+
     String string(int numChars);
     
     int characterOffset() const { return m_offset; }
     PassRefPtr<Range> range() const;
-        
+
 private:
     int m_offset;
     int m_runOffset;
@@ -320,25 +351,18 @@
     bool atEnd() const { return !m_didLookAhead && m_textIterator.atEnd(); }
     void advance();
     
+    String substring(unsigned position, unsigned length) const;
+    UChar characterAt(unsigned index) const;
     int length() const;
-    const UChar* characters() const;
-    
+
     // Range of the text we're currently returning
     PassRefPtr<Range> range() const { return m_range; }
 
 private:
-    // text from the previous chunk from the textIterator
-    const UChar* m_previousText;
-    int m_previousLength;
-
-    // many chunks from textIterator concatenated
     Vector<UChar> m_buffer;
-    
     // Did we have to look ahead in the textIterator to confirm the current chunk?
     bool m_didLookAhead;
-
     RefPtr<Range> m_range;
-
     TextIterator m_textIterator;
 };
 
diff --git a/Source/core/editing/VisibleSelection.cpp b/Source/core/editing/VisibleSelection.cpp
index 8c19083..6b69829 100644
--- a/Source/core/editing/VisibleSelection.cpp
+++ b/Source/core/editing/VisibleSelection.cpp
@@ -241,7 +241,7 @@
     CharacterIterator charIt(searchRange.get(), TextIteratorEmitsCharactersBetweenAllVisiblePositions);
 
     for (; charIt.length(); charIt.advance(1)) {
-        UChar c = charIt.characters()[0];
+        UChar c = charIt.characterAt(0);
         if ((!isSpaceOrNewline(c) && c != noBreakSpace) || c == '\n')
             break;
         m_end = charIt.range()->endPosition();
diff --git a/Source/core/editing/VisibleUnits.cpp b/Source/core/editing/VisibleUnits.cpp
index 6ee1386..46abad5 100644
--- a/Source/core/editing/VisibleUnits.cpp
+++ b/Source/core/editing/VisibleUnits.cpp
@@ -464,12 +464,12 @@
         forwardsScanRange->setStart(end.deprecatedNode(), end.deprecatedEditingOffset(), ec);
         TextIterator forwardsIterator(forwardsScanRange.get());
         while (!forwardsIterator.atEnd()) {
-            const UChar* characters = forwardsIterator.characters();
-            int length = forwardsIterator.length();
-            int i = endOfFirstWordBoundaryContext(characters, length);
-            string.append(characters, i);
+            Vector<UChar, 1024> characters;
+            forwardsIterator.appendTextTo(characters);
+            int i = endOfFirstWordBoundaryContext(characters.data(), characters.size());
+            string.append(characters.data(), i);
             suffixLength += i;
-            if (i < length)
+            if (static_cast<unsigned>(i) < characters.size())
                 break;
             forwardsIterator.advance();
         }
@@ -489,7 +489,7 @@
     while (!it.atEnd()) {
         // iterate to get chunks until the searchFunction returns a non-zero value.
         if (!inTextSecurityMode)
-            string.prepend(it.characters(), it.length());
+            it.prependTextTo(string);
         else {
             // Treat bullets used in the text security mode as regular characters when looking for boundaries
             Vector<UChar, 1024> iteratorString;
@@ -542,10 +542,11 @@
         backwardsScanRange->setEnd(start.deprecatedNode(), start.deprecatedEditingOffset(), IGNORE_EXCEPTION);
         SimplifiedBackwardsTextIterator backwardsIterator(backwardsScanRange.get());
         while (!backwardsIterator.atEnd()) {
-            const UChar* characters = backwardsIterator.characters();
-            int length = backwardsIterator.length();
-            int i = startOfLastWordBoundaryContext(characters, length);
-            string.prepend(characters + i, length - i);
+            Vector<UChar, 1024> characters;
+            backwardsIterator.prependTextTo(characters);
+            int length = characters.size();
+            int i = startOfLastWordBoundaryContext(characters.data(), length);
+            string.prepend(characters.data() + i, length - i);
             prefixLength += length - i;
             if (i > 0)
                 break;
@@ -563,12 +564,12 @@
         // Keep asking the iterator for chunks until the search function
         // returns an end value not equal to the length of the string passed to it.
         if (!inTextSecurityMode)
-            string.append(it.characters(), it.length());
+            it.appendTextTo(string);
         else {
             // Treat bullets used in the text security mode as regular characters when looking for boundaries
-            String iteratorString(it.characters(), it.length());
-            iteratorString.fill('x');
-            iteratorString.appendTo(string);
+            Vector<UChar, 1024> iteratorString;
+            iteratorString.fill('x', it.length());
+            string.append(iteratorString.data(), iteratorString.size());
         }
         next = searchFunction(string.data(), string.size(), prefixLength, MayHaveMoreContext, needMoreContext);
         if (next != string.size())
@@ -591,7 +592,7 @@
         RefPtr<Range> characterRange = charIt.range();
         pos = characterRange->endPosition();
 
-        if (*charIt.characters() == '\n') {
+        if (charIt.characterAt(0) == '\n') {
             // FIXME: workaround for collapsed range (where only start position is correct) emitted for some emitted newlines (see rdar://5192593)
             VisiblePosition visPos = VisiblePosition(pos);
             if (visPos == VisiblePosition(characterRange->startPosition())) {
diff --git a/Source/core/history/BackForwardClient.h b/Source/core/history/BackForwardClient.h
index f4be36a..3bbc8bc 100644
--- a/Source/core/history/BackForwardClient.h
+++ b/Source/core/history/BackForwardClient.h
@@ -28,17 +28,15 @@
 #ifndef BackForwardClient_h
 #define BackForwardClient_h
 
-#include "core/history/HistoryItem.h"
-#include "wtf/Forward.h"
-#include "wtf/RefCounted.h"
+#include "wtf/PassRefPtr.h"
 
 namespace WebCore {
 
+class HistoryItem;
+
 class BackForwardClient {
 public:
-    virtual ~BackForwardClient()
-    {
-    }
+    virtual ~BackForwardClient() { }
 
     virtual void addItem(PassRefPtr<HistoryItem>) = 0;
 
diff --git a/Source/core/history/BackForwardController.cpp b/Source/core/history/BackForwardController.cpp
index 443a02c..5e59897 100644
--- a/Source/core/history/BackForwardController.cpp
+++ b/Source/core/history/BackForwardController.cpp
@@ -50,17 +50,46 @@
 
 void BackForwardController::goBackOrForward(int distance)
 {
-    m_page->goBackOrForward(distance);
+    if (distance == 0)
+        return;
+
+    HistoryItem* item = itemAtIndex(distance);
+    if (!item) {
+        if (distance > 0) {
+            if (forwardCount())
+                item = itemAtIndex(forwardCount());
+        } else {
+            if (backCount())
+                item = itemAtIndex(-backCount());
+        }
+    }
+
+    if (!item)
+        return;
+
+    m_page->goToItem(item);
 }
 
 bool BackForwardController::goBack()
 {
-    return m_page->goBack();
+    HistoryItem* item = backItem();
+
+    if (item) {
+        m_page->goToItem(item);
+        return true;
+    }
+    return false;
 }
 
 bool BackForwardController::goForward()
 {
-    return m_page->goForward();
+    HistoryItem* item = forwardItem();
+
+    if (item) {
+        m_page->goToItem(item);
+        return true;
+    }
+    return false;
 }
 
 void BackForwardController::addItem(PassRefPtr<HistoryItem> item)
@@ -75,7 +104,7 @@
 
 int BackForwardController::count() const
 {
-    return m_page->getHistoryLength();
+    return backCount() + 1 + forwardCount();
 }
 
 int BackForwardController::backCount() const
diff --git a/Source/core/history/BackForwardController.h b/Source/core/history/BackForwardController.h
index f6c123c..d315fd6 100644
--- a/Source/core/history/BackForwardController.h
+++ b/Source/core/history/BackForwardController.h
@@ -53,7 +53,7 @@
 
     void addItem(PassRefPtr<HistoryItem>);
     void setCurrentItem(HistoryItem*);
-        
+
     int count() const;
     int backCount() const;
     int forwardCount() const;
diff --git a/Source/core/html/BaseCheckableInputType.cpp b/Source/core/html/BaseCheckableInputType.cpp
index 6867bd2..28c069b 100644
--- a/Source/core/html/BaseCheckableInputType.cpp
+++ b/Source/core/html/BaseCheckableInputType.cpp
@@ -44,7 +44,7 @@
 
 FormControlState BaseCheckableInputType::saveFormControlState() const
 {
-    return FormControlState(element()->checked() ? "on" : "off");
+    return FormControlState(element()->checked() ? ASCIILiteral("on") : ASCIILiteral("off"));
 }
 
 void BaseCheckableInputType::restoreFormControlState(const FormControlState& state)
@@ -93,7 +93,7 @@
 
 String BaseCheckableInputType::fallbackValue() const
 {
-    return "on";
+    return ASCIILiteral("on");
 }
 
 bool BaseCheckableInputType::storesValueSeparateFromAttribute()
diff --git a/Source/core/html/BaseMultipleFieldsDateAndTimeInputType.cpp b/Source/core/html/BaseMultipleFieldsDateAndTimeInputType.cpp
index 0484277..478e66c 100644
--- a/Source/core/html/BaseMultipleFieldsDateAndTimeInputType.cpp
+++ b/Source/core/html/BaseMultipleFieldsDateAndTimeInputType.cpp
@@ -150,7 +150,7 @@
 
 inline bool BaseMultipleFieldsDateAndTimeInputType::containsFocusedShadowElement() const
 {
-    return element()->userAgentShadowRoot()->contains(element()->document()->focusedNode());
+    return element()->userAgentShadowRoot()->contains(element()->document()->focusedElement());
 }
 
 void BaseMultipleFieldsDateAndTimeInputType::didBlurFromControl()
diff --git a/Source/core/html/DOMTokenList.cpp b/Source/core/html/DOMTokenList.cpp
index b61dfec..2f9b122 100644
--- a/Source/core/html/DOMTokenList.cpp
+++ b/Source/core/html/DOMTokenList.cpp
@@ -208,12 +208,13 @@
         }
 
         // Step 7
-        StringBuilder s;
+        StringBuilder tokenBuilder;
         while (position < inputLength && isNotHTMLSpace(input[position]))
-            s.append(input[position++]);
+            tokenBuilder.append(input[position++]);
 
         // Step 8
-        if (tokens.contains(s.toStringPreserveCapacity())) {
+        String token = tokenBuilder.toString();
+        if (tokens.contains(token)) {
             // Step 8.1
             while (position < inputLength && isHTMLSpace(input[position]))
                 ++position;
@@ -227,8 +228,9 @@
             // Step 8.3
             if (position < inputLength && !output.isEmpty())
                 output.append(' ');
-        } else
-            output.append(s.toStringPreserveCapacity()); // Step 9
+        } else {
+            output.append(token); // Step 9
+        }
     }
 
     return output.toString();
diff --git a/Source/core/html/HTMLAnchorElement.cpp b/Source/core/html/HTMLAnchorElement.cpp
index 5e6e54d..398ac18 100644
--- a/Source/core/html/HTMLAnchorElement.cpp
+++ b/Source/core/html/HTMLAnchorElement.cpp
@@ -375,7 +375,9 @@
 String HTMLAnchorElement::hash() const
 {
     String fragmentIdentifier = href().fragmentIdentifier();
-    return fragmentIdentifier.isEmpty() ? emptyString() : "#" + fragmentIdentifier;
+    if (fragmentIdentifier.isEmpty())
+        return emptyString();
+    return AtomicString(String("#" + fragmentIdentifier));
 }
 
 void HTMLAnchorElement::setHash(const String& value)
diff --git a/Source/core/html/HTMLDimension.cpp b/Source/core/html/HTMLDimension.cpp
index fb91fd1..0946482 100644
--- a/Source/core/html/HTMLDimension.cpp
+++ b/Source/core/html/HTMLDimension.cpp
@@ -31,14 +31,15 @@
 #include "config.h"
 #include "core/html/HTMLDimension.h"
 
+#include "wtf/MathExtras.h"
 #include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
 template <typename CharacterType>
-static Length parseDimension(const CharacterType* characters, size_t lastParsedIndex, size_t endOfCurrentToken)
+static HTMLDimension parseDimension(const CharacterType* characters, size_t lastParsedIndex, size_t endOfCurrentToken)
 {
-    LengthType type = Fixed;
+    HTMLDimension::HTMLDimensionType type = HTMLDimension::Absolute;
     double value = 0.;
 
     // HTML5's split removes leading and trailing spaces so we need to skip the leading spaces here.
@@ -47,7 +48,7 @@
 
     // This is Step 5.5. in the algorithm. Going to the last step would make the code less readable.
     if (lastParsedIndex >= endOfCurrentToken)
-        return Length(value, Relative);
+        return HTMLDimension(value, HTMLDimension::Relative);
 
     size_t position = lastParsedIndex;
     while (position < endOfCurrentToken && isASCIIDigit(characters[position]))
@@ -83,15 +84,15 @@
 
     if (position < endOfCurrentToken) {
         if (characters[position] == '*')
-            type = Relative;
+            type = HTMLDimension::Relative;
         else if (characters[position] == '%')
-            type = Percent;
+            type = HTMLDimension::Percentage;
     }
 
-    return Length(value, type);
+    return HTMLDimension(value, type);
 }
 
-static Length parseDimension(const String& rawToken, size_t lastParsedIndex, size_t endOfCurrentToken)
+static HTMLDimension parseDimension(const String& rawToken, size_t lastParsedIndex, size_t endOfCurrentToken)
 {
     if (rawToken.is8Bit())
         return parseDimension<LChar>(rawToken.characters8(), lastParsedIndex, endOfCurrentToken);
@@ -100,7 +101,7 @@
 
 // This implements the "rules for parsing a list of dimensions" per HTML5.
 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#rules-for-parsing-a-list-of-dimensions
-Vector<Length> parseListOfDimensions(const String& input)
+Vector<HTMLDimension> parseListOfDimensions(const String& input)
 {
     static const char comma = ',';
 
@@ -112,22 +113,22 @@
     // HTML5's split doesn't return a token for an empty string so
     // we need to match them here.
     if (trimmedString.isEmpty())
-        return Vector<Length>();
+        return Vector<HTMLDimension>();
 
     // Step 3. To avoid String copies, we just look for commas instead of splitting.
-    Vector<Length> parsedLength;
+    Vector<HTMLDimension> parsedDimensions;
     size_t lastParsedIndex = 0;
     while (true) {
         size_t nextComma = trimmedString.find(comma, lastParsedIndex);
         if (nextComma == notFound)
             break;
 
-        parsedLength.append(parseDimension(trimmedString, lastParsedIndex, nextComma));
+        parsedDimensions.append(parseDimension(trimmedString, lastParsedIndex, nextComma));
         lastParsedIndex = nextComma + 1;
     }
 
-    parsedLength.append(parseDimension(trimmedString, lastParsedIndex, trimmedString.length()));
-    return parsedLength;
+    parsedDimensions.append(parseDimension(trimmedString, lastParsedIndex, trimmedString.length()));
+    return parsedDimensions;
 }
 
 } // namespace WebCore
diff --git a/Source/core/html/HTMLDimension.h b/Source/core/html/HTMLDimension.h
index 0241d7a..f0aa343 100644
--- a/Source/core/html/HTMLDimension.h
+++ b/Source/core/html/HTMLDimension.h
@@ -31,16 +31,51 @@
 #ifndef HTMLDimension_h
 #define HTMLDimension_h
 
-// FIXME: Remove once we introduce HTMLDimension.
-#include "core/platform/Length.h"
 #include "wtf/Forward.h"
 #include "wtf/Vector.h"
 
 namespace WebCore {
 
-struct Length;
+// This class corresponds to a dimension as described in HTML5 by the
+// "rules for parsing a list of dimensions" (section 2.4.4.6).
+class HTMLDimension {
+public:
+    enum HTMLDimensionType {
+        Relative, Percentage, Absolute
+    };
 
-Vector<Length> parseListOfDimensions(const String&);
+    HTMLDimension()
+        : m_type(Absolute)
+        , m_value(0)
+    {
+    }
+
+    HTMLDimension(double value, HTMLDimensionType type)
+        : m_type(type)
+        , m_value(value)
+    {
+    }
+
+    HTMLDimensionType type() const { return m_type; }
+
+    bool isRelative() const { return m_type == Relative; }
+    bool isPercentage() const { return m_type == Percentage; }
+    bool isAbsolute() const { return m_type == Absolute; }
+
+    double value() const { return m_value; }
+
+    bool operator==(const HTMLDimension& other) const
+    {
+        return m_type == other.m_type && m_value == other.m_value;
+    }
+    bool operator!=(const HTMLDimension& other) const { return !(*this == other); }
+
+private:
+    HTMLDimensionType m_type;
+    double m_value;
+};
+
+Vector<HTMLDimension> parseListOfDimensions(const String&);
 
 } // namespace WebCore
 
diff --git a/Source/core/html/HTMLFrameOwnerElement.cpp b/Source/core/html/HTMLFrameOwnerElement.cpp
index 779e19c..a8bfa6e 100644
--- a/Source/core/html/HTMLFrameOwnerElement.cpp
+++ b/Source/core/html/HTMLFrameOwnerElement.cpp
@@ -95,7 +95,7 @@
 
 DOMWindow* HTMLFrameOwnerElement::contentWindow() const
 {
-    return m_contentFrame ? m_contentFrame->document()->domWindow() : 0;
+    return m_contentFrame ? m_contentFrame->domWindow() : 0;
 }
 
 void HTMLFrameOwnerElement::setSandboxFlags(SandboxFlags flags)
diff --git a/Source/core/html/HTMLFrameSetElement.h b/Source/core/html/HTMLFrameSetElement.h
index 912b397..9b01d46 100644
--- a/Source/core/html/HTMLFrameSetElement.h
+++ b/Source/core/html/HTMLFrameSetElement.h
@@ -24,6 +24,7 @@
 #ifndef HTMLFrameSetElement_h
 #define HTMLFrameSetElement_h
 
+#include "core/html/HTMLDimension.h"
 #include "core/html/HTMLElement.h"
 
 namespace WebCore {
@@ -41,8 +42,8 @@
 
     bool hasBorderColor() const { return m_borderColorSet; }
 
-    const Vector<Length>& rowLengths() const { return m_rowLengths; }
-    const Vector<Length>& colLengths() const { return m_colLengths; }
+    const Vector<HTMLDimension>& rowLengths() const { return m_rowLengths; }
+    const Vector<HTMLDimension>& colLengths() const { return m_colLengths; }
 
     DOMWindow* anonymousNamedGetter(const AtomicString&);
 
@@ -81,8 +82,8 @@
     virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
     virtual void willRecalcStyle(StyleChange) OVERRIDE;
 
-    Vector<Length> m_rowLengths;
-    Vector<Length> m_colLengths;
+    Vector<HTMLDimension> m_rowLengths;
+    Vector<HTMLDimension> m_colLengths;
 
     int m_border;
     bool m_borderSet;
diff --git a/Source/core/html/HTMLInputElement.cpp b/Source/core/html/HTMLInputElement.cpp
index 245d2ac..3325cf9 100644
--- a/Source/core/html/HTMLInputElement.cpp
+++ b/Source/core/html/HTMLInputElement.cpp
@@ -498,7 +498,7 @@
 
     if (wasAttached) {
         lazyAttach();
-        if (document()->focusedNode() == this)
+        if (document()->focusedElement() == this)
             document()->updateFocusAppearanceSoon(true /* restore selection */);
     }
 
@@ -821,7 +821,7 @@
 
     m_inputType->attach();
 
-    if (document()->focusedNode() == this)
+    if (document()->focusedElement() == this)
         document()->updateFocusAppearanceSoon(true /* restore selection */);
 }
 
diff --git a/Source/core/html/HTMLLinkElement.cpp b/Source/core/html/HTMLLinkElement.cpp
index cfdadad..6231f2d 100644
--- a/Source/core/html/HTMLLinkElement.cpp
+++ b/Source/core/html/HTMLLinkElement.cpp
@@ -26,6 +26,7 @@
 #include "core/html/HTMLLinkElement.h"
 
 #include "HTMLNames.h"
+#include "RuntimeEnabledFeatures.h"
 #include "bindings/v8/ScriptEventListener.h"
 #include "core/css/MediaList.h"
 #include "core/css/MediaQueryEvaluator.h"
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index 41cbee8..13cc476 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -1010,7 +1010,7 @@
     // element. (In the other cases, such as explicit seeks, relevant events get
     // fired as part of the overall process of changing the current playback
     // position.)
-    if (m_lastSeekTime <= lastTime)
+    if (!m_seeking && m_lastSeekTime <= lastTime)
         scheduleTimeupdateEvent(false);
 
     // Explicitly cache vector sizes, as their content is constant from here.
@@ -1588,11 +1588,13 @@
         return;
 
     if (m_seeking) {
-        // 4.8.10.9, step 11
+        // 4.8.10.9, step 9 note: If the media element was potentially playing immediately before
+        // it started seeking, but seeking caused its readyState attribute to change to a value
+        // lower than HAVE_FUTURE_DATA, then a waiting will be fired at the element.
         if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA)
             scheduleEvent(eventNames().waitingEvent);
 
-        // 4.8.10.10 step 14 & 15.
+        // 4.8.10.9 steps 12-14
         if (m_readyState >= HAVE_CURRENT_DATA)
             finishSeek();
     } else {
@@ -1834,7 +1836,7 @@
 {
     LOG(Media, "HTMLMediaElement::seek(%f)", time);
 
-    // 4.8.9.9 Seeking
+    // 4.8.10.9 Seeking
 
     // 1 - If the media element's readyState is HAVE_NOTHING, then raise an InvalidStateError exception.
     if (m_readyState == HAVE_NOTHING || !m_player) {
@@ -1912,26 +1914,28 @@
     m_lastSeekTime = time;
     m_sentEndEvent = false;
 
-    // 8 - Set the current playback position to the given new playback position
-    m_player->seek(time);
-
-    // 9 - Queue a task to fire a simple event named seeking at the element.
+    // 8 - Queue a task to fire a simple event named seeking at the element.
     scheduleEvent(eventNames().seekingEvent);
 
-    // 10 - Queue a task to fire a simple event named timeupdate at the element.
-    scheduleTimeupdateEvent(false);
+    // 9 - Set the current playback position to the given new playback position
+    m_player->seek(time);
 
-    // 11-15 are handled, if necessary, when the engine signals a readystate change.
+    // 10-14 are handled, if necessary, when the engine signals a readystate change or otherwise
+    // satisfies seek completion and signals a time change.
 }
 
 void HTMLMediaElement::finishSeek()
 {
     LOG(Media, "HTMLMediaElement::finishSeek");
 
-    // 4.8.10.9 Seeking step 14
+    // 4.8.10.9 Seeking completion
+    // 12 - Set the seeking IDL attribute to false.
     m_seeking = false;
 
-    // 4.8.10.9 Seeking step 15
+    // 13 - Queue a task to fire a simple event named timeupdate at the element.
+    scheduleTimeupdateEvent(false);
+
+    // 14 - Queue a task to fire a simple event named seeked at the element.
     scheduleEvent(eventNames().seekedEvent);
 
     setDisplayMode(Video);
@@ -2444,7 +2448,8 @@
         }
     }
 
-    scheduleTimeupdateEvent(true);
+    if (!m_seeking)
+        scheduleTimeupdateEvent(true);
 
     if (!m_playbackRate)
         return;
@@ -3079,7 +3084,7 @@
 
     invalidateCachedTime();
 
-    // 4.8.10.9 step 14 & 15.  Needed if no ReadyState change is associated with the seek.
+    // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with the seek.
     if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !m_player->seeking())
         finishSeek();
 
diff --git a/Source/core/html/HTMLOptionElement.cpp b/Source/core/html/HTMLOptionElement.cpp
index 0ca2446..e44a404 100644
--- a/Source/core/html/HTMLOptionElement.cpp
+++ b/Source/core/html/HTMLOptionElement.cpp
@@ -196,13 +196,8 @@
                 renderer()->theme()->stateChanged(renderer(), EnabledState);
         }
     } else if (name == selectedAttr) {
-        // FIXME: This doesn't match what the HTML specification says.
-        // The specification implies that removing the selected attribute or
-        // changing the value of a selected attribute that is already present
-        // has no effect on whether the element is selected. Further, it seems
-        // that we need to do more than just set m_isSelected to select in that
-        // case; we'd need to do the other work from the setSelected function.
-        m_isSelected = !value.isNull();
+        if (bool willBeSelected = !value.isNull())
+            setSelected(willBeSelected);
     } else
         HTMLElement::parseAttribute(name, value);
 }
diff --git a/Source/core/html/HTMLTextAreaElement.cpp b/Source/core/html/HTMLTextAreaElement.cpp
index 0e5110b..cf99917 100644
--- a/Source/core/html/HTMLTextAreaElement.cpp
+++ b/Source/core/html/HTMLTextAreaElement.cpp
@@ -384,7 +384,7 @@
     setFormControlValueMatchesRenderer(true);
 
     // Set the caret to the end of the text value.
-    if (document()->focusedNode() == this) {
+    if (document()->focusedElement() == this) {
         unsigned endOfString = m_value.length();
         setSelectionRange(endOfString, endOfString);
     }
diff --git a/Source/core/html/HTMLTextFormControlElement.cpp b/Source/core/html/HTMLTextFormControlElement.cpp
index 5d12522..e55dfb4 100644
--- a/Source/core/html/HTMLTextFormControlElement.cpp
+++ b/Source/core/html/HTMLTextFormControlElement.cpp
@@ -148,7 +148,7 @@
         && isEmptyValue()
         && isEmptySuggestedValue()
         && !isPlaceholderEmpty()
-        && (document()->focusedNode() != this || (renderer() && renderer()->theme()->shouldShowPlaceholderWhenFocused()))
+        && (document()->focusedElement() != this || (renderer() && renderer()->theme()->shouldShowPlaceholderWhenFocused()))
         && (!renderer() || renderer()->style()->visibility() == VISIBLE);
 }
 
@@ -161,7 +161,7 @@
     HTMLElement* placeholder = placeholderElement();
     if (!placeholder)
         return;
-    placeholder->setInlineStyleProperty(CSSPropertyVisibility, placeholderShouldBeVisible() ? "visible" : "hidden");
+    placeholder->setInlineStyleProperty(CSSPropertyVisibility, placeholderShouldBeVisible() ? ASCIILiteral("visible") : ASCIILiteral("hidden"));
 }
 
 void HTMLTextFormControlElement::fixPlaceholderRenderer(HTMLElement* placeholder, HTMLElement* siblingElement)
@@ -359,7 +359,7 @@
 {
     if (!isTextFormControl())
         return 0;
-    if (document()->focusedNode() != this && hasCachedSelection())
+    if (document()->focusedElement() != this && hasCachedSelection())
         return m_cachedSelectionStart;
 
     return computeSelectionStart();
@@ -379,7 +379,7 @@
 {
     if (!isTextFormControl())
         return 0;
-    if (document()->focusedNode() != this && hasCachedSelection())
+    if (document()->focusedElement() != this && hasCachedSelection())
         return m_cachedSelectionEnd;
     return computeSelectionEnd();
 }
@@ -417,7 +417,7 @@
 {
     if (!isTextFormControl())
         return directionString(SelectionHasNoDirection);
-    if (document()->focusedNode() != this && hasCachedSelection())
+    if (document()->focusedElement() != this && hasCachedSelection())
         return directionString(m_cachedSelectionDirection);
 
     return directionString(computeSelectionDirection());
diff --git a/Source/core/html/PluginDocument.cpp b/Source/core/html/PluginDocument.cpp
index 7164d88..154d2ae 100644
--- a/Source/core/html/PluginDocument.cpp
+++ b/Source/core/html/PluginDocument.cpp
@@ -198,7 +198,7 @@
         return;
 
     DocumentLoader* documentLoader = frame()->loader()->activeDocumentLoader();
-    documentLoader->cancelMainResourceLoad(frame()->loader()->cancelledError(documentLoader->request()));
+    documentLoader->cancelMainResourceLoad(ResourceError::cancelledError(documentLoader->request().url()));
     setShouldLoadPluginManually(false);
 }
 
diff --git a/Source/core/html/RadioInputType.cpp b/Source/core/html/RadioInputType.cpp
index 45b3b7f..897abc7 100644
--- a/Source/core/html/RadioInputType.cpp
+++ b/Source/core/html/RadioInputType.cpp
@@ -126,9 +126,9 @@
 
     // Never allow keyboard tabbing to leave you in the same radio group.  Always
     // skip any other elements in the group.
-    Node* currentFocusedNode = element()->document()->focusedNode();
-    if (currentFocusedNode && currentFocusedNode->hasTagName(inputTag)) {
-        HTMLInputElement* focusedInput = toHTMLInputElement(currentFocusedNode);
+    Element* currentFocusedElement = element()->document()->focusedElement();
+    if (currentFocusedElement && currentFocusedElement->hasTagName(inputTag)) {
+        HTMLInputElement* focusedInput = toHTMLInputElement(currentFocusedElement);
         if (focusedInput->isRadioButton() && focusedInput->form() == element()->form() && focusedInput->name() == element()->name())
             return false;
     }
diff --git a/Source/core/html/ime/InputMethodContext.cpp b/Source/core/html/ime/InputMethodContext.cpp
index 537fa03..ce72536 100644
--- a/Source/core/html/ime/InputMethodContext.cpp
+++ b/Source/core/html/ime/InputMethodContext.cpp
@@ -91,8 +91,8 @@
     if (!editor->hasComposition())
         return;
 
-    const Node* node = frame->document()->focusedNode();
-    if (!node || !node->isHTMLElement() || m_element != toHTMLElement(node))
+    const Element* element = frame->document()->focusedElement();
+    if (!element || !element->isHTMLElement() || m_element != toHTMLElement(element))
         return;
 
     // We should verify the parent node of this IME composition node are
diff --git a/Source/core/html/parser/CSSPreloadScanner.cpp b/Source/core/html/parser/CSSPreloadScanner.cpp
index be74d9f..e6b787b 100644
--- a/Source/core/html/parser/CSSPreloadScanner.cpp
+++ b/Source/core/html/parser/CSSPreloadScanner.cpp
@@ -212,7 +212,7 @@
 void CSSPreloadScanner::emitRule(const SegmentedString& source)
 {
     if (equalIgnoringCase(m_rule, "import")) {
-        String url = parseCSSStringOrURL(m_ruleValue.toStringPreserveCapacity());
+        String url = parseCSSStringOrURL(m_ruleValue.toString());
         if (!url.isEmpty()) {
             KURL baseElementURL; // FIXME: This should be passed in from the HTMLPreloadScaner via scan()!
             TextPosition position = TextPosition(source.currentLine(), source.currentColumn());
diff --git a/Source/core/html/shadow/DateTimeEditElement.cpp b/Source/core/html/shadow/DateTimeEditElement.cpp
index 6194d2c..6654f86 100644
--- a/Source/core/html/shadow/DateTimeEditElement.cpp
+++ b/Source/core/html/shadow/DateTimeEditElement.cpp
@@ -572,9 +572,9 @@
 
 size_t DateTimeEditElement::focusedFieldIndex() const
 {
-    Node* const focusedFieldNode = document()->focusedNode();
+    Element* const focusedFieldElement = document()->focusedElement();
     for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) {
-        if (m_fields[fieldIndex] == focusedFieldNode)
+        if (m_fields[fieldIndex] == focusedFieldElement)
             return fieldIndex;
     }
     return invalidFieldIndex;
diff --git a/Source/core/html/shadow/MediaControlElements.cpp b/Source/core/html/shadow/MediaControlElements.cpp
index 3940978..84f6ea9 100644
--- a/Source/core/html/shadow/MediaControlElements.cpp
+++ b/Source/core/html/shadow/MediaControlElements.cpp
@@ -186,8 +186,8 @@
 
     double duration = document()->page() ? document()->page()->theme()->mediaControlsFadeInDuration() : 0;
 
-    setInlineStyleProperty(CSSPropertyWebkitTransitionProperty, CSSPropertyOpacity);
-    setInlineStyleProperty(CSSPropertyWebkitTransitionDuration, duration, CSSPrimitiveValue::CSS_S);
+    setInlineStyleProperty(CSSPropertyTransitionProperty, CSSPropertyOpacity);
+    setInlineStyleProperty(CSSPropertyTransitionDuration, duration, CSSPrimitiveValue::CSS_S);
     setInlineStyleProperty(CSSPropertyOpacity, 1.0, CSSPrimitiveValue::CSS_NUMBER);
 
     m_opaque = true;
@@ -203,8 +203,8 @@
 
     double duration = document()->page() ? document()->page()->theme()->mediaControlsFadeOutDuration() : 0;
 
-    setInlineStyleProperty(CSSPropertyWebkitTransitionProperty, CSSPropertyOpacity);
-    setInlineStyleProperty(CSSPropertyWebkitTransitionDuration, duration, CSSPrimitiveValue::CSS_S);
+    setInlineStyleProperty(CSSPropertyTransitionProperty, CSSPropertyOpacity);
+    setInlineStyleProperty(CSSPropertyTransitionDuration, duration, CSSPrimitiveValue::CSS_S);
     setInlineStyleProperty(CSSPropertyOpacity, 0.0, CSSPrimitiveValue::CSS_NUMBER);
 
     m_opaque = false;
diff --git a/Source/core/inspector/CodeGeneratorInspector.py b/Source/core/inspector/CodeGeneratorInspector.py
index 233d7fa..20122e6 100755
--- a/Source/core/inspector/CodeGeneratorInspector.py
+++ b/Source/core/inspector/CodeGeneratorInspector.py
@@ -48,7 +48,7 @@
 
 
 TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.PropertyDescriptor", "Runtime.InternalPropertyDescriptor",
-                                         "Debugger.FunctionDetails", "Debugger.CallFrame",
+                                         "Debugger.FunctionDetails", "Debugger.CallFrame", "Debugger.Location",
                                          "Canvas.TraceLog", "Canvas.ResourceState",
                                          # This should be a temporary hack. TimelineEvent should be created via generated C++ API.
                                          "Timeline.TimelineEvent"])
diff --git a/Source/core/inspector/InjectedScript.cpp b/Source/core/inspector/InjectedScript.cpp
index 43422c8..52f3e09 100644
--- a/Source/core/inspector/InjectedScript.cpp
+++ b/Source/core/inspector/InjectedScript.cpp
@@ -112,6 +112,26 @@
     *errorString = "Internal error";
 }
 
+void InjectedScript::getStepInPositions(ErrorString* errorString, const ScriptValue& callFrames, const String& callFrameId, RefPtr<Array<TypeBuilder::Debugger::Location> >& positions)
+{
+    ScriptFunctionCall function(injectedScriptObject(), "getStepInPositions");
+    function.appendArgument(callFrames);
+    function.appendArgument(callFrameId);
+    RefPtr<JSONValue> resultValue;
+    makeCall(function, &resultValue);
+    if (resultValue) {
+        if (resultValue->type() == JSONValue::TypeString) {
+            resultValue->asString(errorString);
+            return;
+        }
+        if (resultValue->type() == JSONValue::TypeArray) {
+            positions = Array<TypeBuilder::Debugger::Location>::runtimeCast(resultValue);
+            return;
+        }
+    }
+    *errorString = "Internal error";
+}
+
 void InjectedScript::setVariableValue(ErrorString* errorString, const ScriptValue& callFrames, const String* callFrameIdOpt, const String* functionObjectIdOpt, int scopeNumber, const String& variableName, const String& newValueStr)
 {
     ScriptFunctionCall function(injectedScriptObject(), "setVariableValue");
diff --git a/Source/core/inspector/InjectedScript.h b/Source/core/inspector/InjectedScript.h
index 609efd2..207f5ae 100644
--- a/Source/core/inspector/InjectedScript.h
+++ b/Source/core/inspector/InjectedScript.h
@@ -77,6 +77,7 @@
                              RefPtr<TypeBuilder::Runtime::RemoteObject>* result,
                              TypeBuilder::OptOutput<bool>* wasThrown);
     void restartFrame(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, RefPtr<JSONObject>* result);
+    void getStepInPositions(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::Location> >& positions);
     void setVariableValue(ErrorString*, const ScriptValue& callFrames, const String* callFrameIdOpt, const String* functionObjectIdOpt, int scopeNumber, const String& variableName, const String& newValueStr);
     void getFunctionDetails(ErrorString*, const String& functionId, RefPtr<TypeBuilder::Debugger::FunctionDetails>* result);
     void getProperties(ErrorString*, const String& objectId, bool ownProperties, bool accessorPropertiesOnly, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >* result);
diff --git a/Source/core/inspector/InjectedScriptCanvasModule.cpp b/Source/core/inspector/InjectedScriptCanvasModule.cpp
index 88faf8a..17710cc 100644
--- a/Source/core/inspector/InjectedScriptCanvasModule.cpp
+++ b/Source/core/inspector/InjectedScriptCanvasModule.cpp
@@ -150,7 +150,7 @@
     *traceLog = TraceLog::runtimeCast(resultValue);
 }
 
-void InjectedScriptCanvasModule::replayTraceLog(ErrorString* errorString, const TraceLogId& traceLogId, int stepNo, RefPtr<ResourceState>* result)
+void InjectedScriptCanvasModule::replayTraceLog(ErrorString* errorString, const TraceLogId& traceLogId, int stepNo, RefPtr<ResourceState>* result, double* replayTime)
 {
     ScriptFunctionCall function(injectedScriptObject(), "replayTraceLog");
     function.appendArgument(traceLogId);
@@ -162,7 +162,15 @@
             *errorString = "Internal error: replayTraceLog";
         return;
     }
-    *result = ResourceState::runtimeCast(resultValue);
+    RefPtr<JSONObject> resultObject = resultValue->asObject();
+    RefPtr<JSONObject> resourceStateObject = resultObject->getObject("resourceState");
+    if (!resourceStateObject) {
+        *errorString = "Internal error: replayTraceLog: no resourceState";
+        return;
+    }
+    *result = ResourceState::runtimeCast(resourceStateObject);
+    if (!resultObject->getNumber("replayTime", replayTime))
+        *errorString = "Internal error: replayTraceLog: no replayTime";
 }
 
 void InjectedScriptCanvasModule::resourceState(ErrorString* errorString, const TraceLogId& traceLogId, const ResourceId& resourceId, RefPtr<ResourceState>* result)
diff --git a/Source/core/inspector/InjectedScriptCanvasModule.h b/Source/core/inspector/InjectedScriptCanvasModule.h
index 27f9d8b..5e617dd 100644
--- a/Source/core/inspector/InjectedScriptCanvasModule.h
+++ b/Source/core/inspector/InjectedScriptCanvasModule.h
@@ -58,7 +58,7 @@
     void stopCapturing(ErrorString*, const TypeBuilder::Canvas::TraceLogId&);
     void dropTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&);
     void traceLog(ErrorString*, const String&, const int*, const int*, RefPtr<TypeBuilder::Canvas::TraceLog>*);
-    void replayTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, int, RefPtr<TypeBuilder::Canvas::ResourceState>*);
+    void replayTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, int, RefPtr<TypeBuilder::Canvas::ResourceState>*, double*);
     void resourceState(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, const TypeBuilder::Canvas::ResourceId&, RefPtr<TypeBuilder::Canvas::ResourceState>*);
     void evaluateTraceLogCallArgument(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, int, int, const String&, RefPtr<TypeBuilder::Runtime::RemoteObject>*, RefPtr<TypeBuilder::Canvas::ResourceState>*);
 
diff --git a/Source/core/inspector/InjectedScriptCanvasModuleSource.js b/Source/core/inspector/InjectedScriptCanvasModuleSource.js
index f26c811..c4bd77f 100644
--- a/Source/core/inspector/InjectedScriptCanvasModuleSource.js
+++ b/Source/core/inspector/InjectedScriptCanvasModuleSource.js
@@ -169,6 +169,22 @@
     },
 
     /**
+     * @return {number}
+     */
+    now: function()
+    {
+        try {
+            return inspectedWindow.performance.now();
+        } catch(e) {
+            try {
+                return Date.now();
+            } catch(ex) {
+            }
+        }
+        return 0;
+    },
+
+    /**
      * @return {CanvasRenderingContext2D}
      */
     _dummyCanvas2dContext: function()
@@ -183,6 +199,9 @@
     }
 }
 
+/** @typedef {{name: string, value: *, values: (!Array.<TypeUtils.InternalResourceStateDescriptor>|undefined)}} */
+TypeUtils.InternalResourceStateDescriptor;
+
 /**
  * @interface
  */
@@ -269,6 +288,7 @@
 
 /**
  * @constructor
+ * @template T
  */
 function Cache()
 {
@@ -286,7 +306,7 @@
 
     reset: function()
     {
-        /** @type {!Object.<number, Object>} */
+        /** @type {!Object.<number, !T>} */
         this._items = Object.create(null);
         /** @type {number} */
         this._size = 0;
@@ -303,7 +323,7 @@
 
     /**
      * @param {number} key
-     * @return {Object}
+     * @return {T|undefined}
      */
     get: function(key)
     {
@@ -312,7 +332,7 @@
 
     /**
      * @param {number} key
-     * @param {Object} item
+     * @param {!T} item
      */
     put: function(key, item)
     {
@@ -443,7 +463,7 @@
     },
 
     /**
-     * @param {!Cache} cache
+     * @param {!Cache.<ReplayableResource>} cache
      * @return {!ReplayableCall}
      */
     toReplayable: function(cache)
@@ -460,7 +480,7 @@
 
     /**
      * @param {!ReplayableCall} replayableCall
-     * @param {!Cache} cache
+     * @param {!Cache.<Resource>} cache
      * @return {!Call}
      */
     replay: function(replayableCall, cache)
@@ -602,7 +622,7 @@
     },
 
     /**
-     * @param {!Cache} cache
+     * @param {!Cache.<Resource>} cache
      * @return {!Call}
      */
     replay: function(cache)
@@ -678,7 +698,7 @@
 
 /**
  * @param {Resource|*} obj
- * @param {!Cache} cache
+ * @param {!Cache.<ReplayableResource>} cache
  * @return {ReplayableResource|*}
  */
 Resource.toReplayable = function(obj, cache)
@@ -697,6 +717,22 @@
     },
 
     /**
+     * @return {string}
+     */
+    name: function()
+    {
+        return this._name;
+    },
+
+    /**
+     * @return {string}
+     */
+    description: function()
+    {
+        return this._name + "@" + this._kindId;
+    },
+
+    /**
      * @return {Object}
      */
     wrappedObject: function()
@@ -773,6 +809,23 @@
     },
 
     /**
+     * @return {!Array.<TypeUtils.InternalResourceStateDescriptor>}
+     */
+    currentState: function()
+    {
+        var result = [];
+        var proxyObject = this.proxyObject();
+        if (!proxyObject)
+            return result;
+        var statePropertyNames = this._proxyStatePropertyNames || [];
+        for (var i = 0, n = statePropertyNames.length; i < n; ++i) {
+            var pname = statePropertyNames[i];
+            result.push({ name: pname, value: proxyObject[pname] });
+        }
+        return result;
+    },
+
+    /**
      * @return {string}
      */
     toDataURL: function()
@@ -781,12 +834,12 @@
     },
 
     /**
-     * @param {!Cache} cache
+     * @param {!Cache.<ReplayableResource>} cache
      * @return {!ReplayableResource}
      */
     toReplayable: function(cache)
     {
-        var result = /** @type {ReplayableResource} */ (cache.get(this._id));
+        var result = cache.get(this._id);
         if (result)
             return result;
         var data = {
@@ -808,7 +861,7 @@
 
     /**
      * @param {!Object} data
-     * @param {!Cache} cache
+     * @param {!Cache.<ReplayableResource>} cache
      */
     _populateReplayableData: function(data, cache)
     {
@@ -817,12 +870,12 @@
 
     /**
      * @param {!Object} data
-     * @param {!Cache} cache
+     * @param {!Cache.<Resource>} cache
      * @return {!Resource}
      */
     replay: function(data, cache)
     {
-        var resource = /** @type {Resource} */ (cache.get(data.id));
+        var resource = cache.get(data.id);
         if (resource)
             return resource;
         this._id = data.id;
@@ -840,7 +893,7 @@
 
     /**
      * @param {!Object} data
-     * @param {!Cache} cache
+     * @param {!Cache.<Resource>} cache
      */
     _doReplayCalls: function(data, cache)
     {
@@ -893,20 +946,26 @@
             return null;
         var proxy = Object.create(wrappedObject.__proto__); // In order to emulate "instanceof".
 
-        var self = this;
         var customWrapFunctions = this._customWrapFunctions();
+        /** @type {Array.<string>} */
+        this._proxyStatePropertyNames = [];
+
+        /**
+         * @param {string} property
+         */
         function processProperty(property)
         {
             if (typeof wrappedObject[property] === "function") {
                 var customWrapFunction = customWrapFunctions[property];
                 if (customWrapFunction)
-                    proxy[property] = self._wrapCustomFunction(self, wrappedObject, wrappedObject[property], property, customWrapFunction);
+                    proxy[property] = this._wrapCustomFunction(this, wrappedObject, wrappedObject[property], property, customWrapFunction);
                 else
-                    proxy[property] = self._wrapFunction(self, wrappedObject, wrappedObject[property], property);
+                    proxy[property] = this._wrapFunction(this, wrappedObject, wrappedObject[property], property);
             } else if (/^[A-Z0-9_]+$/.test(property) && typeof wrappedObject[property] === "number") {
                 // Fast access to enums and constants.
                 proxy[property] = wrappedObject[property];
             } else {
+                this._proxyStatePropertyNames.push(property);
                 Object.defineProperty(proxy, property, {
                     get: function()
                     {
@@ -914,7 +973,7 @@
                         var resource = Resource.forObject(obj);
                         return resource ? resource : obj;
                     },
-                    set: self._wrapPropertySetter(self, wrappedObject, property),
+                    set: this._wrapPropertySetter(this, wrappedObject, property),
                     enumerable: true
                 });
             }
@@ -923,7 +982,7 @@
         var isEmpty = true;
         for (var property in wrappedObject) {
             isEmpty = false;
-            processProperty(property);
+            processProperty.call(this, property);
         }
         if (isEmpty)
             return wrappedObject; // Nothing to proxy.
@@ -1128,13 +1187,13 @@
     /**
      * @return {!ReplayableResource}
      */
-    replayableContextResource: function()
+    contextResource: function()
     {
         return this._data.contextResource || this;
     },
 
     /**
-     * @param {!Cache} cache
+     * @param {!Cache.<Resource>} cache
      * @return {!Resource}
      */
     replay: function(cache)
@@ -1148,7 +1207,7 @@
 
 /**
  * @param {ReplayableResource|*} obj
- * @param {!Cache} cache
+ * @param {!Cache.<Resource>} cache
  * @return {*}
  */
 ReplayableResource.replay = function(obj, cache)
@@ -1227,7 +1286,7 @@
     /**
      * @override
      * @param {!Object} data
-     * @param {!Cache} cache
+     * @param {!Cache.<ReplayableResource>} cache
      */
     _populateReplayableData: function(data, cache)
     {
@@ -1241,7 +1300,7 @@
     /**
      * @override
      * @param {!Object} data
-     * @param {!Cache} cache
+     * @param {!Cache.<Resource>} cache
      */
     _doReplayCalls: function(data, cache)
     {
@@ -1277,7 +1336,7 @@
 
     /**
      * @param {!Object} data
-     * @param {!Cache} cache
+     * @param {!Cache.<Resource>} cache
      * @return {WebGLRenderingContextResource}
      */
     _replayContextResource: function(data, cache)
@@ -1322,7 +1381,7 @@
     /**
      * @override
      * @param {!Object} data
-     * @param {!Cache} cache
+     * @param {!Cache.<Resource>} cache
      */
     _doReplayCalls: function(data, cache)
     {
@@ -1422,7 +1481,7 @@
     /**
      * @override
      * @param {!Object} data
-     * @param {!Cache} cache
+     * @param {!Cache.<ReplayableResource>} cache
      */
     _populateReplayableData: function(data, cache)
     {
@@ -1456,7 +1515,7 @@
     /**
      * @override
      * @param {!Object} data
-     * @param {!Cache} cache
+     * @param {!Cache.<Resource>} cache
      */
     _doReplayCalls: function(data, cache)
     {
@@ -1871,25 +1930,75 @@
 
     /**
      * @override
-     * @param {!Object} data
-     * @param {!Cache} cache
+     * @return {!Array.<TypeUtils.InternalResourceStateDescriptor>}
      */
-    _populateReplayableData: function(data, cache)
+    currentState: function()
     {
-        var gl = this.wrappedObject();
-        data.originalCanvas = gl.canvas;
-        data.originalContextAttributes = gl.getContextAttributes();
-        data.extensions = TypeUtils.cloneObject(this._extensions);
+        /**
+         * @param {!Object} obj
+         * @param {!Array.<TypeUtils.InternalResourceStateDescriptor>} output
+         */
+        function convertToStateDescriptors(obj, output)
+        {
+            for (var pname in obj)
+                output.push({ name: pname, value: obj[pname] });
+        }
 
+        var glState = this._internalCurrentState(null);
+
+        // VERTEX_ATTRIB_ARRAYS
+        var vertexAttribStates = [];
+        for (var i = 0, n = glState.VERTEX_ATTRIB_ARRAYS.length; i < n; ++i) {
+            var pname = "" + i;
+            var values = [];
+            convertToStateDescriptors(glState.VERTEX_ATTRIB_ARRAYS[i], values);
+            vertexAttribStates.push({ name: pname, values: values });
+        }
+        delete glState.VERTEX_ATTRIB_ARRAYS;
+
+        // TEXTURE_UNITS
+        var textureUnits = [];
+        for (var i = 0, n = glState.TEXTURE_UNITS.length; i < n; ++i) {
+            var pname = "TEXTURE" + i;
+            var values = [];
+            convertToStateDescriptors(glState.TEXTURE_UNITS[i], values);
+            textureUnits.push({ name: pname, values: values });
+        }
+        delete glState.TEXTURE_UNITS;
+
+        var result = [];
+        convertToStateDescriptors(glState, result);
+        result.push({ name: "VERTEX_ATTRIB_ARRAYS[" + vertexAttribStates.length + "]", values: vertexAttribStates });
+        result.push({ name: "TEXTURE_UNITS[" + textureUnits.length + "]", values: textureUnits });
+        return result;
+    },
+
+    /**
+     * @override
+     * @param {?Cache.<ReplayableResource>} cache
+     * @return {!Object.<string, *>}
+     */
+    _internalCurrentState: function(cache)
+    {
+        /**
+         * @param {Resource|*} obj
+         * @return {Resource|ReplayableResource|*}
+         */
+        function maybeToReplayable(obj)
+        {
+            return cache ? Resource.toReplayable(obj, cache) : (Resource.forObject(obj) || obj);
+        }
+
+        var gl = this.wrappedObject();
         var originalErrors = this.getAllErrors();
 
         // Take a full GL state snapshot.
-        var glState = {};
+        var glState = Object.create(null);
         WebGLRenderingContextResource.GLCapabilities.forEach(function(parameter) {
             glState[parameter] = gl.isEnabled(gl[parameter]);
         });
         WebGLRenderingContextResource.StateParameters.forEach(function(parameter) {
-            glState[parameter] = Resource.toReplayable(gl.getParameter(gl[parameter]), cache);
+            glState[parameter] = maybeToReplayable(gl.getParameter(gl[parameter]));
         });
 
         // VERTEX_ATTRIB_ARRAYS
@@ -1897,39 +2006,51 @@
         var vertexAttribParameters = ["VERTEX_ATTRIB_ARRAY_BUFFER_BINDING", "VERTEX_ATTRIB_ARRAY_ENABLED", "VERTEX_ATTRIB_ARRAY_SIZE", "VERTEX_ATTRIB_ARRAY_STRIDE", "VERTEX_ATTRIB_ARRAY_TYPE", "VERTEX_ATTRIB_ARRAY_NORMALIZED", "CURRENT_VERTEX_ATTRIB"];
         var vertexAttribStates = [];
         for (var i = 0; i < maxVertexAttribs; ++i) {
-            var state = {};
+            var state = Object.create(null);
             vertexAttribParameters.forEach(function(attribParameter) {
-                state[attribParameter] = Resource.toReplayable(gl.getVertexAttrib(i, gl[attribParameter]), cache);
+                state[attribParameter] = maybeToReplayable(gl.getVertexAttrib(i, gl[attribParameter]));
             });
             state.VERTEX_ATTRIB_ARRAY_POINTER = gl.getVertexAttribOffset(i, gl.VERTEX_ATTRIB_ARRAY_POINTER);
             vertexAttribStates.push(state);
         }
-        glState.vertexAttribStates = vertexAttribStates;
+        glState.VERTEX_ATTRIB_ARRAYS = vertexAttribStates;
 
-        // TEXTURES
-        var currentTextureBinding = /** @type {number} */ (gl.getParameter(gl.ACTIVE_TEXTURE));
+        // TEXTURE_UNITS
+        var savedActiveTexture = /** @type {number} */ (gl.getParameter(gl.ACTIVE_TEXTURE));
         var maxTextureImageUnits = /** @type {number} */ (gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS));
-        var textureBindings = [];
+        var textureUnits = [];
         for (var i = 0; i < maxTextureImageUnits; ++i) {
             gl.activeTexture(gl.TEXTURE0 + i);
-            var state = {
-                TEXTURE_2D: Resource.toReplayable(gl.getParameter(gl.TEXTURE_BINDING_2D), cache),
-                TEXTURE_CUBE_MAP: Resource.toReplayable(gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP), cache)
-            };
-            textureBindings.push(state);
+            var state = Object.create(null);
+            state.TEXTURE_2D = maybeToReplayable(gl.getParameter(gl.TEXTURE_BINDING_2D));
+            state.TEXTURE_CUBE_MAP = maybeToReplayable(gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP));
+            textureUnits.push(state);
         }
-        glState.textureBindings = textureBindings;
-        gl.activeTexture(currentTextureBinding);
-
-        data.glState = glState;
+        glState.TEXTURE_UNITS = textureUnits;
+        gl.activeTexture(savedActiveTexture);
 
         this.restoreErrors(originalErrors);
+        return glState;
     },
 
     /**
      * @override
      * @param {!Object} data
-     * @param {!Cache} cache
+     * @param {!Cache.<ReplayableResource>} cache
+     */
+    _populateReplayableData: function(data, cache)
+    {
+        var gl = this.wrappedObject();
+        data.originalCanvas = gl.canvas;
+        data.originalContextAttributes = gl.getContextAttributes();
+        data.extensions = TypeUtils.cloneObject(this._extensions);
+        data.glState = this._internalCurrentState(cache);
+    },
+
+    /**
+     * @override
+     * @param {!Object} data
+     * @param {!Cache.<Resource>} cache
      */
     _doReplayCalls: function(data, cache)
     {
@@ -2003,7 +2124,7 @@
         // VERTEX_ATTRIB_ARRAYS
         var maxVertexAttribs = /** @type {number} */ (gl.getParameter(gl.MAX_VERTEX_ATTRIBS));
         for (var i = 0; i < maxVertexAttribs; ++i) {
-            var state = glState.vertexAttribStates[i] || {};
+            var state = glState.VERTEX_ATTRIB_ARRAYS[i] || {};
             if (state.VERTEX_ATTRIB_ARRAY_ENABLED)
                 gl.enableVertexAttribArray(i);
             else
@@ -2019,11 +2140,11 @@
         gl.bindBuffer(gl.ARRAY_BUFFER, /** @type {WebGLBuffer} */ (ReplayableResource.replay(glState.ARRAY_BUFFER_BINDING, cache)));
         gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, /** @type {WebGLBuffer} */ (ReplayableResource.replay(glState.ELEMENT_ARRAY_BUFFER_BINDING, cache)));
 
-        // TEXTURES
+        // TEXTURE_UNITS
         var maxTextureImageUnits = /** @type {number} */ (gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS));
         for (var i = 0; i < maxTextureImageUnits; ++i) {
             gl.activeTexture(gl.TEXTURE0 + i);
-            var state = glState.textureBindings[i] || {};
+            var state = glState.TEXTURE_UNITS[i] || {};
             gl.bindTexture(gl.TEXTURE_2D, /** @type {WebGLTexture} */ (ReplayableResource.replay(state.TEXTURE_2D, cache)));
             gl.bindTexture(gl.TEXTURE_CUBE_MAP, /** @type {WebGLTexture} */ (ReplayableResource.replay(state.TEXTURE_CUBE_MAP, cache)));
         }
@@ -2293,7 +2414,8 @@
     "textAlign",
     "textBaseline",
     "lineDashOffset",
-    // FIXME: Temporary properties implemented in JSC, but not in V8.
+    "imageSmoothingEnabled",
+    "webkitImageSmoothingEnabled",
     "webkitLineDash",
     "webkitLineDashOffset"
 ];
@@ -2367,13 +2489,71 @@
 
     /**
      * @override
+     * @return {!Array.<TypeUtils.InternalResourceStateDescriptor>}
+     */
+    currentState: function()
+    {
+        var result = [];
+        var state = this._internalCurrentState(null);
+        for (var pname in state)
+            result.push({ name: pname, value: state[pname] });
+        return result;
+    },
+
+    /**
+     * @param {?Cache.<ReplayableResource>} cache
+     * @return {!Object.<string, *>}
+     */
+    _internalCurrentState: function(cache)
+    {
+        /**
+         * @param {Resource|*} obj
+         * @return {Resource|ReplayableResource|*}
+         */
+        function maybeToReplayable(obj)
+        {
+            return cache ? Resource.toReplayable(obj, cache) : (Resource.forObject(obj) || obj);
+        }
+
+        var ctx = this.wrappedObject();
+        var state = Object.create(null);
+        CanvasRenderingContext2DResource.AttributeProperties.forEach(function(attribute) {
+            if (attribute in ctx)
+                state[attribute] = maybeToReplayable(ctx[attribute]);
+        });
+        if (ctx.getLineDash)
+            state.lineDash = ctx.getLineDash();
+        return state;
+    },
+
+    /**
+     * @param {Object.<string, *>} state
+     * @param {!Cache.<Resource>} cache
+     */
+    _applyAttributesState: function(state, cache)
+    {
+        if (!state)
+            return;
+        var ctx = this.wrappedObject();
+        for (var attribute in state) {
+            if (attribute === "lineDash") {
+                if (ctx.setLineDash)
+                    ctx.setLineDash(/** @type {Array.<number>} */ (state[attribute]));
+            } else
+                ctx[attribute] = ReplayableResource.replay(state[attribute], cache);
+        }
+    },
+
+    /**
+     * @override
      * @param {!Object} data
-     * @param {!Cache} cache
+     * @param {!Cache.<ReplayableResource>} cache
      */
     _populateReplayableData: function(data, cache)
     {
         var ctx = this.wrappedObject();
-        data.currentAttributes = this._currentAttributesState();
+        // FIXME: Convert resources in the state (CanvasGradient, CanvasPattern) to Replayable.
+        data.currentAttributes = this._internalCurrentState(null);
         data.originalCanvasCloned = TypeUtils.cloneIntoCanvas(ctx.canvas);
         if (ctx.getContextAttributes)
             data.originalContextAttributes = ctx.getContextAttributes();
@@ -2382,7 +2562,7 @@
     /**
      * @override
      * @param {!Object} data
-     * @param {!Cache} cache
+     * @param {!Cache.<Resource>} cache
      */
     _doReplayCalls: function(data, cache)
     {
@@ -2393,10 +2573,10 @@
         for (var i = 0, n = data.calls.length; i < n; ++i) {
             var replayableCall = /** @type {ReplayableCall} */ (data.calls[i]);
             if (replayableCall.functionName() === "save")
-                this._applyAttributesState(replayableCall.attachment("canvas2dAttributesState"));
+                this._applyAttributesState(replayableCall.attachment("canvas2dAttributesState"), cache);
             this._calls.push(replayableCall.replay(cache));
         }
-        this._applyAttributesState(data.currentAttributes);
+        this._applyAttributesState(data.currentAttributes, cache);
     },
 
     /**
@@ -2428,7 +2608,8 @@
      */
     pushCall_save: function(call)
     {
-        call.setAttachment("canvas2dAttributesState", this._currentAttributesState());
+        // FIXME: Convert resources in the state (CanvasGradient, CanvasPattern) to Replayable.
+        call.setAttachment("canvas2dAttributesState", this._internalCurrentState(null));
         this.pushCall(call);
     },
 
@@ -2572,39 +2753,6 @@
     },
 
     /**
-     * @return {!Object.<string, string>}
-     */
-    _currentAttributesState: function()
-    {
-        var ctx = this.wrappedObject();
-        var state = {};
-        state.attributes = {};
-        CanvasRenderingContext2DResource.AttributeProperties.forEach(function(attribute) {
-            state.attributes[attribute] = ctx[attribute];
-        });
-        if (ctx.getLineDash)
-            state.lineDash = ctx.getLineDash();
-        return state;
-    },
-
-    /**
-     * @param {Object.<string, string>=} state
-     */
-    _applyAttributesState: function(state)
-    {
-        if (!state)
-            return;
-        var ctx = this.wrappedObject();
-        if (state.attributes) {
-            Object.keys(state.attributes).forEach(function(attribute) {
-                ctx[attribute] = state.attributes[attribute];
-            });
-        }
-        if (ctx.setLineDash)
-            ctx.setLineDash(state.lineDash);
-    },
-
-    /**
      * @override
      * @return {!Object.<string, Function>}
      */
@@ -2694,7 +2842,7 @@
      */
     formatValue: function(value)
     {
-        if (value instanceof ReplayableResource) {
+        if (value instanceof Resource || value instanceof ReplayableResource) {
             return {
                 description: value.description(),
                 resourceId: CallFormatter.makeStringResourceId(value.id())
@@ -2711,6 +2859,23 @@
         if (remoteObject.objectId)
             injectedScript.releaseObject(remoteObject.objectId);
         return result;
+    },
+
+    /**
+     * @param {!Array.<TypeUtils.InternalResourceStateDescriptor>} descriptors
+     * @return {!Array.<!CanvasAgent.ResourceStateDescriptor>}
+     */
+    convertResourceStateDescriptors: function(descriptors)
+    {
+        var result = [];
+        for (var i = 0, n = descriptors.length; i < n; ++i) {
+            var d = descriptors[i];
+            if (d.values)
+                result.push({ name: d.name, values: this.convertResourceStateDescriptors(d.values) });
+            else
+                result.push({ name: d.name, value: this.formatValue(d.value) });
+        }
+        return result;
     }
 }
 
@@ -2730,16 +2895,15 @@
 }
 
 /**
- * @param {!ReplayableCall} replayableCall
+ * @param {!Resource|!ReplayableResource} resource
  * @return {!CallFormatter}
  */
-CallFormatter.forReplayableCall = function(replayableCall)
+CallFormatter.forResource = function(resource)
 {
-    var resource = replayableCall.replayableResource();
     var formatter = CallFormatter._formatters[resource.name()];
     if (!formatter) {
-        var contextResource = resource.replayableContextResource();
-        formatter = CallFormatter._formatters[contextResource.name()] || new CallFormatter();
+        var contextResource = resource.contextResource();
+        formatter = (contextResource && CallFormatter._formatters[contextResource.name()]) || new CallFormatter();
     }
     return formatter;
 }
@@ -3053,7 +3217,7 @@
 {
     /** @type {!Array.<ReplayableCall>} */
     this._replayableCalls = [];
-    /** @type {!Cache} */
+    /** @type {!Cache.<ReplayableResource>} */
     this._replayablesCache = new Cache();
     /** @type {!Object.<number, boolean>} */
     this._frameEndCallIndexes = {};
@@ -3078,11 +3242,11 @@
 
     /**
      * @param {number} id
-     * @return {ReplayableResource}
+     * @return {ReplayableResource|undefined}
      */
     replayableResource: function(id)
     {
-        return /** @type {ReplayableResource} */ (this._replayablesCache.get(id));
+        return this._replayablesCache.get(id);
     },
 
     /**
@@ -3128,7 +3292,7 @@
     this._traceLog = traceLog;
     /** @type {number} */
     this._nextReplayStep = 0;
-    /** @type {!Cache} */
+    /** @type {!Cache.<Resource>} */
     this._replayWorldCache = new Cache();
 }
 
@@ -3143,11 +3307,11 @@
 
     /**
      * @param {number} id
-     * @return {Resource}
+     * @return {Resource|undefined}
      */
     replayWorldResource: function(id)
     {
-        return /** @type {Resource} */ (this._replayWorldCache.get(id));
+        return this._replayWorldCache.get(id);
     },
 
     /**
@@ -3448,10 +3612,11 @@
         var contextIds = {};
         for (var i = fromIndex; i <= toIndex; ++i) {
             var call = replayableCalls[i];
-            var contextResource = call.replayableResource().replayableContextResource();
+            var resource = call.replayableResource();
+            var contextResource = resource.contextResource();
             var stackTrace = call.stackTrace();
             var callFrame = stackTrace ? stackTrace.callFrame(0) || {} : {};
-            var item = CallFormatter.forReplayableCall(call).formatCall(call);
+            var item = CallFormatter.forResource(resource).formatCall(call);
             item.contextId = CallFormatter.makeStringResourceId(contextResource.id());
             item.sourceURL = callFrame.sourceURL;
             item.lineNumber = callFrame.lineNumber;
@@ -3460,7 +3625,7 @@
             result.calls.push(item);
             if (!contextIds[item.contextId]) {
                 contextIds[item.contextId] = true;
-                result.contexts.push(CallFormatter.forReplayableCall(call).formatValue(contextResource));
+                result.contexts.push(CallFormatter.forResource(resource).formatValue(contextResource));
             }
         }
         return result;
@@ -3469,7 +3634,7 @@
     /**
      * @param {CanvasAgent.TraceLogId} traceLogId
      * @param {number} stepNo
-     * @return {!CanvasAgent.ResourceState|string}
+     * @return {{resourceState: !CanvasAgent.ResourceState, replayTime: number}|string}
      */
     replayTraceLog: function(traceLogId, stepNo)
     {
@@ -3477,14 +3642,21 @@
         if (!traceLog)
             return "Error: Trace log with the given ID not found.";
         this._traceLogPlayers[traceLogId] = this._traceLogPlayers[traceLogId] || new TraceLogPlayer(traceLog);
+
+        var beforeTime = TypeUtils.now();
         var lastCall = this._traceLogPlayers[traceLogId].stepTo(stepNo);
+        var replayTime = Math.max(0, TypeUtils.now() - beforeTime);
+
         var resource = lastCall.resource();
         var dataURL = resource.toDataURL();
         if (!dataURL) {
             resource = resource.contextResource();
             dataURL = resource.toDataURL();
         }
-        return this._makeResourceState(CallFormatter.makeStringResourceId(resource.id()), traceLogId, dataURL);
+        return {
+            resourceState: this._makeResourceState(resource.id(), traceLogId, resource, dataURL),
+            replayTime: replayTime
+        };
     },
 
     /**
@@ -3509,7 +3681,7 @@
 
         var traceLogPlayer = this._traceLogPlayers[traceLogId];
         var resource = traceLogPlayer && traceLogPlayer.replayWorldResource(resourceId);
-        return this._makeResourceState(stringResourceId, traceLogId, resource ? resource.toDataURL() : "");
+        return this._makeResourceState(resourceId, traceLogId, resource);
     },
 
     /**
@@ -3517,7 +3689,7 @@
      * @param {number} callIndex
      * @param {number} argumentIndex
      * @param {string} objectGroup
-     * @return {!Object|string}
+     * @return {{result:(!RuntimeAgent.RemoteObject|undefined), resourceState:(!CanvasAgent.ResourceState|undefined)}|string}
      */
     evaluateTraceLogCallArgument: function(traceLogId, callIndex, argumentIndex, objectGroup)
     {
@@ -3544,7 +3716,7 @@
         if (value instanceof ReplayableResource) {
             var traceLogPlayer = this._traceLogPlayers[traceLogId];
             var resource = traceLogPlayer && traceLogPlayer.replayWorldResource(value.id());
-            var resourceState = this._makeResourceState(CallFormatter.makeStringResourceId(value.id()), traceLogId, resource ? resource.toDataURL() : "");
+            var resourceState = this._makeResourceState(value.id(), traceLogId, resource);
             return { resourceState: resourceState };
         }
 
@@ -3561,18 +3733,23 @@
     },
 
     /**
-     * @param {CanvasAgent.ResourceId} stringResourceId
+     * @param {number} resourceId
      * @param {CanvasAgent.TraceLogId} traceLogId
-     * @param {string} imageURL
+     * @param {Resource|undefined} resource
+     * @param {string=} overrideImageURL
      * @return {!CanvasAgent.ResourceState}
      */
-    _makeResourceState: function(stringResourceId, traceLogId, imageURL)
+    _makeResourceState: function(resourceId, traceLogId, resource, overrideImageURL)
     {
-        return {
-            id: stringResourceId,
-            traceLogId: traceLogId,
-            imageURL: imageURL
+        var result = {
+            id: CallFormatter.makeStringResourceId(resourceId),
+            traceLogId: traceLogId
         };
+        if (resource) {
+            result.imageURL = overrideImageURL || resource.toDataURL();
+            result.descriptors = CallFormatter.forResource(resource).convertResourceStateDescriptors(resource.currentState());
+        }
+        return result;
     },
 
     /**
diff --git a/Source/core/inspector/InjectedScriptExterns.js b/Source/core/inspector/InjectedScriptExterns.js
index 3076568..513bff4 100644
--- a/Source/core/inspector/InjectedScriptExterns.js
+++ b/Source/core/inspector/InjectedScriptExterns.js
@@ -137,6 +137,8 @@
     this.column;
     /** @type {*} */
     this.thisObject;
+    /** @type {string} */
+    this.stepInPositions;
 }
 
 /**
diff --git a/Source/core/inspector/InjectedScriptModule.cpp b/Source/core/inspector/InjectedScriptModule.cpp
index f95a476..401a05b 100644
--- a/Source/core/inspector/InjectedScriptModule.cpp
+++ b/Source/core/inspector/InjectedScriptModule.cpp
@@ -33,6 +33,7 @@
 
 #include "bindings/v8/ScriptFunctionCall.h"
 #include "bindings/v8/ScriptObject.h"
+#include "bindings/v8/ScriptScope.h"
 #include "core/inspector/InjectedScript.h"
 #include "core/inspector/InjectedScriptManager.h"
 
@@ -56,6 +57,7 @@
     bool hadException = false;
     ScriptValue resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
     ASSERT(!hadException);
+    ScriptScope scope(scriptState);
     if (hadException || resultValue.hasNoValue() || !resultValue.isObject()) {
         ScriptFunctionCall function(injectedScript.injectedScriptObject(), "injectModule");
         function.appendArgument(name());
@@ -72,4 +74,3 @@
 }
 
 } // namespace WebCore
-
diff --git a/Source/core/inspector/InjectedScriptSource.js b/Source/core/inspector/InjectedScriptSource.js
index c59c45e..19fad1a 100644
--- a/Source/core/inspector/InjectedScriptSource.js
+++ b/Source/core/inspector/InjectedScriptSource.js
@@ -640,6 +640,22 @@
     },
 
     /**
+     * @param {Object} topCallFrame
+     * @param {string} callFrameId
+     * @return {*} a stepIn position array ready for protocol JSON or a string error
+     */
+    getStepInPositions: function(topCallFrame, callFrameId)
+    {
+        var callFrame = this._callFrameForId(topCallFrame, callFrameId);
+        if (!callFrame)
+            return "Could not find call frame with given id";
+        var stepInPositionsUnpacked = JSON.parse(callFrame.stepInPositions);
+        if (typeof stepInPositionsUnpacked !== "object")
+            return "Step in positions not available";
+        return stepInPositionsUnpacked;
+    },
+
+    /**
      * Either callFrameId or functionObjectId must be specified.
      * @param {Object} topCallFrame
      * @param {string|boolean} callFrameId or false
diff --git a/Source/core/inspector/InspectorApplicationCacheAgent.cpp b/Source/core/inspector/InspectorApplicationCacheAgent.cpp
index 608b7bf..7ea825a 100644
--- a/Source/core/inspector/InspectorApplicationCacheAgent.cpp
+++ b/Source/core/inspector/InspectorApplicationCacheAgent.cpp
@@ -43,7 +43,7 @@
 }
 
 InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state, InspectorPageAgent* pageAgent)
-    : InspectorBaseAgent<InspectorApplicationCacheAgent>("ApplicationCache", instrumentingAgents, state)
+    : InspectorBaseAgent<InspectorApplicationCacheAgent>(ASCIILiteral("ApplicationCache"), instrumentingAgents, state)
     , m_pageAgent(pageAgent)
     , m_frontend(0)
 {
diff --git a/Source/core/inspector/InspectorCSSAgent.cpp b/Source/core/inspector/InspectorCSSAgent.cpp
index 92d4f35..4c2e610 100644
--- a/Source/core/inspector/InspectorCSSAgent.cpp
+++ b/Source/core/inspector/InspectorCSSAgent.cpp
@@ -27,6 +27,7 @@
 
 #include "CSSPropertyNames.h"
 #include "InspectorTypeBuilder.h"
+#include "StylePropertyShorthand.h"
 #include "core/css/CSSComputedStyleDeclaration.h"
 #include "core/css/CSSImportRule.h"
 #include "core/css/CSSMediaRule.h"
@@ -37,7 +38,6 @@
 #include "core/css/CSSStyleSheet.h"
 #include "core/css/MediaList.h"
 #include "core/css/StylePropertySet.h"
-#include "core/css/StylePropertyShorthand.h"
 #include "core/css/StyleRule.h"
 #include "core/css/StyleSheet.h"
 #include "core/css/StyleSheetContents.h"
@@ -843,6 +843,7 @@
     , m_pageAgent(pageAgent)
     , m_lastStyleSheetId(1)
     , m_creatingViaInspectorStyleSheet(false)
+    , m_isSettingStyleSheetText(false)
 {
     m_domAgent->setDOMListener(this);
 }
@@ -1004,8 +1005,10 @@
     m_frontend->regionOversetChanged(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId));
 }
 
-void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document, const Vector<RefPtr<StyleSheet> >& newSheets)
+void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document, const StyleSheetVector& newSheets)
 {
+    if (m_isSettingStyleSheetText)
+        return;
     HashSet<CSSStyleSheet*> removedSheets;
     for (CSSStyleSheetToInspectorStyleSheet::iterator it = m_cssStyleSheetToInspectorStyleSheet.begin(); it != m_cssStyleSheetToInspectorStyleSheet.end(); ++it) {
         if (it->value->canBind() && (!it->key->ownerDocument() || it->key->ownerDocument() == document))
@@ -1055,7 +1058,7 @@
     Document* document = frame->document();
     if (!document)
         return;
-    Vector<RefPtr<StyleSheet> > newSheets;
+    StyleSheetVector newSheets;
     activeStyleSheetsUpdated(document, newSheets);
 }
 
@@ -1857,6 +1860,18 @@
         m_frontend->styleSheetChanged(styleSheet->id());
 }
 
+void InspectorCSSAgent::willReparseStyleSheet()
+{
+    ASSERT(!m_isSettingStyleSheetText);
+    m_isSettingStyleSheetText = true;
+}
+
+void InspectorCSSAgent::didReparseStyleSheet()
+{
+    ASSERT(m_isSettingStyleSheetText);
+    m_isSettingStyleSheetText = false;
+}
+
 void InspectorCSSAgent::resetPseudoStates()
 {
     HashSet<Document*> documentsToChange;
diff --git a/Source/core/inspector/InspectorCSSAgent.h b/Source/core/inspector/InspectorCSSAgent.h
index 5e433b0..29341ff 100644
--- a/Source/core/inspector/InspectorCSSAgent.h
+++ b/Source/core/inspector/InspectorCSSAgent.h
@@ -63,8 +63,10 @@
 class StyleRule;
 class StyleSheetVisitor;
 class UpdateRegionLayoutTask;
+class UpdateActiveStylesheetsTask;
 
 typedef HashMap<CSSStyleSheet*, RefPtr<InspectorStyleSheet> > CSSStyleSheetToInspectorStyleSheet;
+typedef Vector<RefPtr<StyleSheet> > StyleSheetVector;
 
 class InspectorCSSAgent
     : public InspectorBaseAgent<InspectorCSSAgent>
@@ -127,7 +129,7 @@
     void didUpdateRegionLayout(Document*, NamedFlow*);
     void didChangeRegionOverset(Document*, NamedFlow*);
 
-    void activeStyleSheetsUpdated(Document*, const Vector<RefPtr<StyleSheet> >& newSheets);
+    void activeStyleSheetsUpdated(Document*, const StyleSheetVector& newSheets);
     void frameDetachedFromParent(Frame*);
 
     virtual void getComputedStyleForNode(ErrorString*, int nodeId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> >&);
@@ -199,7 +201,9 @@
     virtual void didModifyDOMAttr(Element*);
 
     // InspectorCSSAgent::Listener implementation
-    virtual void styleSheetChanged(InspectorStyleSheet*);
+    virtual void styleSheetChanged(InspectorStyleSheet*) OVERRIDE;
+    virtual void willReparseStyleSheet() OVERRIDE;
+    virtual void didReparseStyleSheet() OVERRIDE;
 
     void resetPseudoStates();
 
@@ -218,6 +222,7 @@
 
     int m_lastStyleSheetId;
     bool m_creatingViaInspectorStyleSheet;
+    bool m_isSettingStyleSheetText;
 
     OwnPtr<SelectorProfile> m_currentSelectorProfile;
 
diff --git a/Source/core/inspector/InspectorCanvasAgent.cpp b/Source/core/inspector/InspectorCanvasAgent.cpp
index 5c95503..58408b7 100644
--- a/Source/core/inspector/InspectorCanvasAgent.cpp
+++ b/Source/core/inspector/InspectorCanvasAgent.cpp
@@ -169,11 +169,11 @@
         module.traceLog(errorString, traceLogId, startOffset, maxLength, &traceLog);
 }
 
-void InspectorCanvasAgent::replayTraceLog(ErrorString* errorString, const TraceLogId& traceLogId, int stepNo, RefPtr<ResourceState>& result)
+void InspectorCanvasAgent::replayTraceLog(ErrorString* errorString, const TraceLogId& traceLogId, int stepNo, RefPtr<ResourceState>& result, double* replayTime)
 {
     InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId);
     if (!module.hasNoValue())
-        module.replayTraceLog(errorString, traceLogId, stepNo, &result);
+        module.replayTraceLog(errorString, traceLogId, stepNo, &result, replayTime);
 }
 
 void InspectorCanvasAgent::getResourceState(ErrorString* errorString, const TraceLogId& traceLogId, const ResourceId& resourceId, RefPtr<ResourceState>& result)
diff --git a/Source/core/inspector/InspectorCanvasAgent.h b/Source/core/inspector/InspectorCanvasAgent.h
index e7ba554..d26b990 100644
--- a/Source/core/inspector/InspectorCanvasAgent.h
+++ b/Source/core/inspector/InspectorCanvasAgent.h
@@ -82,7 +82,7 @@
     virtual void startCapturing(ErrorString*, const TypeBuilder::Network::FrameId*, TypeBuilder::Canvas::TraceLogId*);
     virtual void stopCapturing(ErrorString*, const TypeBuilder::Canvas::TraceLogId&);
     virtual void getTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, const int*, const int*, RefPtr<TypeBuilder::Canvas::TraceLog>&);
-    virtual void replayTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, int, RefPtr<TypeBuilder::Canvas::ResourceState>&);
+    virtual void replayTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, int, RefPtr<TypeBuilder::Canvas::ResourceState>&, double*);
     virtual void getResourceState(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, const TypeBuilder::Canvas::ResourceId&, RefPtr<TypeBuilder::Canvas::ResourceState>&);
     virtual void evaluateTraceLogCallArgument(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, int, int, const String*, RefPtr<TypeBuilder::Runtime::RemoteObject>&, RefPtr<TypeBuilder::Canvas::ResourceState>&);
 
diff --git a/Source/core/inspector/InspectorController.cpp b/Source/core/inspector/InspectorController.cpp
index f25334c..750904c 100644
--- a/Source/core/inspector/InspectorController.cpp
+++ b/Source/core/inspector/InspectorController.cpp
@@ -101,7 +101,7 @@
 
     m_agents.append(InspectorDOMStorageAgent::create(m_instrumentingAgents.get(), pageAgent, m_state.get()));
 
-    OwnPtr<InspectorMemoryAgent> memoryAgentPtr(InspectorMemoryAgent::create(m_instrumentingAgents.get(), inspectorClient, m_state.get(), m_page));
+    OwnPtr<InspectorMemoryAgent> memoryAgentPtr(InspectorMemoryAgent::create(m_instrumentingAgents.get(), m_state.get()));
     m_memoryAgent = memoryAgentPtr.get();
     m_agents.append(memoryAgentPtr.release());
 
@@ -344,7 +344,7 @@
     // Overlay should not consume events.
     m_overlay->handleTouchEvent(event);
     if (InspectorDOMAgent* domAgent = m_instrumentingAgents->inspectorDOMAgent())
-        domAgent->handleTouchEvent(frame, event);
+        return domAgent->handleTouchEvent(frame, event);
     return false;
 }
 
diff --git a/Source/core/inspector/InspectorDatabaseAgent.cpp b/Source/core/inspector/InspectorDatabaseAgent.cpp
index 2b3ad25..170b316 100644
--- a/Source/core/inspector/InspectorDatabaseAgent.cpp
+++ b/Source/core/inspector/InspectorDatabaseAgent.cpp
@@ -30,7 +30,7 @@
 #include "core/inspector/InspectorDatabaseAgent.h"
 
 #include "InspectorFrontend.h"
-#include "core/dom/ExceptionCodePlaceholder.h"
+#include "bindings/v8/ExceptionStatePlaceholder.h"
 #include "core/html/VoidCallback.h"
 #include "core/inspector/InspectorDatabaseResource.h"
 #include "core/inspector/InspectorState.h"
@@ -145,7 +145,7 @@
         Vector<SQLValue> sqlValues;
         RefPtr<SQLStatementCallback> callback(StatementCallback::create(m_requestCallback.get()));
         RefPtr<SQLStatementErrorCallback> errorCallback(StatementErrorCallback::create(m_requestCallback.get()));
-        transaction->executeSQL(m_sqlStatement, sqlValues, callback.release(), errorCallback.release(), IGNORE_EXCEPTION);
+        transaction->executeSQL(m_sqlStatement, sqlValues, callback.release(), errorCallback.release(), IGNORE_EXCEPTION_STATE);
         return true;
     }
 private:
diff --git a/Source/core/inspector/InspectorDebuggerAgent.cpp b/Source/core/inspector/InspectorDebuggerAgent.cpp
index 16ae1ee..7913f01 100644
--- a/Source/core/inspector/InspectorDebuggerAgent.cpp
+++ b/Source/core/inspector/InspectorDebuggerAgent.cpp
@@ -253,7 +253,16 @@
     bool isAntiBreakpointValue = isAntiBreakpoint && *isAntiBreakpoint;
 
     String url = optionalURL ? *optionalURL : *optionalURLRegex;
-    int columnNumber = optionalColumnNumber ? *optionalColumnNumber : 0;
+    int columnNumber;
+    if (optionalColumnNumber) {
+        columnNumber = *optionalColumnNumber;
+        if (columnNumber < 0) {
+            *errorString = "Incorrect column number";
+            return;
+        }
+    } else {
+        columnNumber = isAntiBreakpointValue ? -1 : 0;
+    }
     String condition = optionalCondition ? *optionalCondition : "";
     bool isRegex = optionalURLRegex;
 
@@ -365,6 +374,25 @@
     resume(errorString);
 }
 
+void InspectorDebuggerAgent::getStepInPositions(ErrorString* errorString, const String& callFrameId, RefPtr<Array<TypeBuilder::Debugger::Location> >& positions)
+{
+    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(callFrameId);
+    if (injectedScript.hasNoValue()) {
+        *errorString = "Inspected frame has gone";
+        return;
+    }
+
+    injectedScript.getStepInPositions(errorString, m_currentCallStack, callFrameId, positions);
+}
+
+void InspectorDebuggerAgent::getBacktrace(ErrorString* errorString, RefPtr<Array<TypeBuilder::Debugger::CallFrame> >& callFrames)
+{
+    if (!assertPaused(errorString))
+        return;
+    scriptDebugServer().updateCallStack(&m_currentCallStack);
+    callFrames = currentCallFrames();
+}
+
 bool InspectorDebuggerAgent::shouldSkipPause(RefPtr<JavaScriptCallFrame>& topFrame)
 {
     // Prepare top frame parameters;
@@ -395,7 +423,10 @@
         int breakColumnNumber;
         breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakColumnNumber);
 
-        if (breakLineNumber != topFrameLineNumber || breakColumnNumber != topFrameColumnNumber)
+        if (breakLineNumber != topFrameLineNumber)
+            continue;
+
+        if (breakColumnNumber != -1 && breakColumnNumber != topFrameColumnNumber)
             continue;
 
         bool isRegex;
diff --git a/Source/core/inspector/InspectorDebuggerAgent.h b/Source/core/inspector/InspectorDebuggerAgent.h
index c3f5159..df71914 100644
--- a/Source/core/inspector/InspectorDebuggerAgent.h
+++ b/Source/core/inspector/InspectorDebuggerAgent.h
@@ -91,6 +91,8 @@
     virtual void setBreakpoint(ErrorString*, const RefPtr<JSONObject>& location, const String* optionalCondition, TypeBuilder::Debugger::BreakpointId*, RefPtr<TypeBuilder::Debugger::Location>& actualLocation);
     virtual void removeBreakpoint(ErrorString*, const String& breakpointId);
     virtual void continueToLocation(ErrorString*, const RefPtr<JSONObject>& location, const bool* interstateLocationOpt);
+    virtual void getStepInPositions(ErrorString*, const String& callFrameId, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::Location> >& positions);
+    virtual void getBacktrace(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame> >&);
 
     virtual void searchInContent(ErrorString*, const String& scriptId, const String& query, const bool* optionalCaseSensitive, const bool* optionalIsRegex, RefPtr<TypeBuilder::Array<TypeBuilder::Page::SearchMatch> >&);
     virtual void setScriptSource(ErrorString*, RefPtr<TypeBuilder::Debugger::SetScriptSourceError>&, const String& scriptId, const String& newContent, const bool* preview, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame> >& newCallFrames, RefPtr<JSONObject>& result);
diff --git a/Source/core/inspector/InspectorInstrumentation.idl b/Source/core/inspector/InspectorInstrumentation.idl
index 4b01aad..672286e 100644
--- a/Source/core/inspector/InspectorInstrumentation.idl
+++ b/Source/core/inspector/InspectorInstrumentation.idl
@@ -206,10 +206,10 @@
     void didDispatchXHRLoadEvent(const InspectorInstrumentationCookie&);
 
     [Timeline, Inline=FastReturn]
-    void willScrollLayer([Keep] Frame*);
+    void willScrollLayer([Keep] RenderObject*);
 
     [Timeline, Inline=FastReturn]
-    void didScrollLayer(Frame*);
+    void didScrollLayer(RenderObject*);
 
     [Timeline, Inline=FastReturn]
     void willPaint([Keep] RenderObject*);
diff --git a/Source/core/inspector/InspectorMemoryAgent.cpp b/Source/core/inspector/InspectorMemoryAgent.cpp
index b89cee7..33fc481 100644
--- a/Source/core/inspector/InspectorMemoryAgent.cpp
+++ b/Source/core/inspector/InspectorMemoryAgent.cpp
@@ -32,24 +32,9 @@
 #include "core/inspector/InspectorMemoryAgent.h"
 
 #include "InspectorFrontend.h"
-#include "bindings/v8/ScriptGCEvent.h"
-#include "bindings/v8/ScriptProfiler.h"
-#include "core/dom/Document.h"
-#include "core/dom/Node.h"
-#include "core/inspector/BindingVisitors.h"
-#include "core/inspector/InspectorClient.h"
-#include "core/inspector/InspectorDOMStorageAgent.h"
-#include "core/loader/cache/MemoryCache.h"
-#include "core/page/Frame.h"
-#include "core/page/Page.h"
-#include "core/platform/JSONValues.h"
-#include "wtf/ArrayBufferView.h"
-#include "wtf/NonCopyingSort.h"
+#include "core/inspector/InspectorCounters.h"
 #include "wtf/OwnPtr.h"
 #include "wtf/PassOwnPtr.h"
-#include "wtf/Vector.h"
-#include "wtf/text/StringImpl.h"
-#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
@@ -64,10 +49,8 @@
     *jsEventListeners = ThreadLocalInspectorCounters::current().counterValue(ThreadLocalInspectorCounters::JSEventListenerCounter);
 }
 
-InspectorMemoryAgent::InspectorMemoryAgent(InstrumentingAgents* instrumentingAgents, InspectorClient* client, InspectorCompositeState* state, Page* page)
+InspectorMemoryAgent::InspectorMemoryAgent(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state)
     : InspectorBaseAgent<InspectorMemoryAgent>("Memory", instrumentingAgents, state)
-    , m_inspectorClient(client)
-    , m_page(page)
     , m_frontend(0)
 {
 }
diff --git a/Source/core/inspector/InspectorMemoryAgent.h b/Source/core/inspector/InspectorMemoryAgent.h
index 19a7ee3..1aa511f 100644
--- a/Source/core/inspector/InspectorMemoryAgent.h
+++ b/Source/core/inspector/InspectorMemoryAgent.h
@@ -34,15 +34,10 @@
 #include "InspectorFrontend.h"
 #include "core/inspector/InspectorBaseAgent.h"
 #include "wtf/PassOwnPtr.h"
-#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
-class InspectorClient;
-class InspectorDOMStorageAgent;
-class InspectorState;
 class InstrumentingAgents;
-class Page;
 
 typedef String ErrorString;
 
@@ -51,26 +46,22 @@
 public:
     typedef Vector<OwnPtr<InspectorBaseAgentInterface> > InspectorAgents;
 
-    static PassOwnPtr<InspectorMemoryAgent> create(InstrumentingAgents* instrumentingAgents, InspectorClient* client, InspectorCompositeState* state, Page* page)
+    static PassOwnPtr<InspectorMemoryAgent> create(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state)
     {
-        return adoptPtr(new InspectorMemoryAgent(instrumentingAgents, client, state, page));
+        return adoptPtr(new InspectorMemoryAgent(instrumentingAgents, state));
     }
     virtual ~InspectorMemoryAgent();
 
     virtual void getDOMCounters(ErrorString*, int* documents, int* nodes, int* jsEventListeners);
 
-    void getProcessMemoryDistributionMap(HashMap<String, size_t>* memoryInfo);
-
     virtual void setFrontend(InspectorFrontend*);
     virtual void clearFrontend();
 
 private:
-    InspectorMemoryAgent(InstrumentingAgents*, InspectorClient*, InspectorCompositeState*, Page*);
+    InspectorMemoryAgent(InstrumentingAgents*, InspectorCompositeState*);
 
     PassRefPtr<JSONObject> getProcessMemoryDistributionImpl(bool reportGraph, HashMap<String, size_t>* memoryInfo);
 
-    InspectorClient* m_inspectorClient;
-    Page* m_page;
     InspectorFrontend::Memory* m_frontend;
 };
 
diff --git a/Source/core/inspector/InspectorPageAgent.cpp b/Source/core/inspector/InspectorPageAgent.cpp
index cafe343..6adee63 100644
--- a/Source/core/inspector/InspectorPageAgent.cpp
+++ b/Source/core/inspector/InspectorPageAgent.cpp
@@ -448,7 +448,7 @@
 {
     m_pendingScriptToEvaluateOnLoadOnce = optionalScriptToEvaluateOnLoad ? *optionalScriptToEvaluateOnLoad : "";
     m_pendingScriptPreprocessor = optionalScriptPreprocessor ? *optionalScriptPreprocessor : "";
-    m_page->mainFrame()->loader()->reload(optionalIgnoreCache ? *optionalIgnoreCache : false);
+    m_page->mainFrame()->loader()->reload(optionalIgnoreCache && *optionalIgnoreCache ? EndToEndReload : NormalReload);
 }
 
 void InspectorPageAgent::navigate(ErrorString*, const String& url)
diff --git a/Source/core/inspector/InspectorPageAgent.h b/Source/core/inspector/InspectorPageAgent.h
index f73f6f9..66a9fc4 100644
--- a/Source/core/inspector/InspectorPageAgent.h
+++ b/Source/core/inspector/InspectorPageAgent.h
@@ -33,8 +33,8 @@
 
 
 #include "InspectorFrontend.h"
-#include "core/dom/DeviceOrientationData.h"
 #include "core/inspector/InspectorBaseAgent.h"
+#include "modules/device_orientation/DeviceOrientationData.h"
 #include "modules/geolocation/GeolocationPosition.h"
 #include "wtf/HashMap.h"
 #include "wtf/text/WTFString.h"
diff --git a/Source/core/inspector/InspectorStyleSheet.cpp b/Source/core/inspector/InspectorStyleSheet.cpp
index c46fff1..d825322 100644
--- a/Source/core/inspector/InspectorStyleSheet.cpp
+++ b/Source/core/inspector/InspectorStyleSheet.cpp
@@ -1009,6 +1009,9 @@
 
 void InspectorStyleSheet::reparseStyleSheet(const String& text)
 {
+    if (m_listener)
+        m_listener->willReparseStyleSheet();
+
     {
         // Have a separate scope for clearRules() (bug 95324).
         CSSStyleSheet::RuleMutationScope mutationScope(m_pageStyleSheet.get());
@@ -1019,9 +1022,13 @@
         m_isReparsing = true;
         CSSStyleSheet::RuleMutationScope mutationScope(m_pageStyleSheet.get());
         m_pageStyleSheet->contents()->parseString(text);
-        fireStyleSheetChanged();
         m_isReparsing = false;
     }
+
+    if (m_listener)
+        m_listener->didReparseStyleSheet();
+    fireStyleSheetChanged();
+    m_pageStyleSheet->ownerDocument()->styleResolverChanged(RecalcStyleImmediately, FullStyleUpdate);
 }
 
 bool InspectorStyleSheet::setText(const String& text, ExceptionCode& ec)
diff --git a/Source/core/inspector/InspectorStyleSheet.h b/Source/core/inspector/InspectorStyleSheet.h
index 9082de5..e98068f 100644
--- a/Source/core/inspector/InspectorStyleSheet.h
+++ b/Source/core/inspector/InspectorStyleSheet.h
@@ -168,6 +168,8 @@
         Listener() { }
         virtual ~Listener() { }
         virtual void styleSheetChanged(InspectorStyleSheet*) = 0;
+        virtual void willReparseStyleSheet() = 0;
+        virtual void didReparseStyleSheet() = 0;
     };
 
     typedef HashMap<CSSStyleDeclaration*, RefPtr<InspectorStyle> > InspectorStyleMap;
diff --git a/Source/core/inspector/InspectorTimelineAgent.cpp b/Source/core/inspector/InspectorTimelineAgent.cpp
index 5996e685..6e2dee5 100644
--- a/Source/core/inspector/InspectorTimelineAgent.cpp
+++ b/Source/core/inspector/InspectorTimelineAgent.cpp
@@ -381,9 +381,9 @@
     didCompleteCurrentRecord(TimelineRecordType::Paint);
 }
 
-void InspectorTimelineAgent::willScrollLayer(Frame* frame)
+void InspectorTimelineAgent::willScrollLayer(RenderObject* renderer)
 {
-    pushCurrentRecord(JSONObject::create(), TimelineRecordType::ScrollLayer, false, frame);
+    pushCurrentRecord(TimelineRecordFactory::createLayerData(idForNode(renderer->generatingNode())), TimelineRecordType::ScrollLayer, false, renderer->frame());
 }
 
 void InspectorTimelineAgent::didScrollLayer()
diff --git a/Source/core/inspector/InspectorTimelineAgent.h b/Source/core/inspector/InspectorTimelineAgent.h
index 574a4cb..c74fb70 100644
--- a/Source/core/inspector/InspectorTimelineAgent.h
+++ b/Source/core/inspector/InspectorTimelineAgent.h
@@ -151,7 +151,7 @@
     void willPaint(RenderObject*);
     void didPaint(RenderObject*, GraphicsContext*, const LayoutRect&);
 
-    void willScrollLayer(Frame*);
+    void willScrollLayer(RenderObject*);
     void didScrollLayer();
 
     void willComposite();
diff --git a/Source/core/inspector/JavaScriptCallFrame.cpp b/Source/core/inspector/JavaScriptCallFrame.cpp
index 7abf059..d82e8af 100644
--- a/Source/core/inspector/JavaScriptCallFrame.cpp
+++ b/Source/core/inspector/JavaScriptCallFrame.cpp
@@ -119,6 +119,14 @@
     return m_callFrame.newLocal(m_isolate)->Get(v8::String::NewSymbol("thisObject"));
 }
 
+String JavaScriptCallFrame::stepInPositions() const
+{
+    v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate);
+    v8::Handle<v8::Function> stepInPositions = v8::Handle<v8::Function>::Cast(callFrame->Get(v8::String::NewSymbol("stepInPositions")));
+    v8::Handle<v8::Value> result = stepInPositions->Call(callFrame, 0, 0);
+    return toWebCoreStringWithUndefinedOrNullCheck(result);
+}
+
 v8::Handle<v8::Value> JavaScriptCallFrame::evaluate(const String& expression)
 {
     v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate);
diff --git a/Source/core/inspector/JavaScriptCallFrame.h b/Source/core/inspector/JavaScriptCallFrame.h
index b92fb13..af95698 100644
--- a/Source/core/inspector/JavaScriptCallFrame.h
+++ b/Source/core/inspector/JavaScriptCallFrame.h
@@ -58,6 +58,7 @@
     v8::Handle<v8::Value> scopeChain() const;
     int scopeType(int scopeIndex) const;
     v8::Handle<v8::Value> thisObject() const;
+    String stepInPositions() const;
 
     v8::Handle<v8::Value> evaluate(const String& expression);
     v8::Handle<v8::Value> restart();
diff --git a/Source/core/inspector/JavaScriptCallFrame.idl b/Source/core/inspector/JavaScriptCallFrame.idl
index 86ae41d..26ae291 100644
--- a/Source/core/inspector/JavaScriptCallFrame.idl
+++ b/Source/core/inspector/JavaScriptCallFrame.idl
@@ -48,6 +48,7 @@
     [CustomGetter] readonly attribute Array scopeChain;
     [Custom] unsigned short scopeType(long scopeIndex);
     [CustomGetter] readonly attribute Object thisObject;
+    readonly attribute DOMString stepInPositions;
     readonly attribute DOMString functionName;
     [CustomGetter] readonly attribute DOMString type;
 };
diff --git a/Source/core/inspector/PageDebuggerAgent.cpp b/Source/core/inspector/PageDebuggerAgent.cpp
index 72bd983..1bbb03a 100644
--- a/Source/core/inspector/PageDebuggerAgent.cpp
+++ b/Source/core/inspector/PageDebuggerAgent.cpp
@@ -33,9 +33,11 @@
 
 #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"
 
@@ -136,7 +138,10 @@
         return;
 
     reset();
-    scriptDebugServer().setScriptPreprocessor(m_pageAgent->scriptPreprocessor());
+
+    // ScriptController::clearWindowShell() clears its ScriptPreprocessor before didClearWindowObjectInWorld is dispatched.
+    if (!m_pageAgent->scriptPreprocessor().isEmpty())
+        frame->script()->setScriptPreprocessor(m_pageAgent->scriptPreprocessor());
 }
 
 } // namespace WebCore
diff --git a/Source/core/inspector/ScriptArguments.cpp b/Source/core/inspector/ScriptArguments.cpp
index 516cd04..3bcdd21 100644
--- a/Source/core/inspector/ScriptArguments.cpp
+++ b/Source/core/inspector/ScriptArguments.cpp
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "core/inspector/ScriptArguments.h"
 
+#include "bindings/v8/ScriptScope.h"
 #include "bindings/v8/ScriptValue.h"
 
 namespace WebCore {
@@ -67,6 +68,7 @@
         return false;
 
     const ScriptValue& value = argumentAt(0);
+    ScriptScope scope(m_scriptState.get());
     if (checkForNullOrUndefined && (value.isNull() || value.isUndefined()))
         return false;
 
diff --git a/Source/core/loader/DocumentLoader.cpp b/Source/core/loader/DocumentLoader.cpp
index 9d23704..c1e7f48 100644
--- a/Source/core/loader/DocumentLoader.cpp
+++ b/Source/core/loader/DocumentLoader.cpp
@@ -55,6 +55,9 @@
 #include "core/page/Page.h"
 #include "core/page/Settings.h"
 #include "core/platform/Logging.h"
+#include "core/plugins/PluginData.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebMimeRegistry.h"
 #include "weborigin/SchemeRegistry.h"
 #include "weborigin/SecurityPolicy.h"
 #include "wtf/Assertions.h"
@@ -96,6 +99,7 @@
     , m_committed(false)
     , m_isStopping(false)
     , m_isClientRedirect(false)
+    , m_replacesCurrentHistoryItem(false)
     , m_wasOnloadHandled(false)
     , m_loadingMainResource(false)
     , m_timeOfLastDataReceived(0.0)
@@ -204,11 +208,6 @@
 void DocumentLoader::mainReceivedError(const ResourceError& error)
 {
     ASSERT(!error.isNull());
-    if (m_identifierForLoadWithoutResourceLoader) {
-        ASSERT(!mainResourceLoader());
-        frameLoader()->client()->dispatchDidFailLoading(this, m_identifierForLoadWithoutResourceLoader, error);
-    }
-
     ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading());
 
     m_applicationCacheHost->failedLoadingMainResource();
@@ -263,20 +262,19 @@
         return;
 
     m_isStopping = true;
-
-    FrameLoader* frameLoader = DocumentLoader::frameLoader();
     
-    if (isLoadingMainResource())
+    if (isLoadingMainResource()) {
         // Stop the main resource loader and let it send the cancelled message.
-        cancelMainResourceLoad(frameLoader->cancelledError(m_request));
-    else if (!m_resourceLoaders.isEmpty())
+        cancelMainResourceLoad(ResourceError::cancelledError(m_request.url()));
+    } else if (!m_resourceLoaders.isEmpty()) {
         // The main resource loader already finished loading. Set the cancelled error on the 
         // document and let the resourceLoaders send individual cancelled messages below.
-        setMainDocumentError(frameLoader->cancelledError(m_request));
-    else
+        setMainDocumentError(ResourceError::cancelledError(m_request.url()));
+    } else {
         // If there are no resource loaders, we need to manufacture a cancelled message.
         // (A back/forward navigation has no resource loaders because its resources are cached.)
-        mainReceivedError(frameLoader->cancelledError(m_request));
+        mainReceivedError(ResourceError::cancelledError(m_request.url()));
+    }
     
     stopLoadingSubresources();
     
@@ -303,6 +301,9 @@
 {
     ASSERT_UNUSED(resource, m_mainResource == resource);
     ASSERT(m_mainResource);
+
+    RefPtr<DocumentLoader> protect(this);
+
     if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) {
         finishedLoading(m_mainResource->loadFinishTime());
         return;
@@ -430,11 +431,7 @@
         return true;
     if (policy == NavigationPolicyIgnore)
         return false;
-
-    ResourceRequest mutableRequest(request);
-    if (policy == NavigationPolicyDownload)
-        frameLoader()->setOriginalURLForDownloadRequest(mutableRequest);
-    frameLoader()->client()->loadURLExternally(mutableRequest, policy);
+    frameLoader()->client()->loadURLExternally(request, policy);
     return false;
 }
 
@@ -453,7 +450,7 @@
     ASSERT(!newRequest.isNull());
 
     if (!frameLoader()->checkIfFormActionAllowedByCSP(newRequest.url())) {
-        cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
+        cancelMainResourceLoad(ResourceError::cancelledError(newRequest.url()));
         return;
     }
 
@@ -464,7 +461,7 @@
         RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectResponse.url());
         if (!redirectingOrigin->canDisplay(newRequest.url())) {
             FrameLoader::reportLocalLoadFailed(m_frame, newRequest.url().string());
-            cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
+            cancelMainResourceLoad(ResourceError::cancelledError(newRequest.url()));
             return;
         }
         timing()->addRedirect(redirectResponse.url(), newRequest.url());
@@ -485,7 +482,7 @@
     Frame* top = m_frame->tree()->top();
     if (top) {
         if (!top->loader()->mixedContentChecker()->canDisplayInsecureContent(top->document()->securityOrigin(), newRequest.url())) {
-            cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
+            cancelMainResourceLoad(ResourceError::cancelledError(newRequest.url()));
             return;
         }
     }
@@ -501,6 +498,14 @@
         stopLoadingForPolicyChange();
 }
 
+static bool canShowMIMEType(const String& mimeType, Page* page)
+{
+    if (WebKit::Platform::current()->mimeRegistry()->supportsMIMEType(mimeType) == WebKit::WebMimeRegistry::IsSupported)
+        return true;
+    PluginData* pluginData = page->pluginData();
+    return !mimeType.isEmpty() && pluginData && pluginData->supportsMimeType(mimeType);
+}
+
 bool DocumentLoader::shouldContinueForResponse() const
 {
     if (m_substituteData.isValid())
@@ -519,7 +524,7 @@
         return false;
     }
 
-    if (!frameLoader()->client()->canShowMIMEType(m_response.mimeType()))
+    if (!canShowMIMEType(m_response.mimeType(), m_frame->page()))
         return false;
 
     // Prevent remote web archives from loading because they can claim to be from any domain and thus avoid cross-domain security checks.
@@ -559,7 +564,7 @@
 
             // The load event might have detached this frame. In that case, the load will already have been cancelled during detach.
             if (frameLoader())
-                cancelMainResourceLoad(frameLoader()->cancelledError(m_request));
+                cancelMainResourceLoad(ResourceError::cancelledError(m_request.url()));
             return;
         }
     }
@@ -590,7 +595,7 @@
             // keep trying to process data from their load
 
             if (hostedByObject)
-                cancelMainResourceLoad(frameLoader()->cancelledError(m_request));
+                cancelMainResourceLoad(ResourceError::cancelledError(m_request.url()));
         }
     }
 
@@ -602,14 +607,9 @@
     }
 }
 
-ResourceError DocumentLoader::interruptedForPolicyChangeError() const
-{
-    return frameLoader()->client()->interruptedForPolicyChangeError(request());
-}
-
 void DocumentLoader::stopLoadingForPolicyChange()
 {
-    ResourceError error = interruptedForPolicyChangeError();
+    ResourceError error = frameLoader()->client()->interruptedForPolicyChangeError(m_request);
     error.setIsCancellation(true);
     cancelMainResourceLoad(error);
 }
@@ -677,7 +677,7 @@
     // If we are sending data to MediaDocument, we should stop here
     // and cancel the request.
     if (m_frame->document()->isMediaDocument())
-        cancelMainResourceLoad(frameLoader()->cancelledError(m_request));
+        cancelMainResourceLoad(ResourceError::cancelledError(m_request.url()));
 }
 
 void DocumentLoader::checkLoadComplete()
@@ -687,7 +687,7 @@
     // FIXME: This ASSERT is always triggered.
     // See https://bugs.webkit.org/show_bug.cgi?id=110937
     // ASSERT(this == frameLoader()->activeDocumentLoader())
-    m_frame->document()->domWindow()->finishedLoading();
+    m_frame->domWindow()->finishedLoading();
 }
 
 void DocumentLoader::clearRedirectChain()
@@ -880,7 +880,7 @@
     // Multiple frames may be loading the same main resource simultaneously. If deferral state changes,
     // each frame's DocumentLoader will try to send a setDefersLoading() to the same underlying ResourceLoader. Ensure only
     // the "owning" DocumentLoader does so, as setDefersLoading() is not resilient to setting the same value repeatedly.
-    if (mainResourceLoader() && mainResourceLoader()->documentLoader() == this)
+    if (mainResourceLoader() && mainResourceLoader()->isLoadedBy(m_cachedResourceLoader.get()))
         mainResourceLoader()->setDefersLoading(defers);
 
     setAllDefersLoading(m_resourceLoaders, defers);
@@ -923,8 +923,7 @@
 
     if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingInitialEmptyDocument())
         m_request.setURL(blankURL());
-    String mimeType = shouldLoadEmpty ? "text/html" : frameLoader()->client()->generatedMIMETypeForURLScheme(m_request.url().protocol());
-    m_response = ResourceResponse(m_request.url(), mimeType, 0, String(), String());
+    m_response = ResourceResponse(m_request.url(), "text/html", 0, String(), String());
     finishedLoading(monotonicallyIncreasingTime());
     return true;
 }
@@ -988,7 +987,7 @@
 void DocumentLoader::cancelMainResourceLoad(const ResourceError& resourceError)
 {
     RefPtr<DocumentLoader> protect(this);
-    ResourceError error = resourceError.isNull() ? frameLoader()->cancelledError(m_request) : resourceError;
+    ResourceError error = resourceError.isNull() ? ResourceError::cancelledError(m_request.url()) : resourceError;
 
     m_dataLoadTimer.stop();
     if (mainResourceLoader())
diff --git a/Source/core/loader/DocumentLoader.h b/Source/core/loader/DocumentLoader.h
index de79abd..91a2b5f 100644
--- a/Source/core/loader/DocumentLoader.h
+++ b/Source/core/loader/DocumentLoader.h
@@ -117,6 +117,8 @@
         const ResourceError& mainDocumentError() const { return m_mainDocumentError; }
         bool isClientRedirect() const { return m_isClientRedirect; }
         void setIsClientRedirect(bool isClientRedirect) { m_isClientRedirect = isClientRedirect; }
+        bool replacesCurrentHistoryItem() const { return m_replacesCurrentHistoryItem; }
+        void setReplacesCurrentHistoryItem(bool replacesCurrentHistoryItem) { m_replacesCurrentHistoryItem = replacesCurrentHistoryItem; }
         void handledOnloadEvents();
         bool wasOnloadHandled() { return m_wasOnloadHandled; }
         bool isLoadingInAPISense() const;
@@ -211,7 +213,6 @@
 
         bool shouldContinueForResponse() const;
         void stopLoadingForPolicyChange();
-        ResourceError interruptedForPolicyChangeError() const;
 
         typedef Timer<DocumentLoader> DocumentLoaderTimer;
 
@@ -252,6 +253,7 @@
         bool m_committed;
         bool m_isStopping;
         bool m_isClientRedirect;
+        bool m_replacesCurrentHistoryItem;
 
         // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloadHandled are roughly the same
         // and should be merged.
diff --git a/Source/core/loader/EmptyClients.h b/Source/core/loader/EmptyClients.h
index b36f1fc..3fef241 100644
--- a/Source/core/loader/EmptyClients.h
+++ b/Source/core/loader/EmptyClients.h
@@ -193,7 +193,6 @@
     virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest&, const ResourceResponse&) OVERRIDE { }
     virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long, const ResourceResponse&) OVERRIDE { }
     virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long) OVERRIDE { }
-    virtual void dispatchDidFailLoading(DocumentLoader*, unsigned long, const ResourceError&) OVERRIDE { }
     virtual void dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int) OVERRIDE { }
 
     virtual void dispatchDidHandleOnloadEvents() OVERRIDE { }
@@ -212,8 +211,6 @@
 
     virtual NavigationPolicy decidePolicyForNavigation(const ResourceRequest&, NavigationType, NavigationPolicy, bool isRedirect) OVERRIDE;
 
-    virtual void dispatchUnableToImplementPolicy(const ResourceError&) OVERRIDE { }
-
     virtual void dispatchWillSendSubmitEvent(PassRefPtr<FormState>) OVERRIDE;
     virtual void dispatchWillSubmitForm(PassRefPtr<FormState>) OVERRIDE;
 
@@ -225,21 +222,8 @@
 
     virtual void didReceiveDocumentData(const char*, int) OVERRIDE { }
 
-    virtual ResourceError cancelledError(const ResourceRequest&) OVERRIDE { ResourceError error("", 0, "", ""); error.setIsCancellation(true); return error; }
-    virtual ResourceError cannotShowURLError(const ResourceRequest&) OVERRIDE { return ResourceError("", 0, "", ""); }
     virtual ResourceError interruptedForPolicyChangeError(const ResourceRequest&) OVERRIDE { return ResourceError("", 0, "", ""); }
 
-    virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&) OVERRIDE { return ResourceError("", 0, "", ""); }
-    virtual ResourceError fileDoesNotExistError(const ResourceResponse&) OVERRIDE { return ResourceError("", 0, "", ""); }
-    virtual ResourceError pluginWillHandleLoadError(const ResourceResponse&) OVERRIDE { return ResourceError("", 0, "", ""); }
-
-    virtual bool shouldFallBack(const ResourceError&) OVERRIDE { return false; }
-
-    virtual bool canShowMIMEType(const String&) const OVERRIDE { return false; }
-    virtual String generatedMIMETypeForURLScheme(const String&) const OVERRIDE { return ""; }
-
-    virtual void didFinishLoad() OVERRIDE { }
-
     virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&) OVERRIDE;
 
     virtual String userAgent(const KURL&) OVERRIDE { return ""; }
diff --git a/Source/core/loader/FrameLoader.cpp b/Source/core/loader/FrameLoader.cpp
index 859d9f9..0dcff7f 100644
--- a/Source/core/loader/FrameLoader.cpp
+++ b/Source/core/loader/FrameLoader.cpp
@@ -289,13 +289,13 @@
     if (unloadEventPolicy != UnloadEventPolicyNone) {
         if (m_frame->document()) {
             if (m_didCallImplicitClose && !m_wasUnloadEventEmitted) {
-                Node* currentFocusedNode = m_frame->document()->focusedNode();
-                if (currentFocusedNode && currentFocusedNode->hasTagName(inputTag))
-                    toHTMLInputElement(currentFocusedNode)->endEditing();
+                Element* currentFocusedElement = m_frame->document()->focusedElement();
+                if (currentFocusedElement && currentFocusedElement->hasTagName(inputTag))
+                    toHTMLInputElement(currentFocusedElement)->endEditing();
                 if (m_pageDismissalEventBeingDispatched == NoDismissal) {
                     if (unloadEventPolicy == UnloadEventPolicyUnloadAndPageHide) {
                         m_pageDismissalEventBeingDispatched = PageHideDismissal;
-                        m_frame->document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, false), m_frame->document());
+                        m_frame->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, false), m_frame->document());
                     }
                     RefPtr<Event> unloadEvent(Event::create(eventNames().unloadEvent, false, false));
                     // The DocumentLoader (and thus its DocumentLoadTiming) might get destroyed
@@ -307,10 +307,11 @@
                         DocumentLoadTiming* timing = documentLoader->timing();
                         ASSERT(timing->navigationStart());
                         timing->markUnloadEventStart();
-                        m_frame->document()->domWindow()->dispatchEvent(unloadEvent, m_frame->document());
+                        m_frame->domWindow()->dispatchEvent(unloadEvent, m_frame->document());
                         timing->markUnloadEventEnd();
-                    } else
-                        m_frame->document()->domWindow()->dispatchEvent(unloadEvent, m_frame->document());
+                    } else {
+                        m_frame->domWindow()->dispatchEvent(unloadEvent, m_frame->document());
+                    }
                 }
                 m_pageDismissalEventBeingDispatched = NoDismissal;
                 if (m_frame->document())
@@ -393,7 +394,7 @@
     // its frame is not in a consistent state for rendering, so avoid setJSStatusBarText
     // since it may cause clients to attempt to render the frame.
     if (!m_stateMachine.creatingInitialEmptyDocument()) {
-        DOMWindow* window = m_frame->document()->domWindow();
+        DOMWindow* window = m_frame->domWindow();
         window->setStatus(String());
         window->setDefaultStatus(String());
     }
@@ -442,7 +443,7 @@
     m_frame->document()->stopActiveDOMObjects();
     if (m_frame->document()->attached()) {
         m_frame->document()->prepareForDestruction();
-        m_frame->document()->removeFocusedNodeOfSubtree(m_frame->document());
+        m_frame->document()->removeFocusedElementOfSubtree(m_frame->document());
     }
 
     // Do this after detaching the document so that the unload event works.
@@ -530,7 +531,6 @@
     if (dispatch)
         dispatchDidClearWindowObjectsInAllWorlds();
 
-    updateFirstPartyForCookies();
     m_frame->document()->initContentSecurityPolicy();
 
     Settings* settings = m_frame->document()->settings();
@@ -712,24 +712,6 @@
     m_frame->document()->implicitClose();
 }
 
-void FrameLoader::loadURLIntoChildFrame(const ResourceRequest& request, Frame* childFrame)
-{
-    ASSERT(childFrame);
-
-    HistoryItem* parentItem = history()->currentItem();
-    // If we're moving in the back/forward list, we might want to replace the content
-    // of this child frame with whatever was there at that point.
-    if (parentItem && parentItem->children().size() && isBackForwardLoadType(loadType()) 
-        && !m_frame->document()->loadEventFinished()) {
-        HistoryItem* childItem = parentItem->childItemWithTarget(childFrame->tree()->uniqueName());
-        if (childItem) {
-            childFrame->loader()->loadDifferentDocumentItem(childItem);
-            return;
-        }
-    }
-    childFrame->loader()->loadURL(request, "_self", FrameLoadTypeInitialInChildFrame, 0, 0, childFrame->loader()->defaultSubstituteDataForURL(request.url()));
-}
-
 String FrameLoader::outgoingReferrer() const
 {
     // See http://www.whatwg.org/specs/web-apps/current-work/#fetching-resources
@@ -790,20 +772,6 @@
     m_submittedFormURL = KURL();
 }
 
-void FrameLoader::updateFirstPartyForCookies()
-{
-    if (m_frame->tree()->parent())
-        setFirstPartyForCookies(m_frame->tree()->parent()->document()->firstPartyForCookies());
-    else
-        setFirstPartyForCookies(m_frame->document()->url());
-}
-
-void FrameLoader::setFirstPartyForCookies(const KURL& url)
-{
-    for (Frame* frame = m_frame; frame; frame = frame->tree()->traverseNext(m_frame))
-        frame->document()->setFirstPartyForCookies(url);
-}
-
 // This does the same kind of work that didOpenURL does, except it relies on the fact
 // that a higher level already checked that the URLs match and the scrolling is the right thing to do.
 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScriptValue> stateObject, bool isNewNavigation)
@@ -864,7 +832,9 @@
         m_client->postProgressStartedNotification();
 
     m_documentLoader->clearRedirectChain();
-    if ((m_startingClientRedirect && !isNewNavigation) || !UserGestureIndicator::processingUserGesture()) {
+    m_documentLoader->setIsClientRedirect((m_startingClientRedirect && !isNewNavigation) || !UserGestureIndicator::processingUserGesture());
+    m_documentLoader->setReplacesCurrentHistoryItem(!isNewNavigation);
+    if (m_documentLoader->isClientRedirect()) {
         m_client->dispatchDidCompleteClientRedirect(oldURL);
         m_documentLoader->appendRedirect(oldURL);
     }
@@ -881,9 +851,6 @@
         m_frame->document()->enqueueHashchangeEvent(oldURL, url);
         m_client->dispatchDidChangeLocationWithinPage();
     }
-    
-    // FrameLoaderClient::didFinishLoad() tells the internal load delegate the load finished with no error
-    m_client->didFinishLoad();
 }
 
 bool FrameLoader::isComplete() const
@@ -922,97 +889,107 @@
         insertDummyHistoryItem();
 
         ASSERT(stateMachine()->isDisplayingInitialEmptyDocument());
+        stateMachine()->advanceTo(FrameLoaderStateMachine::StartedFirstRealLoad);
         stateMachine()->advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocumentPostCommit);
         stateMachine()->advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad);
     }
 }
 
+void FrameLoader::setReferrerForFrameRequest(ResourceRequest& request, ShouldSendReferrer shouldSendReferrer)
+{
+    if (shouldSendReferrer == NeverSendReferrer) {
+        request.clearHTTPReferrer();
+        return;
+    }
+
+    String argsReferrer(request.httpReferrer());
+    if (argsReferrer.isEmpty())
+        argsReferrer = outgoingReferrer();
+    String referrer = SecurityPolicy::generateReferrerHeader(m_frame->document()->referrerPolicy(), request.url(), argsReferrer);
+
+    request.setHTTPReferrer(referrer);
+    RefPtr<SecurityOrigin> referrerOrigin = SecurityOrigin::createFromString(referrer);
+    addHTTPOriginIfNeeded(request, referrerOrigin->toString());
+}
+
+FrameLoadType FrameLoader::determineFrameLoadType(const FrameLoadRequest& request)
+{
+    if (m_frame->tree()->parent() && !m_stateMachine.startedFirstRealLoad())
+        return FrameLoadTypeInitialInChildFrame;
+    if (request.resourceRequest().cachePolicy() == ReloadIgnoringCacheData)
+        return FrameLoadTypeReload;
+    if (request.lockBackForwardList())
+        return FrameLoadTypeRedirectWithLockedBackForwardList;
+    if (!request.requester() && shouldTreatURLAsSameAsCurrent(request.resourceRequest().url()))
+        return FrameLoadTypeSame;
+    if (shouldTreatURLAsSameAsCurrent(request.substituteData().failingURL()) && m_loadType == FrameLoadTypeReload)
+        return FrameLoadTypeReload;
+    return FrameLoadTypeStandard;
+}
+
+bool FrameLoader::prepareRequestForThisFrame(FrameLoadRequest& request)
+{
+    // If no SecurityOrigin was specified, skip security checks and assume the caller has fully initialized the FrameLoadRequest.
+    if (!request.requester())
+        return true;
+
+    KURL url = request.resourceRequest().url();
+    if (m_frame->script()->executeScriptIfJavaScriptURL(url))
+        return false;
+
+    if (!request.requester()->canDisplay(url)) {
+        reportLocalLoadFailed(m_frame, url.elidedString());
+        return false;
+    }
+
+    if (request.requester() && 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
+    // have already set the referrer.
+    if (request.requester() == m_frame->document()->securityOrigin())
+        setReferrerForFrameRequest(request.resourceRequest(), request.shouldSendReferrer());
+    return true;
+}
+
 void FrameLoader::load(const FrameLoadRequest& passedRequest)
 {
     ASSERT(!m_suppressOpenerInNewFrame);
+    ASSERT(m_frame->document());
 
     // Protect frame from getting blown away inside dispatchBeforeLoadEvent in loadWithDocumentLoader.
     RefPtr<Frame> protect(m_frame);
 
-    FrameLoadRequest request(passedRequest);
-    KURL url = request.resourceRequest().url();
-
-    if (m_frame->script()->executeScriptIfJavaScriptURL(url))
-        return;
-
-    ASSERT(m_frame->document());
-    // FIXME: There are a bunch of FrameLoaderRequest::requester() checks in this function, and it's messy.
-    if (request.requester() && !request.requester()->canDisplay(url)) {
-        reportLocalLoadFailed(m_frame, url.elidedString());
-        return;
-    }
-
-    ResourceRequest resourceRequest(request.resourceRequest());
-    String argsReferrer = resourceRequest.httpReferrer();
-    if (argsReferrer.isEmpty() && request.requester())
-        argsReferrer = outgoingReferrer();
-
-    String referrer = request.requester() ? SecurityPolicy::generateReferrerHeader(m_frame->document()->referrerPolicy(), url, argsReferrer) : argsReferrer;
-    if (request.shouldSendReferrer() == NeverSendReferrer)
-        referrer = String();
-
-    if (!referrer.isEmpty()) {
-        resourceRequest.setHTTPReferrer(referrer);
-        RefPtr<SecurityOrigin> referrerOrigin = SecurityOrigin::createFromString(referrer);
-        addHTTPOriginIfNeeded(resourceRequest, referrerOrigin->toString());
-    } else
-        resourceRequest.clearHTTPReferrer();
-
-    FrameLoadType loadType;
-    if (resourceRequest.cachePolicy() == ReloadIgnoringCacheData)
-        loadType = FrameLoadTypeReload;
-    else if (request.lockBackForwardList())
-        loadType = FrameLoadTypeRedirectWithLockedBackForwardList;
-    else if (!request.requester() && shouldTreatURLAsSameAsCurrent(resourceRequest.url()))
-        loadType = FrameLoadTypeSame;
-    else if (shouldTreatURLAsSameAsCurrent(request.substituteData().failingURL()) && m_loadType == FrameLoadTypeReload)
-        loadType = FrameLoadTypeReload;
-    else
-        loadType = FrameLoadTypeStandard;
-
-    if (request.requester() && request.frameName().isEmpty())
-        request.setFrameName(m_frame->document()->baseTarget());
-    TemporaryChange<bool> changeOpener(m_suppressOpenerInNewFrame, request.shouldSendReferrer() == NeverSendReferrer);
-    TemporaryChange<bool> changeClientRedirect(m_startingClientRedirect, request.clientRedirect());
-
-    loadURL(resourceRequest, request.frameName(), loadType, request.triggeringEvent(), request.formState(), request.substituteData());
-}
-
-void FrameLoader::loadURL(const ResourceRequest& request, const String& frameName, FrameLoadType newLoadType, PassRefPtr<Event> event, PassRefPtr<FormState> formState, const SubstituteData& substituteData)
-{
     if (m_inStopAllLoaders)
         return;
 
-    bool isFormSubmission = formState;
+    FrameLoadRequest request(passedRequest);
+    if (!prepareRequestForThisFrame(request))
+        return;
 
     // The search for a target frame is done earlier in the case of form submission.
-    Frame* targetFrame = isFormSubmission ? 0 : findFrameForNavigation(frameName);
+    Frame* targetFrame = request.formState() ? 0 : findFrameForNavigation(request.frameName());
     if (targetFrame && targetFrame != m_frame) {
-        targetFrame->loader()->loadURL(request, "_self", newLoadType, event, formState, substituteData);
+        request.setFrameName("_self");
+        targetFrame->loader()->load(request);
         return;
     }
 
-    if (m_pageDismissalEventBeingDispatched != NoDismissal)
-        return;
-
-    NavigationAction action(request, newLoadType, isFormSubmission, event);
-
-    if (!targetFrame && !frameName.isEmpty()) {
-        checkNewWindowPolicyAndContinue(formState, frameName, action);
+    FrameLoadType newLoadType = determineFrameLoadType(request);
+    NavigationAction action(request.resourceRequest(), newLoadType, request.formState(), request.triggeringEvent());
+    if (!targetFrame && !request.frameName().isEmpty()) {
+        TemporaryChange<bool> changeOpener(m_suppressOpenerInNewFrame, request.shouldSendReferrer() == NeverSendReferrer);
+        checkNewWindowPolicyAndContinue(request.formState(), request.frameName(), action);
         return;
     }
 
-    bool sameURL = shouldTreatURLAsSameAsCurrent(request.url());
-    loadWithNavigationAction(request, action, newLoadType, formState, substituteData.isValid() ? substituteData : defaultSubstituteDataForURL(request.url()));
+    TemporaryChange<bool> changeClientRedirect(m_startingClientRedirect, request.clientRedirect());
+    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
     // driving the generated content, or a master frame with links that drive a target
     // frame, where the user has clicked on the same link repeatedly.
-    if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoadTypeReloadFromOrigin && request.httpMethod() != "POST")
+    if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoadTypeReloadFromOrigin && request.resourceRequest().httpMethod() != "POST")
         m_loadType = FrameLoadTypeSame;
 }
 
@@ -1032,7 +1009,10 @@
     if (m_pageDismissalEventBeingDispatched != NoDismissal)
         return;
 
-    RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request, substituteData);
+    if (!m_stateMachine.startedFirstRealLoad())
+        m_stateMachine.advanceTo(FrameLoaderStateMachine::StartedFirstRealLoad);
+
+    RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request, substituteData.isValid() ? substituteData : defaultSubstituteDataForURL(request.url()));
     loader->setTriggeringAction(action);
 
     if (Frame* parent = m_frame->tree()->parent())
@@ -1042,8 +1022,8 @@
     else if (m_documentLoader)
         loader->setOverrideEncoding(m_documentLoader->overrideEncoding());
 
-    if (type == FrameLoadTypeRedirectWithLockedBackForwardList)
-        loader->setIsClientRedirect(true);
+    loader->setReplacesCurrentHistoryItem(type == FrameLoadTypeRedirectWithLockedBackForwardList);
+    loader->setIsClientRedirect(m_startingClientRedirect);
 
     bool isFormSubmission = formState;
 
@@ -1078,7 +1058,7 @@
     return error.isNull();
 }
 
-void FrameLoader::reload(bool endToEndReload, const KURL& overrideURL, const String& overrideEncoding)
+void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, const String& overrideEncoding)
 {
     DocumentLoader* documentLoader = activeDocumentLoader();
     if (!documentLoader)
@@ -1097,9 +1077,9 @@
     else if (!documentLoader->unreachableURL().isEmpty())
         request.setURL(documentLoader->unreachableURL());
 
-    FrameLoadType type = endToEndReload ? FrameLoadTypeReloadFromOrigin : FrameLoadTypeReload;
+    FrameLoadType type = reloadPolicy == EndToEndReload ? FrameLoadTypeReloadFromOrigin : FrameLoadTypeReload;
     NavigationAction action(request, type, request.httpMethod() == "POST");
-    loadWithNavigationAction(request, action, type, 0, defaultSubstituteDataForURL(request.url()), overrideEncoding);
+    loadWithNavigationAction(request, action, type, 0, SubstituteData(), overrideEncoding);
 }
 
 void FrameLoader::stopAllLoaders(ClearProvisionalItemPolicy clearProvisionalItemPolicy)
@@ -1523,60 +1503,6 @@
     ASSERT_NOT_REACHED();
 }
 
-static KURL originatingURLFromBackForwardList(Page* page)
-{
-    // FIXME: Can this logic be replaced with m_frame->document()->firstPartyForCookies()?
-    // It has the same meaning of "page a user thinks is the current one".
-
-    KURL originalURL;
-    int backCount = page->backForward()->backCount();
-    for (int backIndex = 0; backIndex <= backCount; backIndex++) {
-        // FIXME: At one point we had code here to check a "was user gesture" flag.
-        // Do we need to restore that logic?
-        HistoryItem* historyItem = page->backForward()->itemAtIndex(-backIndex);
-        if (!historyItem)
-            continue;
-
-        originalURL = historyItem->originalURL(); 
-        if (!originalURL.isNull()) 
-            return originalURL;
-    }
-
-    return KURL();
-}
-
-void FrameLoader::setOriginalURLForDownloadRequest(ResourceRequest& request)
-{
-    KURL originalURL;
-    
-    // If there is no referrer, assume that the download was initiated directly, so current document is
-    // completely unrelated to it. See <rdar://problem/5294691>.
-    // FIXME: Referrer is not sent in many other cases, so we will often miss this important information.
-    // Find a better way to decide whether the download was unrelated to current document.
-    if (!request.httpReferrer().isNull()) {
-        // find the first item in the history that was originated by the user
-        originalURL = originatingURLFromBackForwardList(m_frame->page());
-    }
-
-    if (originalURL.isNull())
-        originalURL = request.url();
-
-    if (!originalURL.protocol().isEmpty() && !originalURL.host().isEmpty()) {
-        unsigned port = originalURL.port();
-
-        // Original URL is needed to show the user where a file was downloaded from. We should make a URL that won't result in downloading the file again.
-        // FIXME: Using host-only URL is a very heavy-handed approach. We should attempt to provide the actual page where the download was initiated from, as a reminder to the user.
-        String hostOnlyURLString;
-        if (port)
-            hostOnlyURLString = originalURL.protocol() + "://" + originalURL.host() + ":" + String::number(port);
-        else
-            hostOnlyURLString = originalURL.protocol() + "://" + originalURL.host();
-
-        // FIXME: Rename firstPartyForCookies back to mainDocumentURL. It was a mistake to think that it was only used for cookies.
-        request.setFirstPartyForCookies(KURL(KURL(), hostOnlyURLString));
-    }
-}
-
 void FrameLoader::didLayout(LayoutMilestones milestones)
 {
     m_client->dispatchDidLayout(milestones);
@@ -1712,14 +1638,10 @@
 {
     bool isMainResource = (request.targetType() == ResourceRequest::TargetIsMainFrame) || (request.targetType() == ResourceRequest::TargetIsSubframe);
 
-    // Don't set the cookie policy URL if it's already been set.
-    // But make sure to set it on all requests regardless of protocol, as it has significance beyond the cookie policy (<rdar://problem/6616664>).
-    if (request.firstPartyForCookies().isEmpty()) {
-        if (isMainResource && isLoadingMainFrame())
-            request.setFirstPartyForCookies(request.url());
-        else if (Document* document = m_frame->document())
-            request.setFirstPartyForCookies(document->firstPartyForCookies());
-    }
+    if (isMainResource && isLoadingMainFrame())
+        request.setFirstPartyForCookies(request.url());
+    else
+        request.setFirstPartyForCookies(m_frame->document()->firstPartyForCookies());
 
     // The remaining modifications are only necessary for HTTP and HTTPS.
     if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily())
@@ -1782,9 +1704,6 @@
         initialRequest.setHTTPReferrer(referrer);
     addHTTPOriginIfNeeded(initialRequest, outgoingOrigin());
 
-    if (Page* page = m_frame->page())
-        initialRequest.setFirstPartyForCookies(page->mainFrame()->loader()->documentLoader()->request().url());
-
     addExtraFieldsToRequest(initialRequest);
 
     unsigned long identifier = 0;    
@@ -1815,7 +1734,11 @@
     // FIXME: Don't want to do this if an entirely new load is going, so should check
     // that both data sources on the frame are either this or nil.
     stop();
-    if (m_client->shouldFallBack(error))
+
+    // FIXME: We really ought to be able to just check for isCancellation() here, but there are some
+    // ResourceErrors that setIsCancellation() but aren't created by ResourceError::cancelledError().
+    ResourceError c(ResourceError::cancelledError(KURL()));
+    if (error.errorCode() != c.errorCode() || error.domain() != c.domain())
         handleFallbackContent();
 
     if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) {
@@ -1916,7 +1839,7 @@
 
 bool FrameLoader::fireBeforeUnloadEvent(Chrome& chrome)
 {
-    DOMWindow* domWindow = m_frame->document()->domWindow();
+    DOMWindow* domWindow = m_frame->domWindow();
     if (!domWindow)
         return true;
 
@@ -2006,11 +1929,11 @@
         m_client->dispatchWillSubmitForm(formState);
 
     m_progressTracker->progressStarted();
-    if (m_startingClientRedirect)
+    if (m_provisionalDocumentLoader->isClientRedirect())
         m_provisionalDocumentLoader->appendRedirect(m_frame->document()->url());
     m_provisionalDocumentLoader->appendRedirect(m_provisionalDocumentLoader->request().url());
     m_client->dispatchDidStartProvisionalLoad();
-    if (m_startingClientRedirect)
+    if (m_provisionalDocumentLoader->isClientRedirect())
         m_client->dispatchDidCompleteClientRedirect(m_frame->document()->url());
     ASSERT(m_provisionalDocumentLoader);
 
@@ -2024,6 +1947,9 @@
 
 void FrameLoader::checkNewWindowPolicyAndContinue(PassRefPtr<FormState> formState, const String& frameName, const NavigationAction& action)
 {
+    if (m_pageDismissalEventBeingDispatched != NoDismissal)
+        return;
+
     if (m_frame->document() && m_frame->document()->isSandboxed(SandboxPopups))
         return;
 
@@ -2064,7 +1990,7 @@
 
     // FIXME: We can't just send our NavigationAction to the new FrameLoader's loadWithNavigationAction(), we need to
     // create a new one with a default NavigationType and no triggering event. We should figure out why.
-    mainFrame->loader()->loadWithNavigationAction(action.resourceRequest(), NavigationAction(action.resourceRequest()), FrameLoadTypeStandard, formState, defaultSubstituteDataForURL(action.resourceRequest().url()));
+    mainFrame->loader()->loadWithNavigationAction(action.resourceRequest(), NavigationAction(action.resourceRequest()), FrameLoadTypeStandard, formState, SubstituteData());
 }
 
 void FrameLoader::requestFromDelegate(ResourceRequest& request, unsigned long& identifier, ResourceError& error)
@@ -2079,7 +2005,7 @@
     notifier()->dispatchWillSendRequest(m_documentLoader.get(), identifier, newRequest, ResourceResponse());
 
     if (newRequest.isNull())
-        error = cancelledError(request);
+        error = ResourceError::cancelledError(request.url());
     else
         error = ResourceError();
 
@@ -2249,11 +2175,10 @@
         addHTTPOriginIfNeeded(request, securityOrigin->toString());
     }
 
-    loadWithNavigationAction(request, NavigationAction(request, FrameLoadTypeBackForward, false), FrameLoadTypeBackForward, 0, defaultSubstituteDataForURL(request.url()));
+    loadWithNavigationAction(request, NavigationAction(request, FrameLoadTypeBackForward, false), FrameLoadTypeBackForward, 0, SubstituteData());
 }
 
-// Loads content into this frame, as specified by history item
-void FrameLoader::loadItem(HistoryItem* item)
+void FrameLoader::loadHistoryItem(HistoryItem* item)
 {
     m_requestedHistoryItem = item;
     HistoryItem* currentItem = history()->currentItem();
@@ -2272,13 +2197,6 @@
     frame()->page()->backForward()->setCurrentItem(currentItem.get());
 }
 
-ResourceError FrameLoader::cancelledError(const ResourceRequest& request) const
-{
-    ResourceError error = m_client->cancelledError(request);
-    error.setIsCancellation(true);
-    return error;
-}
-
 void FrameLoader::setTitle(const StringWithDirection& title)
 {
     documentLoader()->setTitle(title);
diff --git a/Source/core/loader/FrameLoader.h b/Source/core/loader/FrameLoader.h
index 68e4ce2..c832698 100644
--- a/Source/core/loader/FrameLoader.h
+++ b/Source/core/loader/FrameLoader.h
@@ -92,17 +92,15 @@
 
     void prepareForHistoryNavigation();
 
-    // FIXME: These are all functions which start loads. We have too many.
-    void loadURLIntoChildFrame(const ResourceRequest&, Frame*);
-    void load(const FrameLoadRequest&);
+    // These functions start a load. All eventually call into loadWithNavigationAction() or loadInSameDocument().
+    void load(const FrameLoadRequest&); // The entry point for non-reload, non-history loads.
+    void reload(ReloadPolicy = NormalReload, const KURL& overrideURL = KURL(), const String& overrideEncoding = String());
+    void loadHistoryItem(HistoryItem*); // The entry point for all back/forward loads
+    void submitForm(PassRefPtr<FormSubmission>); // Schedules a form submission, which will eventually call load() in the target frame.
 
+    // FIXME: This doesn't really belong here, since we don't load Frames synchronously.
     unsigned long loadResourceSynchronously(const ResourceRequest&, StoredCredentials, ResourceError&, ResourceResponse&, Vector<char>& data);
 
-    void submitForm(PassRefPtr<FormSubmission>);
-
-    void reload(bool endToEndReload = false, const KURL& overrideURL = KURL(), const String& overrideEncoding = String());
-
-    void loadItem(HistoryItem*);
     HistoryItem* requestedHistoryItem() const { return m_requestedHistoryItem.get(); }
 
     static void reportLocalLoadFailed(Frame*, const String& url);
@@ -143,8 +141,6 @@
 
     void handleFallbackContent();
 
-    ResourceError cancelledError(const ResourceRequest&) const;
-
     bool isHostedByObjectElement() const;
     bool isLoadingMainFrame() const;
 
@@ -231,8 +227,6 @@
     void completed();
     bool allAncestorsAreComplete() const; // including this
 
-    void setOriginalURLForDownloadRequest(ResourceRequest&);
-
     bool suppressOpenerInNewFrame() const { return m_suppressOpenerInNewFrame; }
 
     bool shouldClose();
@@ -255,9 +249,10 @@
     void loadSameDocumentItem(HistoryItem*);
     void loadDifferentDocumentItem(HistoryItem*);
     void insertDummyHistoryItem();
-    
-    void updateFirstPartyForCookies();
-    void setFirstPartyForCookies(const KURL&);
+
+    bool prepareRequestForThisFrame(FrameLoadRequest&);
+    void setReferrerForFrameRequest(ResourceRequest&, ShouldSendReferrer);
+    FrameLoadType determineFrameLoadType(const FrameLoadRequest&);
 
     void clearProvisionalLoad();
     void transitionToCommitted();
@@ -290,8 +285,6 @@
     void loadWithNavigationAction(const ResourceRequest&, const NavigationAction&,
         FrameLoadType, PassRefPtr<FormState>, const SubstituteData&, const String& overrideEncoding = String());
 
-    // Called by load, calls loadWithNavigationAction or checkNewWindowPolicyAndContinue
-    void loadURL(const ResourceRequest&, const String& frameName, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>, const SubstituteData&);
 
     bool shouldReload(const KURL& currentURL, const KURL& destinationURL);
 
diff --git a/Source/core/loader/FrameLoaderClient.h b/Source/core/loader/FrameLoaderClient.h
index f68ce39..b323744 100644
--- a/Source/core/loader/FrameLoaderClient.h
+++ b/Source/core/loader/FrameLoaderClient.h
@@ -97,7 +97,6 @@
         virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse) = 0;
         virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&) = 0;
         virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier) = 0;
-        virtual void dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&) = 0;
         virtual void dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length) = 0;
 
         virtual void dispatchDidHandleOnloadEvents() = 0;
@@ -119,8 +118,6 @@
 
         virtual NavigationPolicy decidePolicyForNavigation(const ResourceRequest&, NavigationType, NavigationPolicy, bool isRedirect) = 0;
 
-        virtual void dispatchUnableToImplementPolicy(const ResourceError&) = 0;
-
         virtual void dispatchWillRequestResource(CachedResourceRequest*) { }
 
         virtual void dispatchWillSendSubmitEvent(PassRefPtr<FormState>) = 0;
@@ -158,21 +155,8 @@
         virtual void didRunInsecureContent(SecurityOrigin*, const KURL&) = 0;
         virtual void didDetectXSS(const KURL&, bool didBlockEntirePage) = 0;
 
-        virtual ResourceError cancelledError(const ResourceRequest&) = 0;
-        virtual ResourceError cannotShowURLError(const ResourceRequest&) = 0;
         virtual ResourceError interruptedForPolicyChangeError(const ResourceRequest&) = 0;
 
-        virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&) = 0;
-        virtual ResourceError fileDoesNotExistError(const ResourceResponse&) = 0;
-        virtual ResourceError pluginWillHandleLoadError(const ResourceResponse&) = 0;
-
-        virtual bool shouldFallBack(const ResourceError&) = 0;
-
-        virtual bool canShowMIMEType(const String& MIMEType) const = 0;
-        virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const = 0;
-
-        virtual void didFinishLoad() = 0;
-
         virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&) = 0;
 
         virtual String userAgent(const KURL&) = 0;
diff --git a/Source/core/loader/FrameLoaderStateMachine.cpp b/Source/core/loader/FrameLoaderStateMachine.cpp
index 425f912..ed96e0a 100644
--- a/Source/core/loader/FrameLoaderStateMachine.cpp
+++ b/Source/core/loader/FrameLoaderStateMachine.cpp
@@ -39,6 +39,11 @@
 { 
 }
 
+bool FrameLoaderStateMachine::startedFirstRealLoad() const
+{
+    return m_state >= StartedFirstRealLoad;
+}
+
 bool FrameLoaderStateMachine::committedFirstRealDocumentLoad() const 
 {
     return m_state >= DisplayingInitialEmptyDocumentPostCommit;
@@ -51,7 +56,7 @@
 
 bool FrameLoaderStateMachine::isDisplayingInitialEmptyDocument() const 
 {
-    return m_state == DisplayingInitialEmptyDocument || m_state == DisplayingInitialEmptyDocumentPostCommit;
+    return m_state >= DisplayingInitialEmptyDocument && m_state <= DisplayingInitialEmptyDocumentPostCommit;
 }
 
 void FrameLoaderStateMachine::advanceTo(State state)
diff --git a/Source/core/loader/FrameLoaderStateMachine.h b/Source/core/loader/FrameLoaderStateMachine.h
index c9c6cc8..9d9fc81 100644
--- a/Source/core/loader/FrameLoaderStateMachine.h
+++ b/Source/core/loader/FrameLoaderStateMachine.h
@@ -46,10 +46,12 @@
     enum State {
         CreatingInitialEmptyDocument,
         DisplayingInitialEmptyDocument,
+        StartedFirstRealLoad,
         DisplayingInitialEmptyDocumentPostCommit,
         CommittedFirstRealLoad
     };
 
+    bool startedFirstRealLoad() const;
     bool committedFirstRealDocumentLoad() const;
     bool creatingInitialEmptyDocument() const;
     bool isDisplayingInitialEmptyDocument() const;
diff --git a/Source/core/loader/FrameLoaderTypes.h b/Source/core/loader/FrameLoaderTypes.h
index 75cf7ad..08783b0 100644
--- a/Source/core/loader/FrameLoaderTypes.h
+++ b/Source/core/loader/FrameLoaderTypes.h
@@ -89,6 +89,11 @@
         NotAboutToInstantiatePlugin
     };
 
+    enum ReloadPolicy {
+        NormalReload,
+        EndToEndReload
+    };
+
 }
 
 #endif
diff --git a/Source/core/loader/HistoryController.cpp b/Source/core/loader/HistoryController.cpp
index 621d739..c151199 100644
--- a/Source/core/loader/HistoryController.cpp
+++ b/Source/core/loader/HistoryController.cpp
@@ -650,7 +650,7 @@
             childFrame->loader()->history()->recursiveGoToItem(childItems[i].get(), fromChildItem);
         }
     } else {
-        m_frame->loader()->loadItem(item);
+        m_frame->loader()->loadHistoryItem(item);
     }
 }
 
diff --git a/Source/core/loader/HistoryController.h b/Source/core/loader/HistoryController.h
index de855f8..8b0a319 100644
--- a/Source/core/loader/HistoryController.h
+++ b/Source/core/loader/HistoryController.h
@@ -30,6 +30,7 @@
 #ifndef HistoryController_h
 #define HistoryController_h
 
+#include "core/history/HistoryItem.h"
 #include "core/loader/FrameLoaderTypes.h"
 #include "wtf/Noncopyable.h"
 #include "wtf/RefPtr.h"
@@ -38,7 +39,6 @@
 namespace WebCore {
 
 class Frame;
-class HistoryItem;
 class SerializedScriptValue;
 class StringWithDirection;
 
diff --git a/Source/core/loader/IconController.cpp b/Source/core/loader/IconController.cpp
index e687668..b112bc4 100644
--- a/Source/core/loader/IconController.cpp
+++ b/Source/core/loader/IconController.cpp
@@ -79,18 +79,8 @@
         iconURLs.append(defaultURL(Favicon));
 
 #if ENABLE(TOUCH_ICON_LOADING)
-    int missedIcons = 0;
-    if (iconTypesMask & TouchPrecomposedIcon)
-        missedIcons += appendToIconURLs(TouchPrecomposedIcon, &iconURLs) ? 0:1;
-
-    if (iconTypesMask & TouchIcon)
-      missedIcons += appendToIconURLs(TouchIcon, &iconURLs) ? 0:1;
-
-    // Only return the default touch icons when the both were required and neither was gotten.
-    if (missedIcons == 2) {
-        iconURLs.append(defaultURL(TouchPrecomposedIcon));
-        iconURLs.append(defaultURL(TouchIcon));
-    }
+    appendToIconURLs(TouchPrecomposedIcon, &iconURLs);
+    appendToIconURLs(TouchIcon, &iconURLs);
 #endif
 
     // Finally, append all remaining icons of this type.
@@ -137,16 +127,6 @@
         url.setPath("/favicon.ico");
         return IconURL::defaultIconURL(url, Favicon);
     }
-#if ENABLE(TOUCH_ICON_LOADING)
-    if (iconType == TouchPrecomposedIcon) {
-        url.setPath("/apple-touch-icon-precomposed.png");
-        return IconURL::defaultIconURL(url, TouchPrecomposedIcon);
-    }
-    if (iconType == TouchIcon) {
-        url.setPath("/apple-touch-icon.png");
-        return IconURL::defaultIconURL(url, TouchIcon);
-    }
-#endif
     return IconURL();
 }
 
diff --git a/Source/core/loader/ResourceLoadNotifier.cpp b/Source/core/loader/ResourceLoadNotifier.cpp
index a28d931..7bfd2cb 100644
--- a/Source/core/loader/ResourceLoadNotifier.cpp
+++ b/Source/core/loader/ResourceLoadNotifier.cpp
@@ -83,10 +83,6 @@
 {
     if (Page* page = m_frame->page())
         page->progress()->completeProgress(identifier);
-
-    if (!error.isNull())
-        m_frame->loader()->client()->dispatchDidFailLoading(loader, identifier, error);
-
     InspectorInstrumentation::didFailLoading(m_frame, identifier, loader, error);
 }
 
diff --git a/Source/core/loader/ResourceLoader.cpp b/Source/core/loader/ResourceLoader.cpp
index 62aef07..967dc75 100644
--- a/Source/core/loader/ResourceLoader.cpp
+++ b/Source/core/loader/ResourceLoader.cpp
@@ -31,12 +31,7 @@
 #include "core/loader/ResourceLoader.h"
 
 #include "core/inspector/InspectorInstrumentation.h"
-#include "core/loader/DocumentLoader.h"
-#include "core/loader/FrameLoader.h"
-#include "core/loader/FrameLoaderClient.h"
-#include "core/loader/appcache/ApplicationCacheHost.h"
-#include "core/loader/cache/CachedResourceLoader.h"
-#include "core/page/Frame.h"
+#include "core/loader/ResourceLoaderHost.h"
 #include "core/page/Page.h"
 #include "core/platform/Logging.h"
 #include "core/platform/network/ResourceError.h"
@@ -44,37 +39,36 @@
 
 namespace WebCore {
 
-ResourceLoader::RequestCountTracker::RequestCountTracker(CachedResourceLoader* cachedResourceLoader, CachedResource* resource)
-    : m_cachedResourceLoader(cachedResourceLoader)
+ResourceLoader::RequestCountTracker::RequestCountTracker(ResourceLoaderHost* host, CachedResource* resource)
+    : m_host(host)
     , m_resource(resource)
 {
-    m_cachedResourceLoader->incrementRequestCount(m_resource);
+    m_host->incrementRequestCount(m_resource);
 }
 
 ResourceLoader::RequestCountTracker::~RequestCountTracker()
 {
-    m_cachedResourceLoader->decrementRequestCount(m_resource);
+    m_host->decrementRequestCount(m_resource);
 }
 
-PassRefPtr<ResourceLoader> ResourceLoader::create(DocumentLoader* documentLoader, CachedResource* resource, const ResourceRequest& request, const ResourceLoaderOptions& options)
+PassRefPtr<ResourceLoader> ResourceLoader::create(ResourceLoaderHost* host, CachedResource* resource, const ResourceRequest& request, const ResourceLoaderOptions& options)
 {
-    RefPtr<ResourceLoader> loader(adoptRef(new ResourceLoader(documentLoader, resource, options)));
+    RefPtr<ResourceLoader> loader(adoptRef(new ResourceLoader(host, resource, options)));
     if (!loader->init(request))
         return 0;
     loader->start();
     return loader.release();
 }
 
-ResourceLoader::ResourceLoader(DocumentLoader* documentLoader, CachedResource* resource, ResourceLoaderOptions options)
-    : m_frame(documentLoader->frame())
-    , m_documentLoader(documentLoader)
+ResourceLoader::ResourceLoader(ResourceLoaderHost* host, CachedResource* resource, const ResourceLoaderOptions& options)
+    : m_host(host)
     , m_loadingMultipartContent(false)
     , m_notifiedLoadComplete(false)
-    , m_defersLoading(m_frame->page()->defersLoading())
+    , m_defersLoading(host->defersLoading())
     , m_options(options)
     , m_resource(resource)
     , m_state(Uninitialized)
-    , m_requestCountTracker(adoptPtr(new RequestCountTracker(documentLoader->cachedResourceLoader(), resource)))
+    , m_requestCountTracker(adoptPtr(new RequestCountTracker(host, resource)))
 {
 }
 
@@ -88,11 +82,11 @@
     ASSERT(m_state != Terminated);
     if (m_state != Uninitialized) {
         m_requestCountTracker.clear();
-        m_documentLoader->cachedResourceLoader()->loadDone(m_resource);
+        m_host->didLoadResource(m_resource);
         if (m_state == Terminated)
             return;
         m_resource->clearLoader();
-        m_documentLoader->removeResourceLoader(this);
+        m_host->willTerminateResourceLoader(this);
     }
 
     ASSERT(m_state != Terminated);
@@ -103,9 +97,7 @@
     // has been deallocated and also to avoid reentering this method.
     RefPtr<ResourceLoader> protector(this);
 
-    m_frame = 0;
-    m_documentLoader = 0;
-
+    m_host.clear();
     m_state = Terminated;
 
     if (m_handle) {
@@ -136,7 +128,7 @@
 
     m_originalRequest = m_request = clientRequest;
     m_state = Initialized;
-    m_documentLoader->addResourceLoader(this);
+    m_host->didInitializeResourceLoader(this);
     return true;
 }
 
@@ -146,7 +138,7 @@
     ASSERT(!m_request.isNull());
     ASSERT(m_deferredRequest.isNull());
 
-    m_documentLoader->applicationCacheHost()->willStartLoadingResource(m_request);
+    m_host->willStartLoadingResource(m_request);
 
     if (m_defersLoading) {
         m_deferredRequest = m_request;
@@ -169,13 +161,6 @@
     }
 }
 
-FrameLoader* ResourceLoader::frameLoader() const
-{
-    if (!m_frame)
-        return 0;
-    return m_frame->loader();
-}
-
 void ResourceLoader::didDownloadData(ResourceHandle*, int length)
 {
     RefPtr<ResourceLoader> protect(this);
@@ -192,14 +177,13 @@
     if (m_notifiedLoadComplete)
         return;
     m_notifiedLoadComplete = true;
-    if (m_options.sendLoadCallbacks == SendCallbacks)
-        frameLoader()->notifier()->dispatchDidFinishLoading(m_documentLoader.get(), m_resource->identifier(), finishTime);
+    m_host->didFinishLoading(m_resource, finishTime, m_options);
 }
 
 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority)
 {
     if (handle()) {
-        frameLoader()->client()->dispatchDidChangeResourcePriority(m_resource->identifier(), loadPriority);
+        m_host->didChangeLoadingPriority(m_resource, loadPriority);
         handle()->didChangePriority(loadPriority);
     }
 }
@@ -226,7 +210,7 @@
         return;
     }
 
-    ResourceError nonNullError = error.isNull() ? cancelledError() : error;
+    ResourceError nonNullError = error.isNull() ? ResourceError::cancelledError(m_request.url()) : error;
 
     // This function calls out to clients at several points that might do
     // something that causes the last reference to this object to go away.
@@ -242,8 +226,7 @@
         m_handle = 0;
     }
 
-    if (m_options.sendLoadCallbacks == SendCallbacks && !m_notifiedLoadComplete)
-        frameLoader()->notifier()->dispatchDidFail(m_documentLoader.get(), m_resource->identifier(), nonNullError);
+    m_host->didFailLoading(m_resource, nonNullError, m_options);
 
     if (m_state == Finishing)
         m_resource->error(CachedResource::LoadError);
@@ -251,16 +234,6 @@
         releaseResources();
 }
 
-ResourceError ResourceLoader::cancelledError()
-{
-    return frameLoader()->cancelledError(m_request);
-}
-
-ResourceError ResourceLoader::cannotShowURLError()
-{
-    return frameLoader()->client()->cannotShowURLError(m_request);
-}
-
 void ResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse)
 {
     // Store the previous URL because we may modify it.
@@ -269,25 +242,18 @@
 
     ASSERT(!request.isNull());
     if (!redirectResponse.isNull()) {
-        if (!m_documentLoader->cachedResourceLoader()->canRequest(m_resource->type(), request.url(), m_options)) {
+        if (!m_host->shouldRequest(m_resource, request, m_options)) {
             cancel();
             return;
         }
-        if (m_resource->type() == CachedResource::ImageResource && m_documentLoader->cachedResourceLoader()->shouldDeferImageLoad(request.url())) {
-            cancel();
-            return;
-        }
+
         m_resource->willSendRequest(request, redirectResponse);
     }
 
     if (request.isNull() || m_state == Terminated)
         return;
 
-    if (m_options.sendLoadCallbacks == SendCallbacks)
-        frameLoader()->notifier()->dispatchWillSendRequest(m_documentLoader.get(), m_resource->identifier(), request, redirectResponse, m_options.initiatorInfo);
-    else
-        InspectorInstrumentation::willSendRequest(m_frame.get(), m_resource->identifier(), m_documentLoader.get(), request, redirectResponse, m_options.initiatorInfo);
-
+    m_host->willSendRequest(m_resource, request, redirectResponse, m_options);
     m_request = request;
 
     if (request.isNull())
@@ -319,8 +285,7 @@
     if (m_state == Terminated)
         return;
 
-    if (m_options.sendLoadCallbacks == SendCallbacks)
-        frameLoader()->notifier()->dispatchDidReceiveResponse(m_documentLoader.get(), m_resource->identifier(), response);
+    m_host->didReceiveResponse(m_resource, response, m_options);
 
     if (response.isMultipart()) {
         m_loadingMultipartContent = true;
@@ -334,7 +299,7 @@
     } else if (m_loadingMultipartContent) {
         // 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_documentLoader->subresourceLoaderFinishedLoadingOnePart(this);
+        m_host->subresourceLoaderFinishedLoadingOnePart(this);
         didFinishLoadingOnePart(0);
     }
 
@@ -351,7 +316,7 @@
     // loop. When this occurs, ignoring the data is the correct action.
     if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgnoreHTTPStatusCodeErrors())
         return;
-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceData(m_frame.get(), m_resource->identifier(), encodedDataLength);
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceData(m_host->inspectedFrame(), m_resource->identifier(), encodedDataLength);
     ASSERT(m_state == Initialized);
 
     // Reference the object in this method since the additional processing can do
@@ -361,9 +326,7 @@
     // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
     // However, with today's computers and networking speeds, this won't happen in practice.
     // Could be an issue with a giant local file.
-    if (m_options.sendLoadCallbacks == SendCallbacks && m_frame)
-        frameLoader()->notifier()->dispatchDidReceiveData(m_documentLoader.get(), m_resource->identifier(), data, length, static_cast<int>(encodedDataLength));
-
+    m_host->didReceiveData(m_resource, data, length, encodedDataLength, m_options);
     m_resource->appendData(data, length);
 
     InspectorInstrumentation::didReceiveResourceData(cookie);
@@ -395,6 +358,7 @@
     LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string().latin1().data());
 
     RefPtr<ResourceLoader> protect(this);
+    RefPtr<ResourceLoaderHost> protectHost(m_host);
     CachedResourceHandle<CachedResource> protectResource(m_resource);
     m_state = Finishing;
     m_resource->setResourceError(error);
@@ -405,11 +369,15 @@
 
     if (!m_notifiedLoadComplete) {
         m_notifiedLoadComplete = true;
-        if (m_options.sendLoadCallbacks == SendCallbacks)
-            frameLoader()->notifier()->dispatchDidFail(m_documentLoader.get(), m_resource->identifier(), error);
+        m_host->didFailLoading(m_resource, error, m_options);
     }
 
     releaseResources();
 }
 
+bool ResourceLoader::isLoadedBy(ResourceLoaderHost* loader) const
+{
+    return m_host->isLoadedBy(loader);
+}
+
 }
diff --git a/Source/core/loader/ResourceLoader.h b/Source/core/loader/ResourceLoader.h
index f0052c7..fb2c106 100644
--- a/Source/core/loader/ResourceLoader.h
+++ b/Source/core/loader/ResourceLoader.h
@@ -40,30 +40,25 @@
 namespace WebCore {
 
 class CachedResource;
-class CachedResourceLoader;
 class DocumentLoader;
 class Frame;
 class FrameLoader;
 class KURL;
 class ResourceBuffer;
 class ResourceHandle;
+class ResourceLoaderHost;
 
 class ResourceLoader : public RefCounted<ResourceLoader>, protected ResourceHandleClient {
 public:
-    static PassRefPtr<ResourceLoader> create(DocumentLoader*, CachedResource*, const ResourceRequest&, const ResourceLoaderOptions&);
+    static PassRefPtr<ResourceLoader> create(ResourceLoaderHost*, CachedResource*, const ResourceRequest&, const ResourceLoaderOptions&);
     virtual ~ResourceLoader();
 
     void cancel();
     void cancel(const ResourceError&);
     void cancelIfNotFinishing();
 
-    FrameLoader* frameLoader() const;
-    DocumentLoader* documentLoader() const { return m_documentLoader.get(); }
     CachedResource* cachedResource() { return m_resource; }
     const ResourceRequest& originalRequest() const { return m_originalRequest; }
-
-    ResourceError cancelledError();
-    ResourceError cannotShowURLError();
     
     void setDefersLoading(bool);
     bool defersLoading() const { return m_defersLoading; }
@@ -86,13 +81,13 @@
     ResourceHandle* handle() const { return m_handle.get(); }
     bool shouldSendResourceLoadCallbacks() const { return m_options.sendLoadCallbacks == SendCallbacks; }
     bool shouldSniffContent() const { return m_options.sniffContent == SniffContent; }
+    bool isLoadedBy(ResourceLoaderHost*) const;
 
     bool reachedTerminalState() const { return m_state == Terminated; }
-
     const ResourceRequest& request() const { return m_request; }
 
 private:
-    ResourceLoader(DocumentLoader*, CachedResource*, ResourceLoaderOptions);
+    ResourceLoader(ResourceLoaderHost*, CachedResource*, const ResourceLoaderOptions&);
 
     bool init(const ResourceRequest&);
     void start();
@@ -100,8 +95,7 @@
     void didFinishLoadingOnePart(double finishTime);
 
     RefPtr<ResourceHandle> m_handle;
-    RefPtr<Frame> m_frame;
-    RefPtr<DocumentLoader> m_documentLoader;
+    RefPtr<ResourceLoaderHost> m_host;
 
     ResourceRequest m_request;
     ResourceRequest m_originalRequest; // Before redirects.
@@ -122,10 +116,10 @@
 
     class RequestCountTracker {
     public:
-        RequestCountTracker(CachedResourceLoader*, CachedResource*);
+        RequestCountTracker(ResourceLoaderHost*, CachedResource*);
         ~RequestCountTracker();
     private:
-        CachedResourceLoader* m_cachedResourceLoader;
+        ResourceLoaderHost* m_host;
         CachedResource* m_resource;
     };
 
diff --git a/Source/core/loader/ResourceLoaderHost.h b/Source/core/loader/ResourceLoaderHost.h
new file mode 100644
index 0000000..5bda7dd
--- /dev/null
+++ b/Source/core/loader/ResourceLoaderHost.h
@@ -0,0 +1,83 @@
+/*
+ * 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:
+ *
+ *     * 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 ResourceLoaderHost_h
+#define ResourceLoaderHost_h
+
+#include "core/platform/network/ResourceError.h"
+#include "core/platform/network/ResourceLoadPriority.h"
+
+namespace WebCore {
+
+class CachedResource;
+class CachedResourceLoader;
+class Frame;
+class ResourceLoader;
+class ResourceRequest;
+class ResourceResponse;
+
+struct CachedResourceInitiatorInfo;
+struct ResourceLoaderOptions;
+
+class ResourceLoaderHost {
+public:
+    void ref() { refResourceLoaderHost(); }
+    void deref() { derefResourceLoaderHost(); }
+
+    virtual void incrementRequestCount(const CachedResource*) = 0;
+    virtual void decrementRequestCount(const CachedResource*) = 0;
+    virtual void didLoadResource(CachedResource*) = 0;
+
+    virtual void didFinishLoading(const CachedResource*, double finishTime, const ResourceLoaderOptions&) = 0;
+    virtual void didChangeLoadingPriority(const CachedResource*, ResourceLoadPriority) = 0;
+    virtual void didFailLoading(const CachedResource*, const ResourceError&, const ResourceLoaderOptions&) = 0;
+
+    virtual void willSendRequest(const CachedResource*, ResourceRequest&, const ResourceResponse& redirectResponse, const ResourceLoaderOptions&) = 0;
+    virtual void didReceiveResponse(const CachedResource*, const ResourceResponse&, const ResourceLoaderOptions&) = 0;
+    virtual void didReceiveData(const CachedResource*, const char* data, int dataLength, int encodedDataLength, const ResourceLoaderOptions&) = 0;
+
+    virtual void subresourceLoaderFinishedLoadingOnePart(ResourceLoader*) = 0;
+    virtual void didInitializeResourceLoader(ResourceLoader*) = 0;
+    virtual void willTerminateResourceLoader(ResourceLoader*) = 0;
+    virtual void willStartLoadingResource(ResourceRequest&) = 0;
+
+    virtual bool shouldRequest(CachedResource*, const ResourceRequest&, const ResourceLoaderOptions&) = 0;
+    virtual bool defersLoading() const = 0;
+    virtual bool isLoadedBy(ResourceLoaderHost*) const = 0;
+
+    virtual void refResourceLoaderHost() = 0;
+    virtual void derefResourceLoaderHost() = 0;
+
+    virtual Frame* inspectedFrame() const = 0;
+};
+
+}
+
+#endif // ResourceLoaderHost_h
diff --git a/Source/core/loader/cache/CachedImageTest.cpp b/Source/core/loader/cache/CachedImageTest.cpp
index 8781434..ad9b63e 100644
--- a/Source/core/loader/cache/CachedImageTest.cpp
+++ b/Source/core/loader/cache/CachedImageTest.cpp
@@ -147,7 +147,7 @@
     response.initialize();
     response.setMIMEType("text/html");
     WTF::String localPath = WebKit::Platform::current()->unitTestSupport()->webKitRootDir();
-    localPath.append("/Source/WebKit/chromium/tests/data/cancelTest.html");
+    localPath.append("/Source/web/tests/data/cancelTest.html");
     WebKit::Platform::current()->unitTestSupport()->registerMockedURL(testURL, response, localPath);
 
     // Create enough of a mocked world to get a functioning ResourceLoader.
diff --git a/Source/core/loader/cache/CachedResource.cpp b/Source/core/loader/cache/CachedResource.cpp
index ef7be11..3a070be 100644
--- a/Source/core/loader/cache/CachedResource.cpp
+++ b/Source/core/loader/cache/CachedResource.cpp
@@ -181,7 +181,7 @@
         m_fragmentIdentifierForRequest = String();
     }
 
-    m_loader = ResourceLoader::create(cachedResourceLoader->documentLoader(), this, request, options);
+    m_loader = ResourceLoader::create(cachedResourceLoader, this, request, options);
     if (!m_loader) {
         failBeforeStarting();
         return;
diff --git a/Source/core/loader/cache/CachedResourceLoader.cpp b/Source/core/loader/cache/CachedResourceLoader.cpp
index 87d41d3..2dd3289 100644
--- a/Source/core/loader/cache/CachedResourceLoader.cpp
+++ b/Source/core/loader/cache/CachedResourceLoader.cpp
@@ -31,11 +31,13 @@
 #include "core/dom/Document.h"
 #include "core/html/HTMLElement.h"
 #include "core/html/HTMLFrameOwnerElement.h"
+#include "core/inspector/InspectorInstrumentation.h"
 #include "core/loader/DocumentLoader.h"
 #include "core/loader/FrameLoader.h"
 #include "core/loader/FrameLoaderClient.h"
 #include "core/loader/PingLoader.h"
 #include "core/loader/UniqueIdentifier.h"
+#include "core/loader/appcache/ApplicationCacheHost.h"
 #include "core/loader/cache/CachedCSSStyleSheet.h"
 #include "core/loader/cache/CachedDocument.h"
 #include "core/loader/cache/CachedFont.h"
@@ -500,7 +502,7 @@
         if (!frame())
             return 0;
 
-        FrameLoader* frameLoader = frame()->loader();
+        FrameLoader* frameLoader = this->frameLoader();
         if (request.options().securityCheck == DoSecurityCheck && (frameLoader->state() == FrameStateProvisional || !frameLoader->activeDocumentLoader() || frameLoader->activeDocumentLoader()->isStopping()))
             return 0;
 
@@ -893,7 +895,7 @@
     return CachePolicyVerify;
 }
 
-void CachedResourceLoader::loadDone(CachedResource* resource)
+void CachedResourceLoader::didLoadResource(CachedResource* resource)
 {
     RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader);
     RefPtr<Document> protectDocument(m_document);
@@ -1077,6 +1079,120 @@
     m_pendingPreloads.clear();
 }
 
+inline FrameLoader* CachedResourceLoader::frameLoader()
+{
+    return frame() ? frame()->loader() : 0;
+}
+
+void CachedResourceLoader::didFinishLoading(const CachedResource* resource, double finishTime, const ResourceLoaderOptions& options)
+{
+    if (options.sendLoadCallbacks != SendCallbacks)
+        return;
+    if (FrameLoader* loader = frameLoader())
+        loader->notifier()->dispatchDidFinishLoading(m_documentLoader, resource->identifier(), finishTime);
+}
+
+void CachedResourceLoader::didChangeLoadingPriority(const CachedResource* resource, ResourceLoadPriority loadPriority)
+{
+    if (FrameLoader* loader = frameLoader())
+        loader->client()->dispatchDidChangeResourcePriority(resource->identifier(), loadPriority);
+}
+
+void CachedResourceLoader::didFailLoading(const CachedResource* resource, const ResourceError& error, const ResourceLoaderOptions& options)
+{
+    if (options.sendLoadCallbacks != SendCallbacks)
+        return;
+    if (FrameLoader* loader = frameLoader())
+        loader->notifier()->dispatchDidFail(m_documentLoader, resource->identifier(), error);
+}
+
+void CachedResourceLoader::willSendRequest(const CachedResource* resource, ResourceRequest& request, const ResourceResponse& redirectResponse, const ResourceLoaderOptions& options)
+{
+    if (options.sendLoadCallbacks == SendCallbacks) {
+        if (FrameLoader* loader = frameLoader())
+            loader->notifier()->dispatchWillSendRequest(m_documentLoader, resource->identifier(), request, redirectResponse, options.initiatorInfo);
+    } else {
+        InspectorInstrumentation::willSendRequest(frame(), resource->identifier(), m_documentLoader, request, redirectResponse, options.initiatorInfo);
+    }
+}
+
+void CachedResourceLoader::didReceiveResponse(const CachedResource* resource, const ResourceResponse& response, const ResourceLoaderOptions& options)
+{
+    if (options.sendLoadCallbacks != SendCallbacks)
+        return;
+    if (FrameLoader* loader = frameLoader())
+        loader->notifier()->dispatchDidReceiveResponse(m_documentLoader, resource->identifier(), response);
+}
+
+void CachedResourceLoader::didReceiveData(const CachedResource* resource, const char* data, int dataLength, int encodedDataLength, const ResourceLoaderOptions& options)
+{
+    if (options.sendLoadCallbacks != SendCallbacks)
+        return;
+    if (FrameLoader* loader = frameLoader())
+        loader->notifier()->dispatchDidReceiveData(m_documentLoader, resource->identifier(), data, dataLength, encodedDataLength);
+}
+
+void CachedResourceLoader::subresourceLoaderFinishedLoadingOnePart(ResourceLoader* loader)
+{
+    if (m_documentLoader)
+        m_documentLoader->subresourceLoaderFinishedLoadingOnePart(loader);
+}
+
+void CachedResourceLoader::didInitializeResourceLoader(ResourceLoader* loader)
+{
+    if (m_documentLoader)
+        m_documentLoader->addResourceLoader(loader);
+}
+
+void CachedResourceLoader::willTerminateResourceLoader(ResourceLoader* loader)
+{
+    if (m_documentLoader)
+        m_documentLoader->removeResourceLoader(loader);
+}
+
+void CachedResourceLoader::willStartLoadingResource(ResourceRequest& request)
+{
+    if (m_documentLoader)
+        m_documentLoader->applicationCacheHost()->willStartLoadingResource(request);
+}
+
+bool CachedResourceLoader::defersLoading() const
+{
+    if (Frame* frame = this->frame())
+        return frame->page()->defersLoading();
+    return false;
+}
+
+bool CachedResourceLoader::isLoadedBy(ResourceLoaderHost* possibleOwner) const
+{
+    return this == possibleOwner;
+}
+
+bool CachedResourceLoader::shouldRequest(CachedResource* resource, const ResourceRequest& request, const ResourceLoaderOptions& options)
+{
+    if (!canRequest(resource->type(), request.url(), options))
+        return false;
+    if (resource->type() == CachedResource::ImageResource && shouldDeferImageLoad(request.url()))
+        return false;
+    return true;
+}
+
+Frame* CachedResourceLoader::inspectedFrame() const
+{
+    // FIXME: return frame of master document for imported documents.
+    return m_documentLoader ? m_documentLoader->frame() : 0;
+}
+
+void CachedResourceLoader::refResourceLoaderHost()
+{
+    ref();
+}
+
+void CachedResourceLoader::derefResourceLoaderHost()
+{
+    deref();
+}
+
 #if PRELOAD_DEBUG
 void CachedResourceLoader::printPreloadStats()
 {
diff --git a/Source/core/loader/cache/CachedResourceLoader.h b/Source/core/loader/cache/CachedResourceLoader.h
index 9fab79c..b0b05bf 100644
--- a/Source/core/loader/cache/CachedResourceLoader.h
+++ b/Source/core/loader/cache/CachedResourceLoader.h
@@ -26,6 +26,7 @@
 #ifndef CachedResourceLoader_h
 #define CachedResourceLoader_h
 
+#include "core/loader/ResourceLoaderHost.h"
 #include "core/loader/cache/CachePolicy.h"
 #include "core/loader/cache/CachedResource.h"
 #include "core/loader/cache/CachedResourceHandle.h"
@@ -52,6 +53,7 @@
 class Document;
 class DocumentLoader;
 class Frame;
+class FrameLoader;
 class ImageLoader;
 class KURL;
 
@@ -63,14 +65,17 @@
 // RefPtr<CachedResourceLoader> for their lifetime (and will create one if they
 // are initialized without a Frame), so a Document can keep a CachedResourceLoader
 // alive past detach if scripts still reference the Document.
-class CachedResourceLoader : public RefCounted<CachedResourceLoader> {
+class CachedResourceLoader : public RefCounted<CachedResourceLoader>, public ResourceLoaderHost {
     WTF_MAKE_NONCOPYABLE(CachedResourceLoader); WTF_MAKE_FAST_ALLOCATED;
 friend class ImageLoader;
 friend class ResourceCacheValidationSuppressor;
 
 public:
     static PassRefPtr<CachedResourceLoader> create(DocumentLoader* documentLoader) { return adoptRef(new CachedResourceLoader(documentLoader)); }
-    ~CachedResourceLoader();
+    virtual ~CachedResourceLoader();
+
+    using RefCounted<CachedResourceLoader>::ref;
+    using RefCounted<CachedResourceLoader>::deref;
 
     CachedResourceHandle<CachedImage> requestImage(CachedResourceRequest&);
     CachedResourceHandle<CachedCSSStyleSheet> requestCSSStyleSheet(CachedResourceRequest&);
@@ -110,11 +115,8 @@
     DocumentLoader* documentLoader() const { return m_documentLoader; }
     void clearDocumentLoader() { m_documentLoader = 0; }
 
-    void loadDone(CachedResource*);
     void garbageCollectDocumentResources();
     
-    void incrementRequestCount(const CachedResource*);
-    void decrementRequestCount(const CachedResource*);
     int requestCount() const { return m_requestCount; }
 
     bool isPreloaded(const String& urlString) const;
@@ -126,11 +128,34 @@
     bool canRequest(CachedResource::Type, const KURL&, const ResourceLoaderOptions&, bool forPreload = false);
     bool canAccess(CachedResource*);
 
-    static const ResourceLoaderOptions& defaultCachedResourceOptions();
+    // ResourceLoaderHost
+    virtual void incrementRequestCount(const CachedResource*) OVERRIDE;
+    virtual void decrementRequestCount(const CachedResource*) OVERRIDE;
+    virtual void didLoadResource(CachedResource*) 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;
+    virtual void willSendRequest(const CachedResource*, ResourceRequest&, const ResourceResponse& redirectResponse, const ResourceLoaderOptions&) OVERRIDE;
+    virtual void didReceiveResponse(const CachedResource*, const ResourceResponse&, const ResourceLoaderOptions&) OVERRIDE;
+    virtual void didReceiveData(const CachedResource*, const char* data, int dataLength, int encodedDataLength, const ResourceLoaderOptions&) OVERRIDE;
+    virtual void subresourceLoaderFinishedLoadingOnePart(ResourceLoader*) OVERRIDE;
+    virtual void didInitializeResourceLoader(ResourceLoader*) OVERRIDE;
+    virtual void willTerminateResourceLoader(ResourceLoader*) OVERRIDE;
+    virtual void willStartLoadingResource(ResourceRequest&) OVERRIDE;
+    virtual bool defersLoading() const OVERRIDE;
+    virtual bool isLoadedBy(ResourceLoaderHost*) const OVERRIDE;
+    virtual bool shouldRequest(CachedResource*, const ResourceRequest&, const ResourceLoaderOptions&) OVERRIDE;
+    virtual void refResourceLoaderHost() OVERRIDE;
+    virtual void derefResourceLoaderHost() OVERRIDE;
+    virtual Frame* inspectedFrame() const OVERRIDE;
 
+    static const ResourceLoaderOptions& defaultCachedResourceOptions();
 private:
+
     explicit CachedResourceLoader(DocumentLoader*);
 
+    FrameLoader* frameLoader();
+
     CachedResourceHandle<CachedResource> requestResource(CachedResource::Type, CachedResourceRequest&);
     CachedResourceHandle<CachedResource> revalidateResource(const CachedResourceRequest&, CachedResource*);
     CachedResourceHandle<CachedResource> loadResource(CachedResource::Type, CachedResourceRequest&, const String& charset);
diff --git a/Source/core/loader/cache/CachedScript.cpp b/Source/core/loader/cache/CachedScript.cpp
index 0ed66ad..cd0bf16 100644
--- a/Source/core/loader/cache/CachedScript.cpp
+++ b/Source/core/loader/cache/CachedScript.cpp
@@ -36,7 +36,7 @@
 
 CachedScript::CachedScript(const ResourceRequest& resourceRequest, const String& charset)
     : CachedResource(resourceRequest, Script)
-    , m_decoder(TextResourceDecoder::create("application/javascript", charset))
+    , m_decoder(TextResourceDecoder::create(ASCIILiteral("application/javascript"), charset))
 {
     DEFINE_STATIC_LOCAL(const AtomicString, acceptScript, ("*/*", AtomicString::ConstructFromLiteral));
 
diff --git a/Source/core/make_derived_sources.target.darwin-arm.mk b/Source/core/make_derived_sources.target.darwin-arm.mk
index 8aab5c2..a7adb64 100644
--- a/Source/core/make_derived_sources.target.darwin-arm.mk
+++ b/Source/core/make_derived_sources.target.darwin-arm.mk
@@ -76,6 +76,17 @@
 
 $(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.h: $(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.cpp ;
 
+### Rules for action "StylePropertyShorthand":
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_local_path := $(LOCAL_PATH)
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/in_file.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/in_generator.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/license.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/name_macros.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/template_expander.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/macros.tmpl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/make_style_shorthands.py $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSShorthands.in $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/StylePropertyShorthand.h.tmpl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/StylePropertyShorthand.cpp.tmpl $(GYP_TARGET_DEPENDENCIES)
+	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_StylePropertyShorthand ($@)"
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/make_style_shorthands.py css/CSSShorthands.in --output_dir "$(gyp_shared_intermediate_dir)/webkit/"
+
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.h: $(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp ;
+
 ### Rules for action "StyleBuilder":
 $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp: gyp_local_path := $(LOCAL_PATH)
 $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
@@ -331,6 +342,8 @@
 	$(gyp_shared_intermediate_dir)/webkit/RuntimeEnabledFeatures.h \
 	$(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.cpp \
 	$(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.h \
+	$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp \
+	$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.h \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.h \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.cpp \
diff --git a/Source/core/make_derived_sources.target.darwin-mips.mk b/Source/core/make_derived_sources.target.darwin-mips.mk
index fbe2c8e..d043294 100644
--- a/Source/core/make_derived_sources.target.darwin-mips.mk
+++ b/Source/core/make_derived_sources.target.darwin-mips.mk
@@ -76,6 +76,17 @@
 
 $(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.h: $(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.cpp ;
 
+### Rules for action "StylePropertyShorthand":
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_local_path := $(LOCAL_PATH)
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/in_file.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/in_generator.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/license.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/name_macros.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/template_expander.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/macros.tmpl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/make_style_shorthands.py $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSShorthands.in $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/StylePropertyShorthand.h.tmpl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/StylePropertyShorthand.cpp.tmpl $(GYP_TARGET_DEPENDENCIES)
+	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_StylePropertyShorthand ($@)"
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/make_style_shorthands.py css/CSSShorthands.in --output_dir "$(gyp_shared_intermediate_dir)/webkit/"
+
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.h: $(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp ;
+
 ### Rules for action "StyleBuilder":
 $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp: gyp_local_path := $(LOCAL_PATH)
 $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
@@ -331,6 +342,8 @@
 	$(gyp_shared_intermediate_dir)/webkit/RuntimeEnabledFeatures.h \
 	$(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.cpp \
 	$(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.h \
+	$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp \
+	$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.h \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.h \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.cpp \
diff --git a/Source/core/make_derived_sources.target.darwin-x86.mk b/Source/core/make_derived_sources.target.darwin-x86.mk
index 553b58d..9dc8cd6 100644
--- a/Source/core/make_derived_sources.target.darwin-x86.mk
+++ b/Source/core/make_derived_sources.target.darwin-x86.mk
@@ -76,6 +76,17 @@
 
 $(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.h: $(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.cpp ;
 
+### Rules for action "StylePropertyShorthand":
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_local_path := $(LOCAL_PATH)
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/in_file.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/in_generator.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/license.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/name_macros.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/template_expander.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/macros.tmpl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/make_style_shorthands.py $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSShorthands.in $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/StylePropertyShorthand.h.tmpl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/StylePropertyShorthand.cpp.tmpl $(GYP_TARGET_DEPENDENCIES)
+	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_StylePropertyShorthand ($@)"
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/make_style_shorthands.py css/CSSShorthands.in --output_dir "$(gyp_shared_intermediate_dir)/webkit/"
+
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.h: $(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp ;
+
 ### Rules for action "StyleBuilder":
 $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp: gyp_local_path := $(LOCAL_PATH)
 $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
@@ -331,6 +342,8 @@
 	$(gyp_shared_intermediate_dir)/webkit/RuntimeEnabledFeatures.h \
 	$(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.cpp \
 	$(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.h \
+	$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp \
+	$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.h \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.h \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.cpp \
diff --git a/Source/core/make_derived_sources.target.linux-arm.mk b/Source/core/make_derived_sources.target.linux-arm.mk
index 8aab5c2..a7adb64 100644
--- a/Source/core/make_derived_sources.target.linux-arm.mk
+++ b/Source/core/make_derived_sources.target.linux-arm.mk
@@ -76,6 +76,17 @@
 
 $(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.h: $(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.cpp ;
 
+### Rules for action "StylePropertyShorthand":
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_local_path := $(LOCAL_PATH)
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/in_file.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/in_generator.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/license.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/name_macros.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/template_expander.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/macros.tmpl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/make_style_shorthands.py $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSShorthands.in $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/StylePropertyShorthand.h.tmpl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/StylePropertyShorthand.cpp.tmpl $(GYP_TARGET_DEPENDENCIES)
+	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_StylePropertyShorthand ($@)"
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/make_style_shorthands.py css/CSSShorthands.in --output_dir "$(gyp_shared_intermediate_dir)/webkit/"
+
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.h: $(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp ;
+
 ### Rules for action "StyleBuilder":
 $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp: gyp_local_path := $(LOCAL_PATH)
 $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
@@ -331,6 +342,8 @@
 	$(gyp_shared_intermediate_dir)/webkit/RuntimeEnabledFeatures.h \
 	$(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.cpp \
 	$(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.h \
+	$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp \
+	$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.h \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.h \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.cpp \
diff --git a/Source/core/make_derived_sources.target.linux-mips.mk b/Source/core/make_derived_sources.target.linux-mips.mk
index fbe2c8e..d043294 100644
--- a/Source/core/make_derived_sources.target.linux-mips.mk
+++ b/Source/core/make_derived_sources.target.linux-mips.mk
@@ -76,6 +76,17 @@
 
 $(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.h: $(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.cpp ;
 
+### Rules for action "StylePropertyShorthand":
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_local_path := $(LOCAL_PATH)
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/in_file.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/in_generator.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/license.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/name_macros.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/template_expander.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/macros.tmpl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/make_style_shorthands.py $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSShorthands.in $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/StylePropertyShorthand.h.tmpl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/StylePropertyShorthand.cpp.tmpl $(GYP_TARGET_DEPENDENCIES)
+	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_StylePropertyShorthand ($@)"
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/make_style_shorthands.py css/CSSShorthands.in --output_dir "$(gyp_shared_intermediate_dir)/webkit/"
+
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.h: $(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp ;
+
 ### Rules for action "StyleBuilder":
 $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp: gyp_local_path := $(LOCAL_PATH)
 $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
@@ -331,6 +342,8 @@
 	$(gyp_shared_intermediate_dir)/webkit/RuntimeEnabledFeatures.h \
 	$(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.cpp \
 	$(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.h \
+	$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp \
+	$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.h \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.h \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.cpp \
diff --git a/Source/core/make_derived_sources.target.linux-x86.mk b/Source/core/make_derived_sources.target.linux-x86.mk
index 553b58d..9dc8cd6 100644
--- a/Source/core/make_derived_sources.target.linux-x86.mk
+++ b/Source/core/make_derived_sources.target.linux-x86.mk
@@ -76,6 +76,17 @@
 
 $(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.h: $(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.cpp ;
 
+### Rules for action "StylePropertyShorthand":
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_local_path := $(LOCAL_PATH)
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp: $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/in_file.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/in_generator.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/license.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/name_macros.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/template_expander.py $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/macros.tmpl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/make_style_shorthands.py $(LOCAL_PATH)/third_party/WebKit/Source/core/css/CSSShorthands.in $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/StylePropertyShorthand.h.tmpl $(LOCAL_PATH)/third_party/WebKit/Source/core/scripts/templates/StylePropertyShorthand.cpp.tmpl $(GYP_TARGET_DEPENDENCIES)
+	@echo "Gyp action: third_party_WebKit_Source_core_core_derived_sources_gyp_make_derived_sources_target_StylePropertyShorthand ($@)"
+	$(hide)cd $(gyp_local_path)/third_party/WebKit/Source/core; mkdir -p $(gyp_shared_intermediate_dir)/webkit; python scripts/make_style_shorthands.py css/CSSShorthands.in --output_dir "$(gyp_shared_intermediate_dir)/webkit/"
+
+$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.h: $(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp ;
+
 ### Rules for action "StyleBuilder":
 $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp: gyp_local_path := $(LOCAL_PATH)
 $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir))
@@ -331,6 +342,8 @@
 	$(gyp_shared_intermediate_dir)/webkit/RuntimeEnabledFeatures.h \
 	$(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.cpp \
 	$(gyp_shared_intermediate_dir)/webkit/CSSPropertyNames.h \
+	$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp \
+	$(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.h \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.h \
 	$(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.cpp \
diff --git a/Source/core/page/CreateWindow.cpp b/Source/core/page/CreateWindow.cpp
index 6f9ff2c..206ad49 100644
--- a/Source/core/page/CreateWindow.cpp
+++ b/Source/core/page/CreateWindow.cpp
@@ -154,11 +154,11 @@
     newFrame->loader()->setOpener(openerFrame);
     newFrame->page()->setOpenedByDOM();
 
-    if (newFrame->document()->domWindow()->isInsecureScriptAccess(activeWindow, completedURL))
+    if (newFrame->domWindow()->isInsecureScriptAccess(activeWindow, completedURL))
         return newFrame;
 
     if (function)
-        function(newFrame->document()->domWindow(), functionContext);
+        function(newFrame->domWindow(), functionContext);
 
     if (created) {
         FrameLoadRequest request(activeWindow->document()->securityOrigin(), ResourceRequest(completedURL, referrer));
diff --git a/Source/core/page/DOMTimer.cpp b/Source/core/page/DOMTimer.cpp
index ee3157f..e5529e9 100644
--- a/Source/core/page/DOMTimer.cpp
+++ b/Source/core/page/DOMTimer.cpp
@@ -68,21 +68,23 @@
     return 0;
 }
 
-int DOMTimer::install(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int timeout, bool singleShot)
+int DOMTimer::install(ScriptExecutionContext* context, Type type, PassOwnPtr<ScheduledAction> action, int timeout)
 {
-    int timeoutID = context->installNewTimeout(action, timeout, singleShot);
-    InspectorInstrumentation::didInstallTimer(context, timeoutID, timeout, singleShot);
+    int timeoutID = context->installNewTimeout(type, action, timeout);
+    InspectorInstrumentation::didInstallTimer(context, timeoutID, timeout, type == TimeoutType); // FIXME: Fix inspector so it can accept a DOMTimer::Type value.
     return timeoutID;
 }
 
-void DOMTimer::removeByID(ScriptExecutionContext* context, int timeoutID)
+void DOMTimer::removeByIDIfTypeMatches(ScriptExecutionContext* context, Type type, int timeoutID)
 {
-    context->removeTimeoutByID(timeoutID);
+    // FIXME: Invoke didRemoveTimer() if a timer is actually removed.
+    context->removeTimeoutByIDIfTypeMatches(type, timeoutID);
     InspectorInstrumentation::didRemoveTimer(context, timeoutID);
 }
 
-DOMTimer::DOMTimer(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int interval, bool singleShot, int timeoutID)
+DOMTimer::DOMTimer(ScriptExecutionContext* context, Type type, PassOwnPtr<ScheduledAction> action, int interval, int timeoutID)
     : SuspendableTimer(context)
+    , m_type(type)
     , m_timeoutID(timeoutID)
     , m_nestingLevel(timerNestingLevel + 1)
     , m_action(action)
@@ -94,10 +96,14 @@
     double intervalMilliseconds = max(oneMillisecond, interval * oneMillisecond);
     if (intervalMilliseconds < minimumInterval && m_nestingLevel >= maxTimerNestingLevel)
         intervalMilliseconds = minimumInterval;
-    if (singleShot)
+    switch (type) {
+    case TimeoutType:
         startOneShot(intervalMilliseconds);
-    else
+        break;
+    case IntervalType:
         startRepeating(intervalMilliseconds);
+        break;
+    }
 }
 
 DOMTimer::~DOMTimer()
@@ -109,6 +115,11 @@
     return m_timeoutID;
 }
 
+DOMTimer::Type DOMTimer::type() const
+{
+    return m_type;
+}
+
 void DOMTimer::fired()
 {
     ScriptExecutionContext* context = scriptExecutionContext();
@@ -139,7 +150,8 @@
     OwnPtr<ScheduledAction> action = m_action.release();
 
     // This timer is being deleted; no access to member variables allowed after this point.
-    context->removeTimeoutByID(m_timeoutID);
+    bool removed = context->removeTimeoutByIDIfTypeMatches(m_type, m_timeoutID);
+    ASSERT_UNUSED(removed, removed);
 
     action->execute(context);
 
diff --git a/Source/core/page/DOMTimer.h b/Source/core/page/DOMTimer.h
index 9324899..d0ca5c4 100644
--- a/Source/core/page/DOMTimer.h
+++ b/Source/core/page/DOMTimer.h
@@ -40,13 +40,19 @@
 
 class DOMTimer : public SuspendableTimer {
 public:
+    enum Type {
+        TimeoutType,
+        IntervalType
+    };
+
     // Creates a new timer owned by the ScriptExecutionContext, starts it and returns its ID.
-    static int install(ScriptExecutionContext*, PassOwnPtr<ScheduledAction>, int timeout, bool singleShot);
-    static void removeByID(ScriptExecutionContext*, int timeoutID);
+    static int install(ScriptExecutionContext*, Type, PassOwnPtr<ScheduledAction>, int timeout);
+    static void removeByIDIfTypeMatches(ScriptExecutionContext*, Type, int timeoutID);
 
     virtual ~DOMTimer();
 
     int timeoutID() const;
+    Type type() const;
 
     // ActiveDOMObject
     virtual void contextDestroyed() OVERRIDE;
@@ -60,17 +66,18 @@
     friend class ScriptExecutionContext; // For create().
 
     // Should only be used by ScriptExecutionContext.
-    static PassOwnPtr<DOMTimer> create(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int timeout, bool singleShot, int timeoutID)
+    static PassOwnPtr<DOMTimer> create(ScriptExecutionContext* context, Type type, PassOwnPtr<ScheduledAction> action, int timeout, int timeoutID)
     {
-        return adoptPtr(new DOMTimer(context, action, timeout, singleShot, timeoutID));
+        return adoptPtr(new DOMTimer(context, type, action, timeout, timeoutID));
     }
 
-    DOMTimer(ScriptExecutionContext*, PassOwnPtr<ScheduledAction>, int interval, bool singleShot, int timeoutID);
-    virtual void fired();
+    DOMTimer(ScriptExecutionContext*, Type, PassOwnPtr<ScheduledAction>, int interval, int timeoutID);
+    virtual void fired() OVERRIDE;
 
-    // Retuns timer fire time rounded to the next multiple of timer alignment interval.
-    virtual double alignedFireTime(double) const;
+    // Returns timer fire time rounded to the next multiple of timer alignment interval.
+    virtual double alignedFireTime(double) const OVERRIDE;
 
+    Type m_type;
     int m_timeoutID;
     int m_nestingLevel;
     OwnPtr<ScheduledAction> m_action;
diff --git a/Source/core/page/DOMWindow.cpp b/Source/core/page/DOMWindow.cpp
index b4547b1..1781573 100644
--- a/Source/core/page/DOMWindow.cpp
+++ b/Source/core/page/DOMWindow.cpp
@@ -29,10 +29,10 @@
 
 #include "wtf/MainThread.h"
 #include "wtf/MathExtras.h"
-#include "wtf/text/Base64.h"
 #include "wtf/text/WTFString.h"
 #include <algorithm>
 #include "RuntimeEnabledFeatures.h"
+#include "bindings/v8/ExceptionState.h"
 #include "bindings/v8/ScriptCallStackFactory.h"
 #include "bindings/v8/ScriptController.h"
 #include "bindings/v8/SerializedScriptValue.h"
@@ -75,7 +75,6 @@
 #include "core/page/Console.h"
 #include "core/page/CreateWindow.h"
 #include "core/page/DOMPoint.h"
-#include "core/page/DOMTimer.h"
 #include "core/page/EventHandler.h"
 #include "core/page/Frame.h"
 #include "core/page/FrameTree.h"
@@ -500,7 +499,7 @@
 
 bool DOMWindow::isCurrentlyDisplayedInFrame() const
 {
-    return m_frame && m_frame->document()->domWindow() == this;
+    return m_frame && m_frame->domWindow() == this;
 }
 
 #if ENABLE(ORIENTATION_EVENTS)
@@ -646,7 +645,7 @@
     if (!document)
         return 0;
 
-    if (!document->securityOrigin()->canAccessLocalStorage(document->topOrigin())) {
+    if (!document->securityOrigin()->canAccessLocalStorage()) {
         ec = SecurityError;
         return 0;
     }
@@ -682,7 +681,7 @@
     if (!document)
         return 0;
 
-    if (!document->securityOrigin()->canAccessLocalStorage(document->topOrigin())) {
+    if (!document->securityOrigin()->canAccessLocalStorage()) {
         ec = SecurityError;
         return 0;
     }
@@ -712,7 +711,7 @@
     return m_localStorage.get();
 }
 
-void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, const String& targetOrigin, DOMWindow* source, ExceptionCode& ec)
+void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, const String& targetOrigin, DOMWindow* source, ExceptionState& es)
 {
     if (!isCurrentlyDisplayedInFrame())
         return;
@@ -731,13 +730,13 @@
         // It doesn't make sense target a postMessage at a unique origin
         // because there's no way to represent a unique origin in a string.
         if (target->isUnique()) {
-            ec = SyntaxError;
+            es.throwDOMException(SyntaxError);
             return;
         }
     }
 
-    OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, ec);
-    if (ec)
+    OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, es);
+    if (es.hadException())
         return;
 
     // Capture the source of the message.  We need to do this synchronously
@@ -943,38 +942,6 @@
     return String();
 }
 
-String DOMWindow::btoa(const String& stringToEncode, ExceptionCode& ec)
-{
-    if (stringToEncode.isNull())
-        return String();
-
-    if (!stringToEncode.containsOnlyLatin1()) {
-        ec = InvalidCharacterError;
-        return String();
-    }
-
-    return base64Encode(stringToEncode.latin1());
-}
-
-String DOMWindow::atob(const String& encodedString, ExceptionCode& ec)
-{
-    if (encodedString.isNull())
-        return String();
-
-    if (!encodedString.containsOnlyLatin1()) {
-        ec = InvalidCharacterError;
-        return String();
-    }
-
-    Vector<char> out;
-    if (!base64Decode(encodedString, out, Base64FailOnInvalidCharacter)) {
-        ec = InvalidCharacterError;
-        return String();
-    }
-
-    return String(out.data(), out.size());
-}
-
 bool DOMWindow::find(const String& string, bool caseSensitive, bool backwards, bool wrap, bool /*wholeWord*/, bool /*searchInFrames*/, bool /*showDialog*/) const
 {
     if (!isCurrentlyDisplayedInFrame())
@@ -1166,7 +1133,7 @@
     if (!m_frame)
         return 0;
 
-    return m_frame->document()->domWindow();
+    return m_frame->domWindow();
 }
 
 DOMWindow* DOMWindow::opener() const
@@ -1178,7 +1145,7 @@
     if (!opener)
         return 0;
 
-    return opener->document()->domWindow();
+    return opener->domWindow();
 }
 
 DOMWindow* DOMWindow::parent() const
@@ -1188,9 +1155,9 @@
 
     Frame* parent = m_frame->tree()->parent();
     if (parent)
-        return parent->document()->domWindow();
+        return parent->domWindow();
 
-    return m_frame->document()->domWindow();
+    return m_frame->domWindow();
 }
 
 DOMWindow* DOMWindow::top() const
@@ -1202,7 +1169,7 @@
     if (!page)
         return 0;
 
-    return m_frame->tree()->top()->document()->domWindow();
+    return m_frame->tree()->top()->domWindow();
 }
 
 Document* DOMWindow::document() const
@@ -1394,18 +1361,6 @@
     page->chrome().setWindowRect(adjustWindowRect(page, update));
 }
 
-void DOMWindow::clearTimeout(int timeoutID)
-{
-    if (ScriptExecutionContext* context = scriptExecutionContext())
-        DOMTimer::removeByID(context, timeoutID);
-}
-
-void DOMWindow::clearInterval(int timeoutID)
-{
-    if (ScriptExecutionContext* context = scriptExecutionContext())
-        DOMTimer::removeByID(context, timeoutID);
-}
-
 static LayoutSize size(HTMLImageElement* image)
 {
     if (CachedImage* cachedImage = image->cachedImage())
@@ -1902,11 +1857,11 @@
 
         KURL completedURL = firstFrame->document()->completeURL(urlString);
 
-        if (targetFrame->document()->domWindow()->isInsecureScriptAccess(activeWindow, completedURL))
-            return targetFrame->document()->domWindow();
+        if (targetFrame->domWindow()->isInsecureScriptAccess(activeWindow, completedURL))
+            return targetFrame->domWindow();
 
         if (urlString.isEmpty())
-            return targetFrame->document()->domWindow();
+            return targetFrame->domWindow();
 
         // For whatever reason, Firefox uses the first window rather than the active window to
         // determine the outgoing referrer. We replicate that behavior here.
@@ -1915,12 +1870,12 @@
             completedURL,
             firstFrame->loader()->outgoingReferrer(),
             false);
-        return targetFrame->document()->domWindow();
+        return targetFrame->domWindow();
     }
 
     WindowFeatures windowFeatures(windowFeaturesString);
     Frame* result = createWindow(urlString, frameName, windowFeatures, activeWindow, firstFrame, m_frame);
-    return result ? result->document()->domWindow() : 0;
+    return result ? result->domWindow() : 0;
 }
 
 void DOMWindow::showModalDialog(const String& urlString, const String& dialogFeaturesString,
@@ -1955,7 +1910,7 @@
 
     Frame* child = frame->tree()->scopedChild(index);
     if (child)
-        return child->document()->domWindow();
+        return child->domWindow();
 
     return 0;
 }
diff --git a/Source/core/page/DOMWindow.h b/Source/core/page/DOMWindow.h
index ac289d4..34eb1e6 100644
--- a/Source/core/page/DOMWindow.h
+++ b/Source/core/page/DOMWindow.h
@@ -50,6 +50,7 @@
     class Document;
     class Element;
     class EventListener;
+    class ExceptionState;
     class FloatRect;
     class Frame;
     class HTMLCanvasElement;
@@ -159,8 +160,6 @@
         void alert(const String& message);
         bool confirm(const String& message);
         String prompt(const String& message, const String& defaultValue);
-        String btoa(const String& stringToEncode, ExceptionCode&);
-        String atob(const String& encodedString, ExceptionCode&);
 
         bool find(const String&, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) const;
 
@@ -231,7 +230,7 @@
         void printErrorMessage(const String&);
         String crossDomainAccessErrorMessage(DOMWindow* activeWindow);
 
-        void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, const String& targetOrigin, DOMWindow* source, ExceptionCode&);
+        void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, const String& targetOrigin, DOMWindow* source, ExceptionState&);
         void postMessageTimerFired(PassOwnPtr<PostMessageTimer>);
         void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigin, PassRefPtr<Event>, PassRefPtr<ScriptCallStack>);
 
@@ -245,10 +244,6 @@
         void resizeBy(float x, float y) const;
         void resizeTo(float width, float height) const;
 
-        // Timers
-        void clearTimeout(int timeoutId);
-        void clearInterval(int timeoutId);
-
         // Images
         void createImageBitmap(HTMLImageElement*, PassRefPtr<ImageBitmapCallback>, ExceptionCode&);
         void createImageBitmap(HTMLImageElement*, PassRefPtr<ImageBitmapCallback>, int sx, int sy, int sw, int sh, ExceptionCode&);
diff --git a/Source/core/page/DOMWindowBase64.cpp b/Source/core/page/DOMWindowBase64.cpp
new file mode 100644
index 0000000..7d3252b
--- /dev/null
+++ b/Source/core/page/DOMWindowBase64.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2013 Samsung Electronics. 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/page/DOMWindowBase64.h"
+
+#include "wtf/text/Base64.h"
+
+namespace WebCore {
+
+namespace DOMWindowBase64 {
+
+String btoa(void*, const String& stringToEncode, ExceptionCode& ec)
+{
+    if (stringToEncode.isNull())
+        return String();
+
+    if (!stringToEncode.containsOnlyLatin1()) {
+        ec = InvalidCharacterError;
+        return String();
+    }
+
+    return base64Encode(stringToEncode.latin1());
+}
+
+String atob(void*, const String& encodedString, ExceptionCode& ec)
+{
+    if (encodedString.isNull())
+        return String();
+
+    if (!encodedString.containsOnlyLatin1()) {
+        ec = InvalidCharacterError;
+        return String();
+    }
+
+    Vector<char> out;
+    if (!base64Decode(encodedString, out, Base64FailOnInvalidCharacter, Base64StrictPaddingValidation)) {
+        ec = InvalidCharacterError;
+        return String();
+    }
+
+    return String(out.data(), out.size());
+}
+
+} // namespace DOMWindowBase64
+
+} // namespace WebCore
diff --git a/Source/core/page/DOMWindowBase64.h b/Source/core/page/DOMWindowBase64.h
new file mode 100644
index 0000000..50b7972
--- /dev/null
+++ b/Source/core/page/DOMWindowBase64.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2013 Samsung Electronics. 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 DOMWindowBase64_h
+#define DOMWindowBase64_h
+
+#include "core/dom/ExceptionCode.h"
+#include "wtf/text/WTFString.h"
+
+namespace WebCore {
+
+namespace DOMWindowBase64 {
+String btoa(void*, const String& stringToEncode, ExceptionCode&);
+String atob(void*, const String& encodedString, ExceptionCode&);
+}
+
+} // namespace WebCore
+
+#endif // DOMWindowBase64_h
diff --git a/Source/core/page/DOMWindowProperty.cpp b/Source/core/page/DOMWindowProperty.cpp
index f99f9d6..14df8ac 100644
--- a/Source/core/page/DOMWindowProperty.cpp
+++ b/Source/core/page/DOMWindowProperty.cpp
@@ -41,7 +41,7 @@
     // See fast/dom/navigator-detached-no-crash.html for the recipe.
     // We should fix that.  <rdar://problem/11567132>
     if (m_frame) {
-        m_associatedDOMWindow = m_frame->document()->domWindow();
+        m_associatedDOMWindow = m_frame->domWindow();
         m_associatedDOMWindow->registerProperty(this);
     }
 }
diff --git a/Source/core/page/DOMWindowTimers.cpp b/Source/core/page/DOMWindowTimers.cpp
new file mode 100644
index 0000000..66a9142
--- /dev/null
+++ b/Source/core/page/DOMWindowTimers.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2013 Samsung Electronics. 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/page/DOMWindowTimers.h"
+
+#include "core/dom/EventTarget.h"
+#include "core/page/DOMTimer.h"
+
+namespace WebCore {
+
+namespace DOMWindowTimers {
+
+int setTimeout(EventTarget* eventTarget, PassOwnPtr<ScheduledAction> action, int timeout)
+{
+    return DOMTimer::install(eventTarget->scriptExecutionContext(), DOMTimer::TimeoutType, action, timeout);
+}
+
+int setInterval(EventTarget* eventTarget, PassOwnPtr<ScheduledAction> action, int timeout)
+{
+    return DOMTimer::install(eventTarget->scriptExecutionContext(), DOMTimer::IntervalType, action, timeout);
+}
+
+void clearTimeout(EventTarget* eventTarget, int timeoutID)
+{
+    if (ScriptExecutionContext* context = eventTarget->scriptExecutionContext())
+        DOMTimer::removeByIDIfTypeMatches(context, DOMTimer::TimeoutType, timeoutID);
+}
+
+void clearInterval(EventTarget* eventTarget, int timeoutID)
+{
+    if (ScriptExecutionContext* context = eventTarget->scriptExecutionContext())
+        DOMTimer::removeByIDIfTypeMatches(context, DOMTimer::IntervalType, timeoutID);
+}
+
+} // namespace DOMWindowTimers
+
+} // namespace WebCore
diff --git a/Source/core/page/DOMWindowTimers.h b/Source/core/page/DOMWindowTimers.h
new file mode 100644
index 0000000..2a28f81
--- /dev/null
+++ b/Source/core/page/DOMWindowTimers.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2013 Samsung Electronics. 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 DOMWindowTimers_h
+#define DOMWindowTimers_h
+
+#include "wtf/Forward.h"
+
+namespace WebCore {
+
+class EventTarget;
+class ScheduledAction;
+
+namespace DOMWindowTimers {
+int setTimeout(EventTarget*, PassOwnPtr<ScheduledAction>, int timeout);
+int setInterval(EventTarget*, PassOwnPtr<ScheduledAction>, int timeout);
+void clearTimeout(EventTarget*, int timeoutId);
+void clearInterval(EventTarget*, int timeoutId);
+}
+
+} // namespace WebCore
+
+#endif // DOMWindowTimers_h
diff --git a/Source/core/page/DragController.cpp b/Source/core/page/DragController.cpp
index fc2455c..56f3adb 100644
--- a/Source/core/page/DragController.cpp
+++ b/Source/core/page/DragController.cpp
@@ -443,7 +443,7 @@
     ASSERT(m_page->dragCaretController()->hasCaret());
     String text = m_page->dragCaretController()->isContentRichlyEditable() ? "" : dragData->asPlainText(innerFrame);
     Node* target = innerFrame->editor()->findEventTargetFrom(m_page->dragCaretController()->caretPosition());
-    return target->dispatchEvent(TextEvent::createForDrop(innerFrame->document()->domWindow(), text), IGNORE_EXCEPTION);
+    return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow(), text), IGNORE_EXCEPTION);
 }
 
 bool DragController::concludeEditDrag(DragData* dragData)
diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp
index c53c5b4..ecc6e87 100644
--- a/Source/core/page/EventHandler.cpp
+++ b/Source/core/page/EventHandler.cpp
@@ -49,6 +49,7 @@
 #include "core/editing/FrameSelection.h"
 #include "core/editing/TextIterator.h"
 #include "core/editing/htmlediting.h"
+#include "core/history/BackForwardController.h"
 #include "core/html/HTMLFrameElementBase.h"
 #include "core/html/HTMLFrameSetElement.h"
 #include "core/html/HTMLInputElement.h"
@@ -940,7 +941,7 @@
     Node* node = startingNode;
 
     if (!node)
-        node = m_frame->document()->focusedNode();
+        node = m_frame->document()->focusedElement();
 
     if (!node)
         node = m_mousePressNode.get();
@@ -961,7 +962,7 @@
     Node* node = startingNode;
 
     if (!node)
-        node = m_frame->document()->focusedNode();
+        node = m_frame->document()->focusedElement();
 
     if (!node)
         node = m_mousePressNode.get();
@@ -1886,7 +1887,7 @@
     if (!shadowTreeParentElement || !shadowTreeParentElement->hasTagName(useTag))
         return 0;
 
-    return static_cast<SVGUseElement*>(shadowTreeParentElement)->instanceForShadowTreeElement(referenceNode);
+    return toSVGUseElement(shadowTreeParentElement)->instanceForShadowTreeElement(referenceNode);
 }
 
 void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMouseEvent& mouseEvent, bool fireMouseOverOut)
@@ -2030,7 +2031,7 @@
                 Node* n = node->isShadowRoot() ? toShadowRoot(node)->host() : node;
                 if (m_frame->selection()->isRange()
                     && m_frame->selection()->toNormalizedRange()->compareNode(n, IGNORE_EXCEPTION) == Range::NODE_INSIDE
-                    && n->isDescendantOf(m_frame->document()->focusedNode()))
+                    && n->isDescendantOf(m_frame->document()->focusedElement()))
                     return true;
                     
                 break;
@@ -2713,7 +2714,7 @@
 #endif
     IntPoint location;
 
-    Node* focusedNode = doc->focusedNode();
+    Element* focusedElement = doc->focusedElement();
     FrameSelection* selection = m_frame->selection();
     Position start = selection->selection().start();
 
@@ -2725,8 +2726,8 @@
         // In a multiline edit, firstRect.maxY() would endup on the next line, so -1.
         int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0;
         location = IntPoint(x, y);
-    } else if (focusedNode) {
-        RenderBoxModelObject* box = focusedNode->renderBoxModelObject();
+    } else if (focusedElement) {
+        RenderBoxModelObject* box = focusedElement->renderBoxModelObject();
         if (!box)
             return false;
         IntRect clippedRect = box->pixelSnappedAbsoluteClippedOverflowRect();
@@ -2742,7 +2743,7 @@
     IntPoint position = view->contentsToRootView(location);
     IntPoint globalPosition = view->hostWindow()->rootViewToScreen(IntRect(position, IntSize())).location();
 
-    Node* targetNode = doc->focusedNode();
+    Node* targetNode = doc->focusedElement();
     if (!targetNode)
         targetNode = doc;
 
@@ -3309,7 +3310,7 @@
     if (FrameView* view = m_frame->view())
         view->resetDeferredRepaintDelay();
 
-    RefPtr<TextEvent> event = TextEvent::create(m_frame->document()->domWindow(), text, inputType);
+    RefPtr<TextEvent> event = TextEvent::create(m_frame->domWindow(), text, inputType);
     event->setUnderlyingEvent(underlyingEvent);
 
     target->dispatchEvent(event, IGNORE_EXCEPTION);
@@ -3360,7 +3361,7 @@
 
     if (!m_frame->editor()->behavior().shouldNavigateBackOnBackspace())
         return;
-    
+
     Page* page = m_frame->page();
     if (!page)
         return;
@@ -3368,9 +3369,9 @@
     bool handledEvent = false;
 
     if (event->shiftKey())
-        handledEvent = page->goForward();
+        handledEvent = page->backForward()->goForward();
     else
-        handledEvent = page->goBack();
+        handledEvent = page->backForward()->goBack();
 
     if (handledEvent)
         event->setDefaultHandled();
@@ -3426,9 +3427,8 @@
 
 void EventHandler::capsLockStateMayHaveChanged()
 {
-    Document* d = m_frame->document();
-    if (Node* node = d->focusedNode()) {
-        if (RenderObject* r = node->renderer()) {
+    if (Element* element = m_frame->document()->focusedElement()) {
+        if (RenderObject* r = element->renderer()) {
             if (r->isTextField())
                 toRenderTextControlSingleLine(r)->capsLockStateMayHaveChanged();
         }
diff --git a/Source/core/page/FocusController.cpp b/Source/core/page/FocusController.cpp
index 7d62f6f..e7f43b9 100644
--- a/Source/core/page/FocusController.cpp
+++ b/Source/core/page/FocusController.cpp
@@ -118,11 +118,11 @@
             return;
     }
 
-    if (!focused && document->focusedNode())
-        document->focusedNode()->dispatchBlurEvent(0);
+    if (!focused && document->focusedElement())
+        document->focusedElement()->dispatchBlurEvent(0);
     document->dispatchWindowEvent(Event::create(focused ? eventNames().focusEvent : eventNames().blurEvent, false, false));
-    if (focused && document->focusedNode())
-        document->focusedNode()->dispatchFocusEvent(0, FocusDirectionNone);
+    if (focused && document->focusedElement())
+        document->focusedElement()->dispatchFocusEvent(0, FocusDirectionNone);
 }
 
 static inline bool hasCustomFocusLogic(Node* node)
@@ -282,7 +282,7 @@
     ASSERT(frame);
     Document* document = frame->document();
 
-    Node* currentNode = document->focusedNode();
+    Node* currentNode = document->focusedElement();
     // FIXME: Not quite correct when it comes to focus transitions leaving/entering the WebView itself
     bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEnabled();
 
@@ -312,7 +312,7 @@
 
     ASSERT(node);
 
-    if (node == document->focusedNode())
+    if (node == document->focusedElement())
         // Focus wrapped around to the same node.
         return true;
 
@@ -582,12 +582,12 @@
     RefPtr<Frame> oldFocusedFrame = focusedFrame();
     RefPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame->document() : 0;
     
-    Node* oldFocusedNode = oldDocument ? oldDocument->focusedNode() : 0;
-    if (oldFocusedNode == element)
+    Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : 0;
+    if (oldFocusedElement == element)
         return true;
 
     // FIXME: Might want to disable this check for caretBrowsing
-    if (oldFocusedNode && oldFocusedNode->isRootEditableElement() && !relinquishesEditingFocus(oldFocusedNode))
+    if (oldFocusedElement && oldFocusedElement->isRootEditableElement() && !relinquishesEditingFocus(oldFocusedElement))
         return false;
 
     m_page->editorClient()->willSetInputMethodState();
@@ -602,7 +602,7 @@
 
     RefPtr<Document> newDocument = element->document();
 
-    if (newDocument && newDocument->focusedNode() == element)
+    if (newDocument && newDocument->focusedElement() == element)
         return true;
     
     if (oldDocument && oldDocument != newDocument)
@@ -734,18 +734,18 @@
 void FocusController::findFocusCandidateInContainer(Node* container, const LayoutRect& startingRect, FocusDirection direction, KeyboardEvent* event, FocusCandidate& closest)
 {
     ASSERT(container);
-    Node* focusedNode = (focusedFrame() && focusedFrame()->document()) ? focusedFrame()->document()->focusedNode() : 0;
+    Element* focusedElement = (focusedFrame() && focusedFrame()->document()) ? focusedFrame()->document()->focusedElement() : 0;
 
     Element* element = ElementTraversal::firstWithin(container);
     FocusCandidate current;
     current.rect = startingRect;
-    current.focusableNode = focusedNode;
-    current.visibleNode = focusedNode;
+    current.focusableNode = focusedElement;
+    current.visibleNode = focusedElement;
 
     for (; element; element = (element->isFrameOwnerElement() || canScrollInDirection(element, direction))
         ? ElementTraversal::nextSkippingChildren(element, container)
         : ElementTraversal::next(element, container)) {
-        if (element == focusedNode)
+        if (element == focusedElement)
             continue;
 
         if (!element->isKeyboardFocusable(event) && !element->isFrameOwnerElement() && !canScrollInDirection(element, direction))
@@ -793,9 +793,9 @@
         }
         // Navigate into a new frame.
         LayoutRect rect;
-        Node* focusedNode = focusedOrMainFrame()->document()->focusedNode();
-        if (focusedNode && !hasOffscreenRect(focusedNode))
-            rect = nodeRectInAbsoluteCoordinates(focusedNode, true /* ignore border */);
+        Element* focusedElement = focusedOrMainFrame()->document()->focusedElement();
+        if (focusedElement && !hasOffscreenRect(focusedElement))
+            rect = nodeRectInAbsoluteCoordinates(focusedElement, true /* ignore border */);
         frameElement->contentFrame()->document()->updateLayoutIgnorePendingStylesheets();
         if (!advanceFocusDirectionallyInContainer(frameElement->contentFrame()->document(), rect, direction, event)) {
             // The new frame had nothing interesting, need to find another candidate.
@@ -811,9 +811,9 @@
         }
         // Navigate into a new scrollable container.
         LayoutRect startingRect;
-        Node* focusedNode = focusedOrMainFrame()->document()->focusedNode();
-        if (focusedNode && !hasOffscreenRect(focusedNode))
-            startingRect = nodeRectInAbsoluteCoordinates(focusedNode, true);
+        Element* focusedElement = focusedOrMainFrame()->document()->focusedElement();
+        if (focusedElement && !hasOffscreenRect(focusedElement))
+            startingRect = nodeRectInAbsoluteCoordinates(focusedElement, true);
         return advanceFocusDirectionallyInContainer(focusCandidate.visibleNode, startingRect, direction, event);
     }
     if (focusCandidate.isOffscreenAfterScrolling) {
@@ -839,7 +839,7 @@
     if (!focusedDocument)
         return false;
 
-    Node* focusedNode = focusedDocument->focusedNode();
+    Element* focusedElement = focusedDocument->focusedElement();
     Node* container = focusedDocument;
 
     if (container->isDocumentNode())
@@ -847,12 +847,12 @@
         
     // Figure out the starting rect.
     LayoutRect startingRect;
-    if (focusedNode) {
-        if (!hasOffscreenRect(focusedNode)) {
-            container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direction, focusedNode);
-            startingRect = nodeRectInAbsoluteCoordinates(focusedNode, true /* ignore border */);
-        } else if (isHTMLAreaElement(focusedNode)) {
-            HTMLAreaElement* area = toHTMLAreaElement(focusedNode);
+    if (focusedElement) {
+        if (!hasOffscreenRect(focusedElement)) {
+            container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direction, focusedElement);
+            startingRect = nodeRectInAbsoluteCoordinates(focusedElement, true /* ignore border */);
+        } else if (isHTMLAreaElement(focusedElement)) {
+            HTMLAreaElement* area = toHTMLAreaElement(focusedElement);
             container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direction, area->imageElement());
             startingRect = virtualRectForAreaElementAndDirection(area, direction);
         }
diff --git a/Source/core/page/Frame.cpp b/Source/core/page/Frame.cpp
index 5aa82a6..1645d7c 100644
--- a/Source/core/page/Frame.cpp
+++ b/Source/core/page/Frame.cpp
@@ -347,6 +347,9 @@
 
 void Frame::willDetachPage()
 {
+    // We should never be detatching the page during a Layout.
+    RELEASE_ASSERT(!m_view || !m_view->isInLayout());
+
     if (Frame* parent = tree()->parent())
         parent->loader()->checkLoadComplete();
 
@@ -365,6 +368,13 @@
     script()->clearScriptObjects();
 }
 
+void Frame::detachFromPage()
+{
+    // We should never be detatching the page during a Layout.
+    RELEASE_ASSERT(!m_view || !m_view->isInLayout());
+    m_page = 0;
+}
+
 void Frame::disconnectOwnerElement()
 {
     if (m_ownerElement) {
diff --git a/Source/core/page/Frame.h b/Source/core/page/Frame.h
index 0e1343c..ca10068 100644
--- a/Source/core/page/Frame.h
+++ b/Source/core/page/Frame.h
@@ -98,7 +98,7 @@
         FrameTree* tree() const;
         AnimationController* animation() const;
         ScriptController* script();
-        
+
         RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame.
         RenderPart* ownerRenderer() const; // Renderer for the element that contains this frame.
 
@@ -260,11 +260,6 @@
         return m_page;
     }
 
-    inline void Frame::detachFromPage()
-    {
-        m_page = 0;
-    }
-
     inline EventHandler* Frame::eventHandler() const
     {
         return m_eventHandler.get();
diff --git a/Source/core/page/FrameView.cpp b/Source/core/page/FrameView.cpp
index db745bc..26badff 100644
--- a/Source/core/page/FrameView.cpp
+++ b/Source/core/page/FrameView.cpp
@@ -290,6 +290,7 @@
 
 void FrameView::clearFrame()
 {
+    RELEASE_ASSERT(!isInLayout());
     m_frame = 0;
 }
 
@@ -338,6 +339,8 @@
 
 void FrameView::prepareForDetach()
 {
+    RELEASE_ASSERT(!isInLayout());
+
     detachCustomScrollbars();
     // When the view is no longer associated with a frame, it needs to be removed from the ax object cache
     // right now, otherwise it won't be able to reach the topDocument()'s axObject cache later.
@@ -859,6 +862,11 @@
 
 void FrameView::layout(bool allowSubtree)
 {
+    // We should never layout a Document which is not in a Frame.
+    ASSERT(m_frame);
+    ASSERT(m_frame->view() == this);
+    ASSERT(m_frame->page());
+
     if (m_inLayout)
         return;
 
@@ -875,13 +883,6 @@
     m_delayedLayout = false;
     m_setNeedsLayoutWasDeferred = false;
 
-    if (!m_frame) {
-        // FIXME: Do we need to set m_size.width here?
-        // FIXME: Should we set m_size.height here too?
-        m_size.setWidth(layoutWidth());
-        return;
-    }
-
     // we shouldn't enter layout() while painting
     ASSERT(!isPainting());
     if (isPainting())
@@ -894,18 +895,15 @@
         m_layoutRoot = 0;
     }
 
-    ASSERT(m_frame->view() == this);
-
     Document* document = m_frame->document();
-    bool subtree;
-    RenderObject* root;
+    bool inSubtreeLayout = false;
+    RenderObject* rootForThisLayout = 0;
 
     {
         TemporaryChange<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled, false);
 
         if (!m_nestedLayoutCount && !m_inSynchronousPostLayout && m_postLayoutTasksTimer.isActive() && !frame()->document()->shouldDisplaySeamlesslyWithParent()) {
-            // This is a new top-level layout. If there are any remaining tasks from the previous
-            // layout, finish them now.
+            // This is a new top-level layout. If there are any remaining tasks from the previous layout, finish them now.
             m_inSynchronousPostLayout = true;
             performPostLayoutTasks();
             m_inSynchronousPostLayout = false;
@@ -922,15 +920,15 @@
         TemporaryChange<bool> changeDoingPreLayoutStyleUpdate(m_doingPreLayoutStyleUpdate, true);
         document->updateStyleIfNeeded();
 
-        subtree = m_layoutRoot;
+        inSubtreeLayout = m_layoutRoot;
 
         // If there is only one ref to this view left, then its going to be destroyed as soon as we exit,
         // so there's no point to continuing to layout
         if (protector->hasOneRef())
             return;
 
-        root = subtree ? m_layoutRoot : document->renderer();
-        if (!root) {
+        rootForThisLayout = inSubtreeLayout ? m_layoutRoot : document->renderer();
+        if (!rootForThisLayout) {
             // FIXME: Do we need to set m_size here?
             return;
         }
@@ -945,28 +943,15 @@
 
         m_nestedLayoutCount++;
 
-        if (!m_layoutRoot) {
-            Document* document = m_frame->document();
-            Node* body = document->body();
-            if (body && body->renderer()) {
-                if (body->hasTagName(framesetTag)) {
-                    body->renderer()->setChildNeedsLayout(true);
-                } else if (body->hasTagName(bodyTag)) {
-                    if (!m_firstLayout && m_size.height() != layoutHeight() && body->renderer()->enclosingBox()->stretchesToViewport())
-                        body->renderer()->setChildNeedsLayout(true);
-                }
-            }
-        }
-
         autoSizeIfEnabled();
 
         ScrollbarMode hMode;
         ScrollbarMode vMode;
         calculateScrollbarModesForLayout(hMode, vMode);
 
-        m_doFullRepaint = !subtree && (m_firstLayout || toRenderView(root)->printing());
+        m_doFullRepaint = !inSubtreeLayout && (m_firstLayout || toRenderView(rootForThisLayout)->printing());
 
-        if (!subtree) {
+        if (!inSubtreeLayout) {
             // Now set our scrollbar state for the layout.
             ScrollbarMode currentHMode = horizontalScrollbarMode();
             ScrollbarMode currentVMode = verticalScrollbarMode();
@@ -978,7 +963,7 @@
                     m_firstLayout = false;
                     m_firstLayoutCallbackPending = true;
                     m_lastViewportSize = layoutSize(IncludeScrollbars);
-                    m_lastZoomFactor = root->style()->zoom();
+                    m_lastZoomFactor = rootForThisLayout->style()->zoom();
 
                     // Set the initial vMode to AlwaysOn if we're auto.
                     if (vMode == ScrollbarAuto)
@@ -1010,42 +995,42 @@
             }
         }
 
-        layer = root->enclosingLayer();
+        layer = rootForThisLayout->enclosingLayer();
 
         m_actionScheduler->pause();
 
         {
             bool disableLayoutState = false;
-            if (subtree) {
-                RenderView* view = root->view();
-                disableLayoutState = view->shouldDisableLayoutStateForSubtree(root);
-                view->pushLayoutState(root);
+            if (inSubtreeLayout) {
+                RenderView* view = rootForThisLayout->view();
+                disableLayoutState = view->shouldDisableLayoutStateForSubtree(rootForThisLayout);
+                view->pushLayoutState(rootForThisLayout);
             }
-            LayoutStateDisabler layoutStateDisabler(disableLayoutState ? root->view() : 0);
+            LayoutStateDisabler layoutStateDisabler(disableLayoutState ? rootForThisLayout->view() : 0);
 
             m_inLayout = true;
             beginDeferredRepaints();
             forceLayoutParentViewIfNeeded();
-            root->layout();
+            rootForThisLayout->layout();
 
-            bool autosized = document->textAutosizer()->processSubtree(root);
-            if (autosized && root->needsLayout()) {
+            bool autosized = document->textAutosizer()->processSubtree(rootForThisLayout);
+            if (autosized && rootForThisLayout->needsLayout()) {
                 TRACE_EVENT0("webkit", "2nd layout due to Text Autosizing");
-                root->layout();
+                rootForThisLayout->layout();
             }
 
             endDeferredRepaints();
             m_inLayout = false;
 
-            if (subtree)
-                root->view()->popLayoutState(root);
+            if (inSubtreeLayout)
+                rootForThisLayout->view()->popLayoutState(rootForThisLayout);
         }
         m_layoutRoot = 0;
     } // Reset m_layoutSchedulingEnabled to its previous value.
 
     bool neededFullRepaint = m_doFullRepaint;
 
-    if (!subtree && !toRenderView(root)->printing())
+    if (!inSubtreeLayout && !toRenderView(rootForThisLayout)->printing())
         adjustViewSize();
 
     m_doFullRepaint = neededFullRepaint;
@@ -1053,10 +1038,10 @@
     // Now update the positions of all layers.
     beginDeferredRepaints();
     if (m_doFullRepaint)
-        root->view()->repaint(); // FIXME: This isn't really right, since the RenderView doesn't fully encompass the visibleContentRect(). It just happens
+        rootForThisLayout->view()->repaint(); // FIXME: This isn't really right, since the RenderView doesn't fully encompass the visibleContentRect(). It just happens
                                  // to work out most of the time, since first layouts and printing don't have you scrolled anywhere.
 
-    layer->updateLayerPositionsAfterLayout(renderView()->layer(), updateLayerPositionFlags(layer, subtree, m_doFullRepaint));
+    layer->updateLayerPositionsAfterLayout(renderView()->layer(), updateLayerPositionFlags(layer, inSubtreeLayout, m_doFullRepaint));
 
     endDeferredRepaints();
 
@@ -1064,19 +1049,18 @@
 
     m_layoutCount++;
 
-    if (AXObjectCache* cache = root->document()->existingAXObjectCache())
-        cache->postNotification(root, AXObjectCache::AXLayoutComplete, true);
+    if (AXObjectCache* cache = rootForThisLayout->document()->existingAXObjectCache())
+        cache->postNotification(rootForThisLayout, AXObjectCache::AXLayoutComplete, true);
     updateAnnotatedRegions();
 
     layoutLazyBlocks();
 
-    ASSERT(!root->needsLayout());
+    ASSERT(!rootForThisLayout->needsLayout());
 
     updateCanBlitOnScrollRecursively();
 
     if (document->hasListenerType(Document::OVERFLOWCHANGED_LISTENER))
-        updateOverflowStatus(layoutWidth() < contentsWidth(),
-                             layoutHeight() < contentsHeight());
+        updateOverflowStatus(layoutWidth() < contentsWidth(), layoutHeight() < contentsHeight());
 
     if (!m_postLayoutTasksTimer.isActive()) {
         if (!m_inSynchronousPostLayout) {
@@ -1106,17 +1090,21 @@
         m_actionScheduler->resume();
     }
 
-    InspectorInstrumentation::didLayout(cookie, root);
+    InspectorInstrumentation::didLayout(cookie, rootForThisLayout);
 
     m_nestedLayoutCount--;
     if (m_nestedLayoutCount)
         return;
 
-    Page* page = frame() ? frame()->page() : 0;
-    if (!page)
-        return;
-
-    page->chrome().client()->layoutUpdated(frame());
+    // FIXME: It should be not possible to remove the FrameView from the frame/page during layout
+    // however m_inLayout is not set for most of this function, so none of our RELEASE_ASSERTS
+    // in Frame/Page will fire. One of the post-layout tasks is disconnecting the Frame from
+    // the page in fast/frames/crash-remove-iframe-during-object-beforeload-2.html
+    // necessitating this check here.
+    ASSERT(frame());
+    // ASSERT(frame()->page());
+    if (frame() && frame()->page())
+        frame()->page()->chrome().client()->layoutUpdated(frame());
 }
 
 void FrameView::layoutLazyBlocks()
diff --git a/Source/core/page/Location.cpp b/Source/core/page/Location.cpp
index 3a78903..d1101fa 100644
--- a/Source/core/page/Location.cpp
+++ b/Source/core/page/Location.cpp
@@ -242,21 +242,13 @@
     if (!m_frame)
         return;
     // Note: We call DOMWindow::setLocation directly here because replace() always operates on the current frame.
-    m_frame->document()->domWindow()->setLocation(url, activeWindow, firstWindow, LockHistoryAndBackForwardList);
+    m_frame->domWindow()->setLocation(url, activeWindow, firstWindow, LockHistoryAndBackForwardList);
 }
 
 void Location::reload(DOMWindow* activeWindow)
 {
     if (!m_frame)
         return;
-    // FIXME: It's not clear this cross-origin security check is valuable.
-    // We allow one page to change the location of another. Why block attempts to reload?
-    // Other location operations simply block use of JavaScript URLs cross origin.
-    DOMWindow* targetWindow = m_frame->document()->domWindow();
-    if (!activeWindow->document()->securityOrigin()->canAccess(m_frame->document()->securityOrigin())) {
-        targetWindow->printErrorMessage(targetWindow->crossDomainAccessErrorMessage(activeWindow));
-        return;
-    }
     if (protocolIsJavaScript(m_frame->document()->url()))
         return;
     m_frame->navigationScheduler()->scheduleRefresh();
@@ -269,7 +261,7 @@
     Frame* frame = m_frame->loader()->findFrameForNavigation(String(), activeWindow->document());
     if (!frame)
         return;
-    frame->document()->domWindow()->setLocation(url, activeWindow, firstWindow);
+    frame->domWindow()->setLocation(url, activeWindow, firstWindow);
 }
 
 } // namespace WebCore
diff --git a/Source/core/page/Location.idl b/Source/core/page/Location.idl
index c4d6693..842d462 100644
--- a/Source/core/page/Location.idl
+++ b/Source/core/page/Location.idl
@@ -33,7 +33,7 @@
 
     [CallWith=ActiveWindow&FirstWindow, DoNotCheckSecurity, Unforgeable, ReadOnly, PerWorldBindings, ActivityLog=AccessForIsolatedWorlds] void assign([Default=Undefined] optional DOMString url);
     [CallWith=ActiveWindow&FirstWindow, DoNotCheckSecurity, Unforgeable, ReadOnly, PerWorldBindings, ActivityLog=AccessForIsolatedWorlds] void replace([Default=Undefined] optional DOMString url);
-    [CallWith=ActiveWindow, DoNotCheckSecurity, Unforgeable, ReadOnly] void reload();
+    [CallWith=ActiveWindow, Unforgeable, ReadOnly] void reload();
 
     // URI decomposition attributes
     [SetterCallWith=ActiveWindow&FirstWindow, SetterRaisesException] attribute DOMString protocol;
diff --git a/Source/core/page/Page.cpp b/Source/core/page/Page.cpp
index 7f3c393..bf99a97 100644
--- a/Source/core/page/Page.cpp
+++ b/Source/core/page/Page.cpp
@@ -111,11 +111,9 @@
     , m_openedByDOM(false)
     , m_tabKeyCyclesThroughElements(true)
     , m_defersLoading(false)
-    , m_defersLoadingCallCount(0)
     , m_pageScaleFactor(1)
     , m_deviceScaleFactor(1)
     , m_didLoadUserStyleSheet(false)
-    , m_userStyleSheetModificationTime(0)
     , m_group(0)
     , m_timerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval())
     , m_visibilityState(PageVisibilityStateVisible)
@@ -289,50 +287,6 @@
     m_openedByDOM = true;
 }
 
-bool Page::goBack()
-{
-    HistoryItem* item = backForward()->backItem();
-
-    if (item) {
-        goToItem(item);
-        return true;
-    }
-    return false;
-}
-
-bool Page::goForward()
-{
-    HistoryItem* item = backForward()->forwardItem();
-
-    if (item) {
-        goToItem(item);
-        return true;
-    }
-    return false;
-}
-
-void Page::goBackOrForward(int distance)
-{
-    if (distance == 0)
-        return;
-
-    HistoryItem* item = backForward()->itemAtIndex(distance);
-    if (!item) {
-        if (distance > 0) {
-            if (int forwardCount = backForward()->forwardCount())
-                item = backForward()->itemAtIndex(forwardCount);
-        } else {
-            if (int backCount = backForward()->backCount())
-                item = backForward()->itemAtIndex(-backCount);
-        }
-    }
-
-    if (!item)
-        return;
-
-    goToItem(item);
-}
-
 void Page::goToItem(HistoryItem* item)
 {
     // stopAllLoaders may end up running onload handlers, which could cause further history traversals that may lead to the passed in HistoryItem
@@ -345,11 +299,6 @@
     m_mainFrame->loader()->history()->goToItem(item);
 }
 
-int Page::getHistoryLength()
-{
-    return backForward()->backCount() + 1 + backForward()->forwardCount();
-}
-
 void Page::clearPageGroup()
 {
     if (!m_group)
@@ -453,7 +402,6 @@
 
 void Page::setDefersLoading(bool defers)
 {
-    ASSERT(!m_defersLoadingCallCount);
     if (defers == m_defersLoading)
         return;
 
@@ -517,7 +465,6 @@
 
     m_didLoadUserStyleSheet = false;
     m_userStyleSheet = String();
-    m_userStyleSheetModificationTime = 0;
 
     // Data URLs with base64-encoded UTF-8 style sheets are common. We can process them
     // synchronously and avoid using a loader.
diff --git a/Source/core/page/Page.h b/Source/core/page/Page.h
index 9f93136..0e986a9 100644
--- a/Source/core/page/Page.h
+++ b/Source/core/page/Page.h
@@ -35,10 +35,6 @@
 #include "wtf/Noncopyable.h"
 #include "wtf/text/WTFString.h"
 
-#if OS(SOLARIS)
-#include <sys/time.h> // For time_t structure.
-#endif
-
 namespace WebCore {
 
 class AutoscrollController;
@@ -137,12 +133,7 @@
     bool openedByDOM() const;
     void setOpenedByDOM();
 
-    // DEPRECATED. Use backForward() instead of the following 5 functions.
-    bool goBack();
-    bool goForward();
-    void goBackOrForward(int distance);
-    int getHistoryLength();
-
+    // DEPRECATED. Use backForward() instead of the following function.
     void goToItem(HistoryItem*);
 
     // FIXME: InspectorPageGroup is only needed to support single process debugger layout tests, it should be removed when DumpRenderTree is gone.
@@ -311,7 +302,6 @@
 
     bool m_tabKeyCyclesThroughElements;
     bool m_defersLoading;
-    unsigned m_defersLoadingCallCount;
 
     float m_pageScaleFactor;
     float m_deviceScaleFactor;
@@ -320,7 +310,6 @@
 
     mutable String m_userStyleSheet;
     mutable bool m_didLoadUserStyleSheet;
-    mutable time_t m_userStyleSheetModificationTime;
 
     RefPtr<PageGroup> m_group;
 
diff --git a/Source/core/page/RuntimeEnabledFeatures.in b/Source/core/page/RuntimeEnabledFeatures.in
index 1f2edbb..884debe 100644
--- a/Source/core/page/RuntimeEnabledFeatures.in
+++ b/Source/core/page/RuntimeEnabledFeatures.in
@@ -30,7 +30,7 @@
 CustomDOMElements status=experimental
 Database status=stable
 DataListElement status=stable
-DeviceMotion
+DeviceMotion status=test
 DeviceOrientation status=stable
 DialogElement status=experimental
 DirectoryUpload status=stable
diff --git a/Source/core/page/Window.idl b/Source/core/page/Window.idl
index e26d2db..f15f3e4 100644
--- a/Source/core/page/Window.idl
+++ b/Source/core/page/Window.idl
@@ -180,10 +180,6 @@
     [ImplementedAs=cancelAnimationFrame] void webkitCancelAnimationFrame(long id);
     [ImplementedAs=cancelAnimationFrame] void webkitCancelRequestAnimationFrame(long id); // This is a deprecated alias for webkitCancelAnimationFrame(). Remove this when removing vendor prefix.
 
-    // Base64
-    [RaisesException] DOMString atob([TreatNullAs=NullString,Default=Undefined] optional DOMString string);
-    [RaisesException] DOMString btoa([TreatNullAs=NullString,Default=Undefined] optional DOMString string);
-
     [Replaceable] readonly attribute CSS CSS;
 
     // Events
@@ -193,40 +189,40 @@
     attribute EventListener oncanplay;
     attribute EventListener oncanplaythrough;
     attribute EventListener onchange;
-    attribute EventListener onclick;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onclick;
     attribute EventListener oncontextmenu;
-    attribute EventListener ondblclick;
-    attribute EventListener ondrag;
-    attribute EventListener ondragend;
-    attribute EventListener ondragenter;
-    attribute EventListener ondragleave;
-    attribute EventListener ondragover;
-    attribute EventListener ondragstart;
-    attribute EventListener ondrop;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondblclick;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondrag;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragend;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragenter;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragleave;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragover;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondragstart;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener ondrop;
     attribute EventListener ondurationchange;
     attribute EventListener onemptied;
     attribute EventListener onended;
     attribute EventListener onerror;
     attribute EventListener onfocus;
     attribute EventListener onhashchange;
-    attribute EventListener oninput;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener oninput;
     attribute EventListener oninvalid;
-    attribute EventListener onkeydown;
-    attribute EventListener onkeypress;
-    attribute EventListener onkeyup;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onkeydown;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onkeypress;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onkeyup;
     attribute EventListener onload;
     attribute EventListener onloadeddata;
     attribute EventListener onloadedmetadata;
     attribute EventListener onloadstart;
     attribute EventListener onmessage;
-    attribute EventListener onmousedown;
-    attribute EventListener onmouseenter;
-    attribute EventListener onmouseleave;
-    attribute EventListener onmousemove;
-    attribute EventListener onmouseout;
-    attribute EventListener onmouseover;
-    attribute EventListener onmouseup;
-    attribute EventListener onmousewheel;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmousedown;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseenter;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseleave;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmousemove;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseout;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseover;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmouseup;
+    [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventListener onmousewheel;
     attribute EventListener onoffline;
     attribute EventListener ononline;
     attribute EventListener onpagehide;
@@ -315,4 +311,4 @@
 };
 
 Window implements WindowTimers;
-
+Window implements WindowBase64;
diff --git a/Source/core/page/WindowBase64.idl b/Source/core/page/WindowBase64.idl
new file mode 100644
index 0000000..e27a93b
--- /dev/null
+++ b/Source/core/page/WindowBase64.idl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Samsung Electronics. 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.
+ */
+
+[
+    NoInterfaceObject,
+    ImplementedAs=DOMWindowBase64
+] interface WindowBase64 {
+    [RaisesException] DOMString atob(DOMString string);
+    [RaisesException] DOMString btoa(DOMString string);
+};
diff --git a/Source/core/page/WindowTimers.idl b/Source/core/page/WindowTimers.idl
index 97d5d42..744567d 100644
--- a/Source/core/page/WindowTimers.idl
+++ b/Source/core/page/WindowTimers.idl
@@ -26,7 +26,8 @@
  */
 
 [
-    NoInterfaceObject
+    NoInterfaceObject,
+    ImplementedAs=DOMWindowTimers
 ] interface WindowTimers {
     [Custom] long setTimeout(any handler, [Default=Undefined] optional long timeout);
     void clearTimeout([Default=Undefined] optional long handle);
diff --git a/Source/core/page/animation/CSSPropertyAnimation.cpp b/Source/core/page/animation/CSSPropertyAnimation.cpp
index c1f4152..9eba320 100644
--- a/Source/core/page/animation/CSSPropertyAnimation.cpp
+++ b/Source/core/page/animation/CSSPropertyAnimation.cpp
@@ -32,10 +32,10 @@
 
 #include <algorithm>
 #include "CSSPropertyNames.h"
+#include "StylePropertyShorthand.h"
 #include "core/css/CSSCrossfadeValue.h"
 #include "core/css/CSSImageValue.h"
 #include "core/css/CSSPrimitiveValue.h"
-#include "core/css/StylePropertyShorthand.h"
 #include "core/loader/cache/CachedImage.h"
 #include "core/page/animation/AnimationBase.h"
 #include "core/platform/FloatConversion.h"
diff --git a/Source/core/page/scrolling/ScrollingCoordinator.cpp b/Source/core/page/scrolling/ScrollingCoordinator.cpp
index 87829b1..323298d 100644
--- a/Source/core/page/scrolling/ScrollingCoordinator.cpp
+++ b/Source/core/page/scrolling/ScrollingCoordinator.cpp
@@ -27,18 +27,23 @@
 
 #include "core/page/scrolling/ScrollingCoordinator.h"
 
+#include "RuntimeEnabledFeatures.h"
 #include "core/dom/Document.h"
+#include "core/dom/Node.h"
+#include "core/html/HTMLElement.h"
 #include "core/page/Frame.h"
 #include "core/page/FrameView.h"
 #include "core/page/Page.h"
 #include "core/platform/PlatformWheelEvent.h"
 #include "core/platform/ScrollAnimator.h"
 #include "core/platform/ScrollbarThemeComposite.h"
+#include "core/platform/chromium/TraceEvent.h"
 #include "core/platform/chromium/support/WebScrollbarImpl.h"
 #include "core/platform/chromium/support/WebScrollbarThemeGeometryNative.h"
 #include "core/platform/graphics/GraphicsLayer.h"
 #include "core/platform/graphics/IntRect.h"
 #include "core/platform/graphics/Region.h"
+#include "core/platform/graphics/transforms/TransformState.h"
 #include "core/plugins/PluginView.h"
 #include "core/rendering/RenderLayerBacking.h"
 #include "core/rendering/RenderLayerCompositor.h"
@@ -91,6 +96,12 @@
 
 }
 
+bool ScrollingCoordinator::touchHitTestingEnabled() const
+{
+    RenderView* contentRenderer = m_page->mainFrame()->contentRenderer();
+    return RuntimeEnabledFeatures::touchEnabled() && contentRenderer && contentRenderer->usesCompositing();
+}
+
 void ScrollingCoordinator::setShouldHandleScrollGestureOnMainThreadRegion(const Region& region)
 {
     if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainFrame()->view())) {
@@ -104,7 +115,10 @@
 
 void ScrollingCoordinator::frameViewLayoutUpdated(FrameView* frameView)
 {
-    ASSERT(m_page);
+    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:
@@ -116,8 +130,8 @@
     // 3. Plugin areas.
     Region shouldHandleScrollGestureOnMainThreadRegion = computeShouldHandleScrollGestureOnMainThreadRegion(m_page->mainFrame(), IntPoint());
     setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGestureOnMainThreadRegion);
-    Vector<IntRect> touchEventTargetRects;
-    computeAbsoluteTouchEventTargetRects(m_page->mainFrame()->document(), touchEventTargetRects);
+    LayerHitTestRects touchEventTargetRects;
+    computeTouchEventTargetRects(touchEventTargetRects);
     setTouchEventTargetRects(touchEventTargetRects);
     if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(frameView))
         scrollLayer->setBounds(frameView->contentsSize());
@@ -296,28 +310,92 @@
     return !!webLayer;
 }
 
-void ScrollingCoordinator::setTouchEventTargetRects(const Vector<IntRect>& absoluteHitTestRects)
+static void convertLayerRectsToEnclosingCompositedLayer(const LayerHitTestRects& layerRects, LayerHitTestRects& compositorRects)
 {
-    if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainFrame()->view())) {
-        WebVector<WebRect> webRects(absoluteHitTestRects.size());
-        for (size_t i = 0; i < absoluteHitTestRects.size(); ++i)
-            webRects[i] = absoluteHitTestRects[i];
-        scrollLayer->setTouchEventHandlerRegion(webRects);
+    // We have a set of rects per RenderLayer, we need to map them to their bounding boxes in their
+    // enclosing composited layer.
+    for (LayerHitTestRects::const_iterator layerIter = layerRects.begin(); layerIter != layerRects.end(); ++layerIter) {
+        // Find the enclosing composited layer when it's in another document (for non-composited iframes).
+        RenderLayer* compositedLayer = 0;
+        for (const RenderLayer* layer = layerIter->key; !compositedLayer;) {
+            compositedLayer = layer->enclosingCompositingLayerForRepaint();
+            if (!compositedLayer) {
+                RenderObject* owner = layer->renderer()->frame()->ownerRenderer();
+                if (!owner)
+                    break;
+                layer = owner->enclosingLayer();
+            }
+        }
+        if (!compositedLayer) {
+            // Since this machinery is used only when accelerated compositing is enabled, we expect
+            // that every layer should have an enclosing composited layer.
+            ASSERT_NOT_REACHED();
+            continue;
+        }
+
+        LayerHitTestRects::iterator compIter = compositorRects.find(compositedLayer);
+        if (compIter == compositorRects.end())
+            compIter = compositorRects.add(compositedLayer, Vector<LayoutRect>()).iterator;
+
+        // Transform each rect to the co-ordinate space of it's enclosing composited layer.
+        // Ideally we'd compute a transformation matrix once and re-use it for each rect, but
+        // there doesn't appear to be any easy way to do it (mapLocalToContainer will flatten
+        // the TransformState, so we can't use setQuad/mappedQuad over and over again). Perhaps
+        // RenderGeometryMap?
+        for (size_t i = 0; i < layerIter->value.size(); ++i) {
+            FloatQuad localQuad(layerIter->value[i]);
+            TransformState transformState(TransformState::ApplyTransformDirection, localQuad);
+            MapCoordinatesFlags flags = ApplyContainerFlip | UseTransforms | TraverseDocumentBoundaries;
+            layerIter->key->renderer()->mapLocalToContainer(compositedLayer->renderer(), transformState, flags);
+            transformState.flatten();
+            LayoutRect compositorRect = LayoutRect(transformState.lastPlanarQuad().boundingBox());
+            compIter->value.append(compositorRect);
+        }
+    }
+}
+
+void ScrollingCoordinator::setTouchEventTargetRects(const LayerHitTestRects& layerRects)
+{
+    TRACE_EVENT0("input", "ScrollingCoordinator::setTouchEventTargetRects");
+
+    LayerHitTestRects compositorRects;
+    convertLayerRectsToEnclosingCompositedLayer(layerRects, compositorRects);
+
+    // Inform any observers (i.e. for testing) of these new rects.
+    HashSet<TouchEventTargetRectsObserver*>::iterator stop = m_touchEventTargetRectsObservers.end();
+    for (HashSet<TouchEventTargetRectsObserver*>::iterator it = m_touchEventTargetRectsObservers.begin(); it != stop; ++it)
+        (*it)->touchEventTargetRectsChanged(compositorRects);
+
+    // Note that ideally we'd clear the touch event handler region on all layers first,
+    // in case there are others that no longer have any handlers. But it's unlikely to
+    // matter much in practice (just makes us more conservative).
+    for (LayerHitTestRects::const_iterator iter = compositorRects.begin(); iter != compositorRects.end(); ++iter) {
+        WebVector<WebRect> webRects(iter->value.size());
+        for (size_t i = 0; i < iter->value.size(); ++i)
+            webRects[i] = enclosingIntRect(iter->value[i]);
+        RenderLayerBacking* backing = iter->key->backing();
+        // If the layer is using composited scrolling, then it's the contents that these
+        // rects apply to.
+        GraphicsLayer* graphicsLayer = backing->scrollingContentsLayer();
+        if (!graphicsLayer)
+            graphicsLayer = backing->graphicsLayer();
+        graphicsLayer->platformLayer()->setTouchEventHandlerRegion(webRects);
     }
 }
 
 void ScrollingCoordinator::touchEventTargetRectsDidChange(const Document*)
 {
-    // The rects are always evaluated and used in the main frame coordinates.
-    FrameView* frameView = m_page->mainFrame()->view();
-    Document* document = m_page->mainFrame()->document();
-
-    // Wait until after layout to update.
-    if (frameView->needsLayout() || !document)
+    if (!touchHitTestingEnabled())
         return;
 
-    Vector<IntRect> touchEventTargetRects;
-    computeAbsoluteTouchEventTargetRects(document, touchEventTargetRects);
+    // Wait until after layout to update.
+    if (m_page->mainFrame()->view()->needsLayout())
+        return;
+
+    TRACE_EVENT0("input", "ScrollingCoordinator::touchEventTargetRectsDidChange");
+
+    LayerHitTestRects touchEventTargetRects;
+    computeTouchEventTargetRects(touchEventTargetRects);
     setTouchEventTargetRects(touchEventTargetRects);
 }
 
@@ -363,6 +441,7 @@
 
 Region ScrollingCoordinator::computeShouldHandleScrollGestureOnMainThreadRegion(const Frame* frame, const IntPoint& frameLocation) const
 {
+    TRACE_EVENT0("input", "ScrollingCoordinator::computeShouldHandleScrollGestureOnMainThreadRegion");
     Region shouldHandleScrollGestureOnMainThreadRegion;
     FrameView* frameView = frame->view();
     if (!frameView)
@@ -415,75 +494,63 @@
     return shouldHandleScrollGestureOnMainThreadRegion;
 }
 
-static void accumulateRendererTouchEventTargetRects(Vector<IntRect>& rects, const RenderObject* renderer, const IntRect& parentRect = IntRect())
+void ScrollingCoordinator::addTouchEventTargetRectsObserver(TouchEventTargetRectsObserver* observer)
 {
-    IntRect adjustedParentRect = parentRect;
-    if (parentRect.isEmpty() || renderer->isFloating() || renderer->isPositioned() || renderer->hasTransform()) {
-        // FIXME: This method is O(N^2) as it walks the tree to the root for every renderer. RenderGeometryMap would fix this.
-        IntRect r = enclosingIntRect(renderer->clippedOverflowRectForRepaint(0));
-        if (!r.isEmpty()) {
-            // Convert to the top-level view's coordinates.
-            ASSERT(renderer->document()->view());
-            r = renderer->document()->view()->convertToRootView(r);
-
-            if (!parentRect.contains(r)) {
-                rects.append(r);
-                adjustedParentRect = r;
-            }
-        }
-    }
-
-    for (RenderObject* child = renderer->firstChild(); child; child = child->nextSibling())
-        accumulateRendererTouchEventTargetRects(rects, child, adjustedParentRect);
+    m_touchEventTargetRectsObservers.add(observer);
 }
 
-static void accumulateDocumentEventTargetRects(Vector<IntRect>& rects, const Document* document)
+void ScrollingCoordinator::removeTouchEventTargetRectsObserver(TouchEventTargetRectsObserver* observer)
+{
+    m_touchEventTargetRectsObservers.remove(observer);
+}
+
+static void accumulateDocumentTouchEventTargetRects(LayerHitTestRects& rects, const Document* document)
 {
     ASSERT(document);
     if (!document->touchEventTargets())
         return;
 
     const TouchEventTargetSet* targets = document->touchEventTargets();
+
+    // If there's a handler on the document, html or body element (fairly common in practice),
+    // then we can quickly mark the entire document and skip looking at any other handlers.
+    // Note that technically a handler on the body doesn't cover the whole document, but it's
+    // reasonable to be conservative and report the whole document anyway.
     for (TouchEventTargetSet::const_iterator iter = targets->begin(); iter != targets->end(); ++iter) {
-        const Node* touchTarget = iter->key;
-        if (!touchTarget->inDocument())
-            continue;
-
-        if (touchTarget == document) {
-            if (RenderView* view = document->renderView()) {
-                IntRect r;
-                if (touchTarget == document->topDocument())
-                    r = view->documentRect();
-                else
-                    r = enclosingIntRect(view->clippedOverflowRectForRepaint(0));
-
-                if (!r.isEmpty()) {
-                    ASSERT(view->document()->view());
-                    r = view->document()->view()->convertToRootView(r);
-                    rects.append(r);
-                }
+        Node* target = iter->key;
+        if (target == document || target == document->documentElement() || target == document->body()) {
+            if (RenderObject* renderer = document->renderer()) {
+                renderer->computeLayerHitTestRects(rects);
             }
             return;
         }
-
-        if (touchTarget->isDocumentNode() && touchTarget != document) {
-            accumulateDocumentEventTargetRects(rects, toDocument(touchTarget));
-            continue;
-        }
-
-        if (RenderObject* renderer = touchTarget->renderer())
-            accumulateRendererTouchEventTargetRects(rects, renderer);
     }
+
+    for (TouchEventTargetSet::const_iterator iter = targets->begin(); iter != targets->end(); ++iter) {
+        const Node* target = iter->key;
+        if (!target->inDocument())
+            continue;
+
+        if (target->isDocumentNode()) {
+            ASSERT(target != document);
+            accumulateDocumentTouchEventTargetRects(rects, toDocument(target));
+        } else if (RenderObject* renderer = target->renderer()) {
+            renderer->computeLayerHitTestRects(rects);
+        }
+    }
+
 }
 
-void ScrollingCoordinator::computeAbsoluteTouchEventTargetRects(const Document* document, Vector<IntRect>& rects)
+void ScrollingCoordinator::computeTouchEventTargetRects(LayerHitTestRects& rects)
 {
-    ASSERT(document);
-    if (!document->view())
+    TRACE_EVENT0("input", "ScrollingCoordinator::computeTouchEventTargetRects");
+    ASSERT(touchHitTestingEnabled());
+
+    Document* document = m_page->mainFrame()->document();
+    if (!document || !document->view())
         return;
 
-    // FIXME: These rects won't be properly updated if the renderers are in a sub-tree that scrolls.
-    accumulateDocumentEventTargetRects(rects, document);
+    accumulateDocumentTouchEventTargetRects(rects, document);
 }
 
 unsigned ScrollingCoordinator::computeCurrentWheelEventHandlerCount()
diff --git a/Source/core/page/scrolling/ScrollingCoordinator.h b/Source/core/page/scrolling/ScrollingCoordinator.h
index c446d36..e8e1762 100644
--- a/Source/core/page/scrolling/ScrollingCoordinator.h
+++ b/Source/core/page/scrolling/ScrollingCoordinator.h
@@ -98,12 +98,18 @@
     void updateLayerPositionConstraint(RenderLayer*);
     void touchEventTargetRectsDidChange(const Document*);
 
-    void computeAbsoluteTouchEventTargetRects(const Document*, Vector<IntRect>&);
-
     static String mainThreadScrollingReasonsAsText(MainThreadScrollingReasons);
     String mainThreadScrollingReasonsAsText() const;
     Region computeShouldHandleScrollGestureOnMainThreadRegion(const Frame*, const IntPoint& frameLocation) const;
 
+    class TouchEventTargetRectsObserver {
+    public:
+        virtual void touchEventTargetRectsChanged(const LayerHitTestRects&) = 0;
+    };
+
+    void addTouchEventTargetRectsObserver(TouchEventTargetRectsObserver*);
+    void removeTouchEventTargetRectsObserver(TouchEventTargetRectsObserver*);
+
 protected:
     explicit ScrollingCoordinator(Page*);
 
@@ -127,18 +133,22 @@
     
     static WebKit::WebLayer* scrollingWebLayerForScrollableArea(ScrollableArea*);
 
+    bool touchHitTestingEnabled() const;
     void setShouldHandleScrollGestureOnMainThreadRegion(const Region&);
-    void setTouchEventTargetRects(const Vector<IntRect>&);
+    void setTouchEventTargetRects(const LayerHitTestRects&);
+    void computeTouchEventTargetRects(LayerHitTestRects&);
     void setWheelEventHandlerCount(unsigned);
 
     WebKit::WebScrollbarLayer* addWebScrollbarLayer(ScrollableArea*, ScrollbarOrientation, PassOwnPtr<WebKit::WebScrollbarLayer>);
     WebKit::WebScrollbarLayer* getWebScrollbarLayer(ScrollableArea*, ScrollbarOrientation);
     void removeWebScrollbarLayer(ScrollableArea*, ScrollbarOrientation);
 
+
     typedef HashMap<ScrollableArea*, OwnPtr<WebKit::WebScrollbarLayer> > ScrollbarMap;
     ScrollbarMap m_horizontalScrollbars;
     ScrollbarMap m_verticalScrollbars;
 
+    HashSet<TouchEventTargetRectsObserver*> m_touchEventTargetRectsObservers;
 };
 
 } // namespace WebCore
diff --git a/Source/core/platform/Arena.cpp b/Source/core/platform/Arena.cpp
index 70c4646..fff0291 100644
--- a/Source/core/platform/Arena.cpp
+++ b/Source/core/platform/Arena.cpp
@@ -49,8 +49,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <algorithm>
-#include <wtf/Assertions.h>
-#include <wtf/FastMalloc.h>
+#include "wtf/Assertions.h"
+#include "wtf/FastMalloc.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/AsyncFileSystemCallbacks.h b/Source/core/platform/AsyncFileSystemCallbacks.h
index 8b52313..18c4961 100644
--- a/Source/core/platform/AsyncFileSystemCallbacks.h
+++ b/Source/core/platform/AsyncFileSystemCallbacks.h
@@ -35,7 +35,7 @@
 #include "core/platform/FileMetadata.h"
 #include "core/platform/network/BlobData.h"
 #include "modules/filesystem/AsyncFileWriter.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/CalculationValue.h b/Source/core/platform/CalculationValue.h
index e894574..55d5f9e 100644
--- a/Source/core/platform/CalculationValue.h
+++ b/Source/core/platform/CalculationValue.h
@@ -33,10 +33,10 @@
 
 #include "core/css/LengthFunctions.h"
 #include "core/platform/Length.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/Clock.cpp b/Source/core/platform/Clock.cpp
index 62eb19f..63dcae3 100644
--- a/Source/core/platform/Clock.cpp
+++ b/Source/core/platform/Clock.cpp
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "core/platform/Clock.h"
 
-#include <wtf/CurrentTime.h>
+#include "wtf/CurrentTime.h"
 
 using namespace WebCore;
 
diff --git a/Source/core/platform/Clock.h b/Source/core/platform/Clock.h
index b1747b8..53d2c82 100644
--- a/Source/core/platform/Clock.h
+++ b/Source/core/platform/Clock.h
@@ -26,8 +26,8 @@
 #ifndef Clock_h
 #define Clock_h
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/ColorChooserClient.h b/Source/core/platform/ColorChooserClient.h
index 3835d06..ba00ba5 100644
--- a/Source/core/platform/ColorChooserClient.h
+++ b/Source/core/platform/ColorChooserClient.h
@@ -33,9 +33,9 @@
 
 #include "core/platform/ColorChooser.h"
 #include "core/platform/graphics/IntRect.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/ContentType.h b/Source/core/platform/ContentType.h
index 175fe36..848cc1d 100644
--- a/Source/core/platform/ContentType.h
+++ b/Source/core/platform/ContentType.h
@@ -27,7 +27,7 @@
 #ifndef ContentType_h
 #define ContentType_h
 
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/ContextMenuItem.h b/Source/core/platform/ContextMenuItem.h
index 98b97fb..67cc7c4 100644
--- a/Source/core/platform/ContextMenuItem.h
+++ b/Source/core/platform/ContextMenuItem.h
@@ -27,8 +27,8 @@
 #ifndef ContextMenuItem_h
 #define ContextMenuItem_h
 
-#include <wtf/OwnPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/Cookie.h b/Source/core/platform/Cookie.h
index 27f670d..f236ef4 100644
--- a/Source/core/platform/Cookie.h
+++ b/Source/core/platform/Cookie.h
@@ -26,8 +26,8 @@
 #ifndef Cookie_h
 #define Cookie_h
 
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/text/StringHash.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/CrossThreadCopier.h b/Source/core/platform/CrossThreadCopier.h
index 3b60761..682425a 100644
--- a/Source/core/platform/CrossThreadCopier.h
+++ b/Source/core/platform/CrossThreadCopier.h
@@ -31,13 +31,13 @@
 #ifndef CrossThreadCopier_h
 #define CrossThreadCopier_h
 
-#include <wtf/Assertions.h>
-#include <wtf/Forward.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
-#include <wtf/Threading.h>
-#include <wtf/TypeTraits.h>
+#include "wtf/Assertions.h"
+#include "wtf/Forward.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
+#include "wtf/Threading.h"
+#include "wtf/TypeTraits.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/DateComponents.cpp b/Source/core/platform/DateComponents.cpp
index 0d7c616..3e07906 100644
--- a/Source/core/platform/DateComponents.cpp
+++ b/Source/core/platform/DateComponents.cpp
@@ -32,10 +32,10 @@
 #include "core/platform/DateComponents.h"
 
 #include <limits.h>
-#include <wtf/ASCIICType.h>
-#include <wtf/DateMath.h>
-#include <wtf/MathExtras.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/ASCIICType.h"
+#include "wtf/DateMath.h"
+#include "wtf/MathExtras.h"
+#include "wtf/text/WTFString.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/DateComponents.h b/Source/core/platform/DateComponents.h
index 2a2c5b7..a8f4a49 100644
--- a/Source/core/platform/DateComponents.h
+++ b/Source/core/platform/DateComponents.h
@@ -32,8 +32,8 @@
 #define DateComponents_h
 
 #include <limits>
-#include <wtf/Forward.h>
-#include <wtf/unicode/Unicode.h>
+#include "wtf/Forward.h"
+#include "wtf/unicode/Unicode.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/DateTimeChooser.h b/Source/core/platform/DateTimeChooser.h
index a6e6398..814d24d 100644
--- a/Source/core/platform/DateTimeChooser.h
+++ b/Source/core/platform/DateTimeChooser.h
@@ -32,8 +32,8 @@
 #define DateTimeChooser_h
 
 #include "core/platform/graphics/IntRect.h"
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/Decimal.cpp b/Source/core/platform/Decimal.cpp
index c329c0c..e61d5bb 100644
--- a/Source/core/platform/Decimal.cpp
+++ b/Source/core/platform/Decimal.cpp
@@ -34,10 +34,10 @@
 #include <float.h>
 #include <algorithm>
 
-#include <wtf/Assertions.h>
-#include <wtf/MathExtras.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/text/StringBuilder.h>
+#include "wtf/Assertions.h"
+#include "wtf/MathExtras.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/text/StringBuilder.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/Decimal.h b/Source/core/platform/Decimal.h
index 59cdb18..fa9a1a3 100644
--- a/Source/core/platform/Decimal.h
+++ b/Source/core/platform/Decimal.h
@@ -32,8 +32,8 @@
 #define Decimal_h
 
 #include <stdint.h>
-#include <wtf/Assertions.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Assertions.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/DragData.h b/Source/core/platform/DragData.h
index 990da9f..3c1ee07 100644
--- a/Source/core/platform/DragData.h
+++ b/Source/core/platform/DragData.h
@@ -30,9 +30,9 @@
 #include "core/platform/chromium/DragDataRef.h"
 #include "core/platform/graphics/IntPoint.h"
 
-#include <wtf/Forward.h>
-#include <wtf/HashMap.h>
-#include <wtf/Vector.h>
+#include "wtf/Forward.h"
+#include "wtf/HashMap.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/FileChooser.h b/Source/core/platform/FileChooser.h
index bffd04e..de1ffb7 100644
--- a/Source/core/platform/FileChooser.h
+++ b/Source/core/platform/FileChooser.h
@@ -30,9 +30,9 @@
 #ifndef FileChooser_h
 #define FileChooser_h
 
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/FileIconLoader.h b/Source/core/platform/FileIconLoader.h
index da8ca2a..39bb4a3 100644
--- a/Source/core/platform/FileIconLoader.h
+++ b/Source/core/platform/FileIconLoader.h
@@ -31,8 +31,8 @@
 #ifndef FileIconLoader_h
 #define FileIconLoader_h
 
-#include <wtf/RefPtr.h>
-#include <wtf/RefCounted.h>
+#include "wtf/RefPtr.h"
+#include "wtf/RefCounted.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/FileMetadata.h b/Source/core/platform/FileMetadata.h
index 8e9a82f..9da2570 100644
--- a/Source/core/platform/FileMetadata.h
+++ b/Source/core/platform/FileMetadata.h
@@ -32,7 +32,7 @@
 #define FileMetadata_h
 
 #include "core/platform/FileSystem.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/FileSystem.h b/Source/core/platform/FileSystem.h
index 0794204..e632c31 100644
--- a/Source/core/platform/FileSystem.h
+++ b/Source/core/platform/FileSystem.h
@@ -31,10 +31,10 @@
 #define FileSystem_h
 
 #include <time.h>
-#include <wtf/Forward.h>
-#include <wtf/MathExtras.h>
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Forward.h"
+#include "wtf/MathExtras.h"
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/KillRing.h b/Source/core/platform/KillRing.h
index 9dc7311..a702635 100644
--- a/Source/core/platform/KillRing.h
+++ b/Source/core/platform/KillRing.h
@@ -26,7 +26,7 @@
 #ifndef KillRing_h
 #define KillRing_h
 
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/Language.cpp b/Source/core/platform/Language.cpp
index d0da8a3..2cd4ebb 100644
--- a/Source/core/platform/Language.cpp
+++ b/Source/core/platform/Language.cpp
@@ -26,9 +26,9 @@
 #include "config.h"
 #include "core/platform/Language.h"
 
-#include <wtf/HashMap.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/HashMap.h"
+#include "wtf/RetainPtr.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/Language.h b/Source/core/platform/Language.h
index b0376df..c727256 100644
--- a/Source/core/platform/Language.h
+++ b/Source/core/platform/Language.h
@@ -26,8 +26,8 @@
 #ifndef Language_h
 #define Language_h
 
-#include <wtf/Forward.h>
-#include <wtf/Vector.h>
+#include "wtf/Forward.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/LayoutUnit.h b/Source/core/platform/LayoutUnit.h
index 4691936..97a3431 100644
--- a/Source/core/platform/LayoutUnit.h
+++ b/Source/core/platform/LayoutUnit.h
@@ -35,8 +35,8 @@
 #include <limits>
 #include <math.h>
 #include <stdlib.h>
-#include <wtf/MathExtras.h>
-#include <wtf/SaturatedArithmetic.h>
+#include "wtf/MathExtras.h"
+#include "wtf/SaturatedArithmetic.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/Length.cpp b/Source/core/platform/Length.cpp
index d93d6af..e304b0d 100644
--- a/Source/core/platform/Length.cpp
+++ b/Source/core/platform/Length.cpp
@@ -26,10 +26,10 @@
 #include "core/platform/Length.h"
 
 #include "core/platform/CalculationValue.h"
-#include <wtf/ASCIICType.h>
-#include <wtf/Assertions.h>
-#include <wtf/text/StringBuffer.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/ASCIICType.h"
+#include "wtf/Assertions.h"
+#include "wtf/text/StringBuffer.h"
+#include "wtf/text/WTFString.h"
 
 using namespace WTF;
 
diff --git a/Source/core/platform/Length.h b/Source/core/platform/Length.h
index 32ce21f..1a655d4 100644
--- a/Source/core/platform/Length.h
+++ b/Source/core/platform/Length.h
@@ -40,6 +40,7 @@
     MinContent, MaxContent, FillAvailable, FitContent,
     Calculated,
     ViewportPercentageWidth, ViewportPercentageHeight, ViewportPercentageMin, ViewportPercentageMax,
+    ExtendToZoom,
     Undefined
 };
 
diff --git a/Source/core/platform/LinkHash.h b/Source/core/platform/LinkHash.h
index e11234f..1951609 100644
--- a/Source/core/platform/LinkHash.h
+++ b/Source/core/platform/LinkHash.h
@@ -26,8 +26,8 @@
 #ifndef LinkHash_h
 #define LinkHash_h
 
-#include <wtf/Forward.h>
-#include <wtf/text/StringHash.h>
+#include "wtf/Forward.h"
+#include "wtf/text/StringHash.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/LocalizedStrings.h b/Source/core/platform/LocalizedStrings.h
index 32d38ea..e13264e 100644
--- a/Source/core/platform/LocalizedStrings.h
+++ b/Source/core/platform/LocalizedStrings.h
@@ -27,7 +27,7 @@
 #ifndef LocalizedStrings_h
 #define LocalizedStrings_h
 
-#include <wtf/Forward.h>
+#include "wtf/Forward.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/Logging.cpp b/Source/core/platform/Logging.cpp
index 5ebb90f..834ece6 100644
--- a/Source/core/platform/Logging.cpp
+++ b/Source/core/platform/Logging.cpp
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "core/platform/Logging.h"
 
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 #if !LOG_DISABLED
 
diff --git a/Source/core/platform/Logging.h b/Source/core/platform/Logging.h
index 493d309..bdad93f 100644
--- a/Source/core/platform/Logging.h
+++ b/Source/core/platform/Logging.h
@@ -26,8 +26,8 @@
 #ifndef Logging_h
 #define Logging_h
 
-#include <wtf/Assertions.h>
-#include <wtf/Forward.h>
+#include "wtf/Assertions.h"
+#include "wtf/Forward.h"
 
 #if !LOG_DISABLED
 
diff --git a/Source/core/platform/MIMETypeRegistry.h b/Source/core/platform/MIMETypeRegistry.h
index 77fefd7..c69f2dd 100644
--- a/Source/core/platform/MIMETypeRegistry.h
+++ b/Source/core/platform/MIMETypeRegistry.h
@@ -26,10 +26,10 @@
 #ifndef MIMETypeRegistry_h
 #define MIMETypeRegistry_h
 
-#include <wtf/HashSet.h>
-#include <wtf/Vector.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/HashSet.h"
+#include "wtf/Vector.h"
+#include "wtf/text/StringHash.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/MemoryUsageSupport.h b/Source/core/platform/MemoryUsageSupport.h
index b9588fc..36128e1 100644
--- a/Source/core/platform/MemoryUsageSupport.h
+++ b/Source/core/platform/MemoryUsageSupport.h
@@ -31,9 +31,9 @@
 #ifndef MemoryUsageSupport_h
 #define MemoryUsageSupport_h
 
-#include <wtf/Forward.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Forward.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
@@ -62,17 +62,6 @@
     // Requests private and shared usage, in bytes. Private bytes is the amount of
     // memory currently allocated to this process that cannot be shared.
     static void requestProcessMemorySizes(PassOwnPtr<ProcessMemorySizesCallback> requestCallback);
-
-    class ComponentInfo {
-    public:
-        ComponentInfo(const String& name, size_t size) : m_name(name), m_sizeInBytes(size) { }
-
-        const String m_name;
-        size_t m_sizeInBytes;
-    };
-
-    // Reports private memory used by components in bytes.
-    static void memoryUsageByComponents(Vector<ComponentInfo>&);
 };
 
 } // namespace WebCore
diff --git a/Source/core/platform/NotImplemented.h b/Source/core/platform/NotImplemented.h
index 22b94f7..d553018 100644
--- a/Source/core/platform/NotImplemented.h
+++ b/Source/core/platform/NotImplemented.h
@@ -26,7 +26,7 @@
 #ifndef NotImplemented_h
 #define NotImplemented_h
 
-#include <wtf/Assertions.h>
+#include "wtf/Assertions.h"
 
 #if LOG_DISABLED
     #define notImplemented() ((void)0)
diff --git a/Source/core/platform/PODArena.h b/Source/core/platform/PODArena.h
index 07ff1f8..bc65de6 100644
--- a/Source/core/platform/PODArena.h
+++ b/Source/core/platform/PODArena.h
@@ -27,13 +27,13 @@
 #define PODArena_h
 
 #include <stdint.h>
-#include <wtf/Assertions.h>
-#include <wtf/FastMalloc.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
+#include "wtf/Assertions.h"
+#include "wtf/FastMalloc.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/PODInterval.h b/Source/core/platform/PODInterval.h
index 5c1dcc2..925187c 100644
--- a/Source/core/platform/PODInterval.h
+++ b/Source/core/platform/PODInterval.h
@@ -27,7 +27,7 @@
 #define PODInterval_h
 
 #ifndef NDEBUG
-#include <wtf/text/StringBuilder.h>
+#include "wtf/text/StringBuilder.h"
 #endif
 
 namespace WebCore {
diff --git a/Source/core/platform/PODIntervalTree.h b/Source/core/platform/PODIntervalTree.h
index 102bf6f..1a3e5f6 100644
--- a/Source/core/platform/PODIntervalTree.h
+++ b/Source/core/platform/PODIntervalTree.h
@@ -29,9 +29,9 @@
 #include "core/platform/PODArena.h"
 #include "core/platform/PODInterval.h"
 #include "core/platform/PODRedBlackTree.h"
-#include <wtf/Assertions.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
+#include "wtf/Assertions.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/PODRedBlackTree.h b/Source/core/platform/PODRedBlackTree.h
index 234ee46..b671b05 100644
--- a/Source/core/platform/PODRedBlackTree.h
+++ b/Source/core/platform/PODRedBlackTree.h
@@ -73,13 +73,13 @@
 #define PODRedBlackTree_h
 
 #include "core/platform/PODFreeListArena.h"
-#include <wtf/Assertions.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/RefPtr.h>
+#include "wtf/Assertions.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/RefPtr.h"
 #ifndef NDEBUG
-#include <wtf/text/CString.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/text/CString.h"
+#include "wtf/text/StringBuilder.h"
+#include "wtf/text/WTFString.h"
 #endif
 
 namespace WebCore {
diff --git a/Source/core/platform/Pasteboard.h b/Source/core/platform/Pasteboard.h
index d11cf20..48b4200 100644
--- a/Source/core/platform/Pasteboard.h
+++ b/Source/core/platform/Pasteboard.h
@@ -26,11 +26,11 @@
 #ifndef Pasteboard_h
 #define Pasteboard_h
 
-#include <wtf/Forward.h>
-#include <wtf/HashSet.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "wtf/Forward.h"
+#include "wtf/HashSet.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/text/WTFString.h"
+#include "wtf/Vector.h"
 
 // FIXME: This class is too high-level to be in the platform directory, since it
 // uses the DOM and makes calls to Editor. It should either be divested of its
diff --git a/Source/core/platform/PlatformInstrumentation.h b/Source/core/platform/PlatformInstrumentation.h
index 5c44993..33414fd 100644
--- a/Source/core/platform/PlatformInstrumentation.h
+++ b/Source/core/platform/PlatformInstrumentation.h
@@ -31,8 +31,8 @@
 #ifndef PlatformInstrumentation_h
 #define PlatformInstrumentation_h
 
-#include <wtf/MainThread.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/MainThread.h"
+#include "wtf/text/WTFString.h"
 
 #include "core/platform/chromium/TraceEvent.h"
 
diff --git a/Source/core/platform/PlatformKeyboardEvent.h b/Source/core/platform/PlatformKeyboardEvent.h
index 9b876c6..3731b85 100644
--- a/Source/core/platform/PlatformKeyboardEvent.h
+++ b/Source/core/platform/PlatformKeyboardEvent.h
@@ -28,7 +28,7 @@
 #define PlatformKeyboardEvent_h
 
 #include "core/platform/PlatformEvent.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/PlatformScreen.h b/Source/core/platform/PlatformScreen.h
index f7d47ac..096f026 100644
--- a/Source/core/platform/PlatformScreen.h
+++ b/Source/core/platform/PlatformScreen.h
@@ -27,8 +27,8 @@
 #define PlatformScreen_h
 
 #include "core/platform/graphics/FloatRect.h"
-#include <wtf/Forward.h>
-#include <wtf/RefPtr.h>
+#include "wtf/Forward.h"
+#include "wtf/RefPtr.h"
 
 typedef uint32_t PlatformDisplayID;
 
diff --git a/Source/core/platform/PlatformSpeechSynthesisUtterance.h b/Source/core/platform/PlatformSpeechSynthesisUtterance.h
index dc4b1f1..79998e9 100644
--- a/Source/core/platform/PlatformSpeechSynthesisUtterance.h
+++ b/Source/core/platform/PlatformSpeechSynthesisUtterance.h
@@ -27,9 +27,9 @@
 #define PlatformSpeechSynthesisUtterance_h
 
 #include "core/platform/PlatformSpeechSynthesisVoice.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
     
diff --git a/Source/core/platform/PlatformSpeechSynthesisVoice.h b/Source/core/platform/PlatformSpeechSynthesisVoice.h
index 79e7ef1..b475a2c 100644
--- a/Source/core/platform/PlatformSpeechSynthesisVoice.h
+++ b/Source/core/platform/PlatformSpeechSynthesisVoice.h
@@ -26,9 +26,9 @@
 #ifndef PlatformSpeechSynthesisVoice_h
 #define PlatformSpeechSynthesisVoice_h
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/PlatformSpeechSynthesizer.h b/Source/core/platform/PlatformSpeechSynthesizer.h
index 694b968..f1db25a 100644
--- a/Source/core/platform/PlatformSpeechSynthesizer.h
+++ b/Source/core/platform/PlatformSpeechSynthesizer.h
@@ -27,8 +27,8 @@
 #define PlatformSpeechSynthesizer_h
 
 #include "core/platform/PlatformSpeechSynthesisVoice.h"
-#include <wtf/PassOwnPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebKit {
 class WebSpeechSynthesizer;
diff --git a/Source/core/platform/PlatformTouchEvent.h b/Source/core/platform/PlatformTouchEvent.h
index 7238617..d3b1eef 100644
--- a/Source/core/platform/PlatformTouchEvent.h
+++ b/Source/core/platform/PlatformTouchEvent.h
@@ -22,7 +22,7 @@
 
 #include "core/platform/PlatformEvent.h"
 #include "core/platform/PlatformTouchPoint.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/PlatformTouchPoint.h b/Source/core/platform/PlatformTouchPoint.h
index a5edebb..f6609a8 100644
--- a/Source/core/platform/PlatformTouchPoint.h
+++ b/Source/core/platform/PlatformTouchPoint.h
@@ -21,7 +21,7 @@
 #define PlatformTouchPoint_h
 
 #include "core/platform/graphics/IntPoint.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/PopupMenuClient.h b/Source/core/platform/PopupMenuClient.h
index cc1cc88..ed41b51 100644
--- a/Source/core/platform/PopupMenuClient.h
+++ b/Source/core/platform/PopupMenuClient.h
@@ -25,7 +25,7 @@
 #include "core/platform/LayoutUnit.h"
 #include "core/platform/PopupMenuStyle.h"
 #include "core/platform/ScrollTypes.h"
-#include <wtf/Forward.h>
+#include "wtf/Forward.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/PrerenderHandle.h b/Source/core/platform/PrerenderHandle.h
index f1f1c1b..90dd511 100644
--- a/Source/core/platform/PrerenderHandle.h
+++ b/Source/core/platform/PrerenderHandle.h
@@ -33,10 +33,10 @@
 #define PrerenderHandle_h
 
 #include "weborigin/ReferrerPolicy.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/RefCountedSupplement.h b/Source/core/platform/RefCountedSupplement.h
index 28c7655..985c81f 100644
--- a/Source/core/platform/RefCountedSupplement.h
+++ b/Source/core/platform/RefCountedSupplement.h
@@ -27,8 +27,8 @@
 #define RefCountedSupplement_h
 
 #include "core/platform/Supplementable.h"
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/SSLKeyGenerator.h b/Source/core/platform/SSLKeyGenerator.h
index 0651526..41c4f98 100644
--- a/Source/core/platform/SSLKeyGenerator.h
+++ b/Source/core/platform/SSLKeyGenerator.h
@@ -26,8 +26,8 @@
 #ifndef SSLKeyGenerator_h
 #define SSLKeyGenerator_h
 
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/ScrollAnimator.cpp b/Source/core/platform/ScrollAnimator.cpp
index 2924a2b..37be5c7 100644
--- a/Source/core/platform/ScrollAnimator.cpp
+++ b/Source/core/platform/ScrollAnimator.cpp
@@ -35,7 +35,7 @@
 #include "core/platform/PlatformWheelEvent.h"
 #include "core/platform/ScrollableArea.h"
 #include "core/platform/graphics/FloatPoint.h"
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/ScrollAnimator.h b/Source/core/platform/ScrollAnimator.h
index 796f82e..d0a0fe7 100644
--- a/Source/core/platform/ScrollAnimator.h
+++ b/Source/core/platform/ScrollAnimator.h
@@ -34,9 +34,9 @@
 #include "core/platform/PlatformWheelEvent.h"
 #include "core/platform/ScrollTypes.h"
 #include "core/platform/graphics/FloatSize.h"
-#include <wtf/FastAllocBase.h>
-#include <wtf/Forward.h>
-#include <wtf/UnusedParam.h>
+#include "wtf/FastAllocBase.h"
+#include "wtf/Forward.h"
+#include "wtf/UnusedParam.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/ScrollAnimatorNone.cpp b/Source/core/platform/ScrollAnimatorNone.cpp
index 4c2f97d..27c12c3 100644
--- a/Source/core/platform/ScrollAnimatorNone.cpp
+++ b/Source/core/platform/ScrollAnimatorNone.cpp
@@ -35,9 +35,9 @@
 #include <algorithm>
 #include "core/platform/ScrollableArea.h"
 #include "core/platform/graphics/FloatPoint.h"
-#include <wtf/CurrentTime.h>
-#include <wtf/OwnArrayPtr.h>
-#include <wtf/PassOwnPtr.h>
+#include "wtf/CurrentTime.h"
+#include "wtf/OwnArrayPtr.h"
+#include "wtf/PassOwnPtr.h"
 
 #include "core/platform/chromium/TraceEvent.h"
 
diff --git a/Source/core/platform/ScrollAnimatorNone.h b/Source/core/platform/ScrollAnimatorNone.h
index 9eddc3a..b583c5e 100644
--- a/Source/core/platform/ScrollAnimatorNone.h
+++ b/Source/core/platform/ScrollAnimatorNone.h
@@ -34,7 +34,7 @@
 #include "core/platform/ScrollAnimator.h"
 #include "core/platform/Timer.h"
 #include "core/platform/graphics/FloatPoint.h"
-#include <wtf/OwnPtr.h>
+#include "wtf/OwnPtr.h"
 
 class ScrollAnimatorNoneTest;
 
diff --git a/Source/core/platform/ScrollView.cpp b/Source/core/platform/ScrollView.cpp
index 8086216..65c585e 100644
--- a/Source/core/platform/ScrollView.cpp
+++ b/Source/core/platform/ScrollView.cpp
@@ -32,7 +32,7 @@
 #include "core/platform/ScrollbarTheme.h"
 #include "core/platform/graphics/GraphicsContextStateSaver.h"
 #include "core/platform/graphics/GraphicsLayer.h"
-#include <wtf/StdLibExtras.h>
+#include "wtf/StdLibExtras.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/ScrollView.h b/Source/core/platform/ScrollView.h
index fdb819f..fff4633 100644
--- a/Source/core/platform/ScrollView.h
+++ b/Source/core/platform/ScrollView.h
@@ -33,7 +33,7 @@
 #include "core/platform/Widget.h"
 #include "core/platform/graphics/IntRect.h"
 
-#include <wtf/HashSet.h>
+#include "wtf/HashSet.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/ScrollableArea.cpp b/Source/core/platform/ScrollableArea.cpp
index bd89596..3075a11 100644
--- a/Source/core/platform/ScrollableArea.cpp
+++ b/Source/core/platform/ScrollableArea.cpp
@@ -36,7 +36,7 @@
 #include "core/platform/ScrollbarTheme.h"
 #include "core/platform/graphics/FloatPoint.h"
 #include "core/platform/graphics/GraphicsLayer.h"
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 #include "core/platform/chromium/TraceEvent.h"
 
diff --git a/Source/core/platform/ScrollableArea.h b/Source/core/platform/ScrollableArea.h
index bdefcb6..46f1495 100644
--- a/Source/core/platform/ScrollableArea.h
+++ b/Source/core/platform/ScrollableArea.h
@@ -27,7 +27,7 @@
 #define ScrollableArea_h
 
 #include "core/platform/Scrollbar.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/Scrollbar.h b/Source/core/platform/Scrollbar.h
index a8926e7..f8a1555 100644
--- a/Source/core/platform/Scrollbar.h
+++ b/Source/core/platform/Scrollbar.h
@@ -30,8 +30,8 @@
 #include "core/platform/ScrollbarThemeClient.h"
 #include "core/platform/Timer.h"
 #include "core/platform/Widget.h"
-#include <wtf/MathExtras.h>
-#include <wtf/PassRefPtr.h>
+#include "wtf/MathExtras.h"
+#include "wtf/PassRefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/ScrollbarThemeClient.h b/Source/core/platform/ScrollbarThemeClient.h
index 106175f..dc001b7 100644
--- a/Source/core/platform/ScrollbarThemeClient.h
+++ b/Source/core/platform/ScrollbarThemeClient.h
@@ -30,8 +30,8 @@
 #include "core/platform/graphics/IntPoint.h"
 #include "core/platform/graphics/IntRect.h"
 #include "core/platform/graphics/IntSize.h"
-#include <wtf/PassOwnPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/SharedBuffer.cpp b/Source/core/platform/SharedBuffer.cpp
index fa83910..f883db4 100644
--- a/Source/core/platform/SharedBuffer.cpp
+++ b/Source/core/platform/SharedBuffer.cpp
@@ -28,9 +28,9 @@
 #include "core/platform/SharedBuffer.h"
 
 #include "core/platform/PurgeableBuffer.h"
-#include <wtf/PassOwnPtr.h>
-#include <wtf/unicode/Unicode.h>
-#include <wtf/unicode/UTF8.h>
+#include "wtf/PassOwnPtr.h"
+#include "wtf/unicode/Unicode.h"
+#include "wtf/unicode/UTF8.h"
 
 #undef SHARED_BUFFER_STATS
 
diff --git a/Source/core/platform/SharedBufferChunkReader.h b/Source/core/platform/SharedBufferChunkReader.h
index 568ec3c..107b460 100644
--- a/Source/core/platform/SharedBufferChunkReader.h
+++ b/Source/core/platform/SharedBufferChunkReader.h
@@ -31,8 +31,8 @@
 #ifndef SharedBufferChunkReader_h
 #define SharedBufferChunkReader_h
 
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/SharedTimer.h b/Source/core/platform/SharedTimer.h
index 6acaba9..4634060 100644
--- a/Source/core/platform/SharedTimer.h
+++ b/Source/core/platform/SharedTimer.h
@@ -26,8 +26,8 @@
 #ifndef SharedTimer_h
 #define SharedTimer_h
 
-#include <wtf/FastAllocBase.h>
-#include <wtf/Noncopyable.h>
+#include "wtf/FastAllocBase.h"
+#include "wtf/Noncopyable.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/Supplementable.h b/Source/core/platform/Supplementable.h
index 352d7ea..e87c12f 100644
--- a/Source/core/platform/Supplementable.h
+++ b/Source/core/platform/Supplementable.h
@@ -26,13 +26,13 @@
 #ifndef Supplementable_h
 #define Supplementable_h
 
-#include <wtf/Assertions.h>
-#include <wtf/HashMap.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
+#include "wtf/Assertions.h"
+#include "wtf/HashMap.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
 
 #if !ASSERT_DISABLED
-#include <wtf/Threading.h>
+#include "wtf/Threading.h"
 #endif
 
 namespace WebCore {
@@ -71,6 +71,21 @@
 //     {
 //         return reinterpret_cast<MyClass*>(Supplement<MySupplementable>::from(host, supplementName()));
 //     }
+//
+// What you should know about thread checks
+// ========================================
+// When assertion is enabled this class performs thread-safety check so that
+// provideTo and from happen on the same thread. If you want to provide
+// some value for Workers this thread check may not work very well though,
+// since in most case you'd provide the value while worker preparation is
+// being done on the main thread, even before the worker thread is started.
+// If that's the case you can explicitly call reattachThread() when the
+// Supplementable object is passed to the final destination thread (i.e.
+// worker thread). Please be extremely careful to use the method though,
+// as randomly calling the method could easily cause racy condition.
+//
+// Note that reattachThread() does nothing if assertion is not enabled.
+//
 
 template<typename T>
 class Supplementable;
@@ -116,6 +131,13 @@
         return m_supplements.get(key);
     }
 
+    void reattachThread()
+    {
+#if !ASSERT_DISABLED
+        m_threadId = currentThread();
+#endif
+    }
+
 #if !ASSERT_DISABLED
 protected:
     Supplementable() : m_threadId(currentThread()) { }
@@ -132,4 +154,3 @@
 } // namespace WebCore
 
 #endif // Supplementable_h
-
diff --git a/Source/core/platform/Theme.h b/Source/core/platform/Theme.h
index f8fde5e..e8e91ec 100644
--- a/Source/core/platform/Theme.h
+++ b/Source/core/platform/Theme.h
@@ -32,7 +32,7 @@
 #include "core/platform/graphics/Color.h"
 #include "core/platform/graphics/Font.h"
 #include "core/platform/graphics/IntRect.h"
-#include <wtf/Forward.h>
+#include "wtf/Forward.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/ThreadTimers.cpp b/Source/core/platform/ThreadTimers.cpp
index abf5bea..eef621a 100644
--- a/Source/core/platform/ThreadTimers.cpp
+++ b/Source/core/platform/ThreadTimers.cpp
@@ -31,8 +31,8 @@
 #include "core/platform/ThreadGlobalData.h"
 #include "core/platform/Timer.h"
 #include "core/platform/chromium/TraceEvent.h"
-#include <wtf/CurrentTime.h>
-#include <wtf/MainThread.h>
+#include "wtf/CurrentTime.h"
+#include "wtf/MainThread.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/ThreadTimers.h b/Source/core/platform/ThreadTimers.h
index 90877ed..d503541 100644
--- a/Source/core/platform/ThreadTimers.h
+++ b/Source/core/platform/ThreadTimers.h
@@ -27,9 +27,9 @@
 #ifndef ThreadTimers_h
 #define ThreadTimers_h
 
-#include <wtf/Noncopyable.h>
-#include <wtf/HashSet.h>
-#include <wtf/Vector.h>
+#include "wtf/Noncopyable.h"
+#include "wtf/HashSet.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/Timer.cpp b/Source/core/platform/Timer.cpp
index 25ce7f5..3425468 100644
--- a/Source/core/platform/Timer.cpp
+++ b/Source/core/platform/Timer.cpp
@@ -32,9 +32,9 @@
 #include <limits>
 #include "core/platform/ThreadGlobalData.h"
 #include "core/platform/ThreadTimers.h"
-#include <wtf/CurrentTime.h>
-#include <wtf/HashSet.h>
-#include <wtf/Vector.h>
+#include "wtf/CurrentTime.h"
+#include "wtf/HashSet.h"
+#include "wtf/Vector.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/Timer.h b/Source/core/platform/Timer.h
index aec7b3a..296b832 100644
--- a/Source/core/platform/Timer.h
+++ b/Source/core/platform/Timer.h
@@ -26,9 +26,9 @@
 #ifndef Timer_h
 #define Timer_h
 
-#include <wtf/Noncopyable.h>
-#include <wtf/Threading.h>
-#include <wtf/Vector.h>
+#include "wtf/Noncopyable.h"
+#include "wtf/Threading.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/TreeShared.h b/Source/core/platform/TreeShared.h
index 9185364..9c1b8d9 100644
--- a/Source/core/platform/TreeShared.h
+++ b/Source/core/platform/TreeShared.h
@@ -21,9 +21,9 @@
 #ifndef TreeShared_h
 #define TreeShared_h
 
-#include <wtf/Assertions.h>
-#include <wtf/MainThread.h>
-#include <wtf/Noncopyable.h>
+#include "wtf/Assertions.h"
+#include "wtf/MainThread.h"
+#include "wtf/Noncopyable.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/UUID.cpp b/Source/core/platform/UUID.cpp
index e6d79cb..8e453f5 100644
--- a/Source/core/platform/UUID.cpp
+++ b/Source/core/platform/UUID.cpp
@@ -31,9 +31,9 @@
 #include "config.h"
 #include "core/platform/UUID.h"
 
-#include <wtf/CryptographicallyRandomNumber.h>
-#include <wtf/HexNumber.h>
-#include <wtf/text/StringBuilder.h>
+#include "wtf/CryptographicallyRandomNumber.h"
+#include "wtf/HexNumber.h"
+#include "wtf/text/StringBuilder.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/UUID.h b/Source/core/platform/UUID.h
index 6d914dc..99ab781 100644
--- a/Source/core/platform/UUID.h
+++ b/Source/core/platform/UUID.h
@@ -31,7 +31,7 @@
 #ifndef UUID_h
 #define UUID_h
 
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/Widget.cpp b/Source/core/platform/Widget.cpp
index c59a290..b857039 100644
--- a/Source/core/platform/Widget.cpp
+++ b/Source/core/platform/Widget.cpp
@@ -31,7 +31,7 @@
 #include "core/platform/ScrollView.h"
 #include "core/platform/graphics/IntRect.h"
 
-#include <wtf/Assertions.h>
+#include "wtf/Assertions.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/Widget.h b/Source/core/platform/Widget.h
index c69053a..ab863f3 100644
--- a/Source/core/platform/Widget.h
+++ b/Source/core/platform/Widget.h
@@ -29,8 +29,8 @@
 #define Widget_h
 
 #include "core/platform/graphics/IntRect.h"
-#include <wtf/Forward.h>
-#include <wtf/RefCounted.h>
+#include "wtf/Forward.h"
+#include "wtf/RefCounted.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/animation/AnimationUtilities.h b/Source/core/platform/animation/AnimationUtilities.h
index 07cd54d..64aea5a 100644
--- a/Source/core/platform/animation/AnimationUtilities.h
+++ b/Source/core/platform/animation/AnimationUtilities.h
@@ -28,7 +28,7 @@
 
 #include "core/platform/LayoutUnit.h"
 #include "core/platform/graphics/IntPoint.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/animation/CSSAnimationData.h b/Source/core/platform/animation/CSSAnimationData.h
index 80549dc..3ca878a 100644
--- a/Source/core/platform/animation/CSSAnimationData.h
+++ b/Source/core/platform/animation/CSSAnimationData.h
@@ -28,9 +28,9 @@
 #include "CSSPropertyNames.h"
 #include "core/platform/animation/TimingFunction.h"
 #include "core/rendering/style/RenderStyleConstants.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/animation/CSSAnimationDataList.h b/Source/core/platform/animation/CSSAnimationDataList.h
index b5276b5..bd7d942 100644
--- a/Source/core/platform/animation/CSSAnimationDataList.h
+++ b/Source/core/platform/animation/CSSAnimationDataList.h
@@ -26,8 +26,8 @@
 #define CSSAnimationDataList_h
 
 #include "core/platform/animation/CSSAnimationData.h"
-#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/AudioArray.h b/Source/core/platform/audio/AudioArray.h
index 3959361..a70903b 100644
--- a/Source/core/platform/audio/AudioArray.h
+++ b/Source/core/platform/audio/AudioArray.h
@@ -30,8 +30,8 @@
 #define AudioArray_h
 
 #include <string.h>
-#include <wtf/FastMalloc.h>
-#include <wtf/Vector.h>
+#include "wtf/FastMalloc.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/AudioBus.cpp b/Source/core/platform/audio/AudioBus.cpp
index 4da8425..dcdf6fc 100644
--- a/Source/core/platform/audio/AudioBus.cpp
+++ b/Source/core/platform/audio/AudioBus.cpp
@@ -39,8 +39,8 @@
 #include <algorithm>
 #include "core/platform/audio/SincResampler.h"
 #include "core/platform/audio/VectorMath.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/AudioBus.h b/Source/core/platform/audio/AudioBus.h
index 6f4ed2b..d13b0e7 100644
--- a/Source/core/platform/audio/AudioBus.h
+++ b/Source/core/platform/audio/AudioBus.h
@@ -30,10 +30,10 @@
 #define AudioBus_h
 
 #include "core/platform/audio/AudioChannel.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/ThreadSafeRefCounted.h>
-#include <wtf/Vector.h>
+#include "wtf/Noncopyable.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/ThreadSafeRefCounted.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/AudioChannel.cpp b/Source/core/platform/audio/AudioChannel.cpp
index e489256..786d48b 100644
--- a/Source/core/platform/audio/AudioChannel.cpp
+++ b/Source/core/platform/audio/AudioChannel.cpp
@@ -35,7 +35,7 @@
 #include <math.h>
 #include <algorithm>
 #include "core/platform/audio/VectorMath.h"
-#include <wtf/OwnPtr.h>
+#include "wtf/OwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/AudioChannel.h b/Source/core/platform/audio/AudioChannel.h
index 5fdc9d9..44bd3ca 100644
--- a/Source/core/platform/audio/AudioChannel.h
+++ b/Source/core/platform/audio/AudioChannel.h
@@ -30,7 +30,7 @@
 #define AudioChannel_h
 
 #include "core/platform/audio/AudioArray.h"
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/AudioDSPKernelProcessor.h b/Source/core/platform/audio/AudioDSPKernelProcessor.h
index 73f9cbd..5c03835 100644
--- a/Source/core/platform/audio/AudioDSPKernelProcessor.h
+++ b/Source/core/platform/audio/AudioDSPKernelProcessor.h
@@ -33,9 +33,9 @@
 
 #include "core/platform/audio/AudioBus.h"
 #include "core/platform/audio/AudioProcessor.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/AudioDestination.h b/Source/core/platform/audio/AudioDestination.h
index 1766ee5..4c1a56f 100644
--- a/Source/core/platform/audio/AudioDestination.h
+++ b/Source/core/platform/audio/AudioDestination.h
@@ -29,9 +29,9 @@
 #ifndef AudioDestination_h
 #define AudioDestination_h
 
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/AudioDestinationConsumer.h b/Source/core/platform/audio/AudioDestinationConsumer.h
index 4f1f899..35bc396 100644
--- a/Source/core/platform/audio/AudioDestinationConsumer.h
+++ b/Source/core/platform/audio/AudioDestinationConsumer.h
@@ -31,7 +31,7 @@
 #ifndef AudioDestinationConsumer_h
 #define AudioDestinationConsumer_h
 
-#include <wtf/RefCounted.h>
+#include "wtf/RefCounted.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/AudioFileReader.h b/Source/core/platform/audio/AudioFileReader.h
index 8283ee2..bbc117f 100644
--- a/Source/core/platform/audio/AudioFileReader.h
+++ b/Source/core/platform/audio/AudioFileReader.h
@@ -30,8 +30,8 @@
 #define AudioFileReader_h
 
 #include <stdlib.h>
-#include <wtf/RefPtr.h>
-#include <wtf/PassRefPtr.h>
+#include "wtf/RefPtr.h"
+#include "wtf/PassRefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/AudioResampler.cpp b/Source/core/platform/audio/AudioResampler.cpp
index faeecae..a3c18cb 100644
--- a/Source/core/platform/audio/AudioResampler.cpp
+++ b/Source/core/platform/audio/AudioResampler.cpp
@@ -30,7 +30,7 @@
 
 #include <algorithm>
 #include "core/platform/audio/AudioBus.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 using namespace std;
  
diff --git a/Source/core/platform/audio/AudioResampler.h b/Source/core/platform/audio/AudioResampler.h
index 4f0631f..c0d511f 100644
--- a/Source/core/platform/audio/AudioResampler.h
+++ b/Source/core/platform/audio/AudioResampler.h
@@ -28,8 +28,8 @@
 #include "core/platform/audio/AudioBus.h"
 #include "core/platform/audio/AudioResamplerKernel.h"
 #include "core/platform/audio/AudioSourceProvider.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/AudioUtilities.cpp b/Source/core/platform/audio/AudioUtilities.cpp
index ef0fbde..515499c 100644
--- a/Source/core/platform/audio/AudioUtilities.cpp
+++ b/Source/core/platform/audio/AudioUtilities.cpp
@@ -27,7 +27,7 @@
 #if ENABLE(WEB_AUDIO)
 
 #include "core/platform/audio/AudioUtilities.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/Biquad.cpp b/Source/core/platform/audio/Biquad.cpp
index 7281380..5928357 100644
--- a/Source/core/platform/audio/Biquad.cpp
+++ b/Source/core/platform/audio/Biquad.cpp
@@ -35,7 +35,7 @@
 #include <stdio.h>
 #include <algorithm>
 #include "core/platform/audio/DenormalDisabler.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 #if OS(DARWIN)
 #include <Accelerate/Accelerate.h>
diff --git a/Source/core/platform/audio/Biquad.h b/Source/core/platform/audio/Biquad.h
index f157a2d..e0e421d 100644
--- a/Source/core/platform/audio/Biquad.h
+++ b/Source/core/platform/audio/Biquad.h
@@ -31,7 +31,7 @@
 
 #include <sys/types.h>
 #include "core/platform/audio/AudioArray.h"
-#include <wtf/Complex.h>
+#include "wtf/Complex.h"
  
 #if USE(WEBAUDIO_IPP)
 #include <ipps.h>
diff --git a/Source/core/platform/audio/Cone.cpp b/Source/core/platform/audio/Cone.cpp
index f6b608b..c38138a 100644
--- a/Source/core/platform/audio/Cone.cpp
+++ b/Source/core/platform/audio/Cone.cpp
@@ -31,7 +31,7 @@
 #if ENABLE(WEB_AUDIO)
 
 #include "core/platform/audio/Cone.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/DenormalDisabler.h b/Source/core/platform/audio/DenormalDisabler.h
index 6e9f4e0..942e302 100644
--- a/Source/core/platform/audio/DenormalDisabler.h
+++ b/Source/core/platform/audio/DenormalDisabler.h
@@ -25,7 +25,7 @@
 #ifndef DenormalDisabler_h
 #define DenormalDisabler_h
 
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/DynamicsCompressor.cpp b/Source/core/platform/audio/DynamicsCompressor.cpp
index ec67305..6f735cd 100644
--- a/Source/core/platform/audio/DynamicsCompressor.cpp
+++ b/Source/core/platform/audio/DynamicsCompressor.cpp
@@ -34,7 +34,7 @@
 
 #include "core/platform/audio/AudioBus.h"
 #include "core/platform/audio/AudioUtilities.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/DynamicsCompressor.h b/Source/core/platform/audio/DynamicsCompressor.h
index 6253365..90922e6 100644
--- a/Source/core/platform/audio/DynamicsCompressor.h
+++ b/Source/core/platform/audio/DynamicsCompressor.h
@@ -33,7 +33,7 @@
 #include "core/platform/audio/DynamicsCompressorKernel.h"
 #include "core/platform/audio/ZeroPole.h"
 
-#include <wtf/OwnArrayPtr.h>
+#include "wtf/OwnArrayPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/DynamicsCompressorKernel.cpp b/Source/core/platform/audio/DynamicsCompressorKernel.cpp
index 7206ef5..e5ee8a6 100644
--- a/Source/core/platform/audio/DynamicsCompressorKernel.cpp
+++ b/Source/core/platform/audio/DynamicsCompressorKernel.cpp
@@ -35,7 +35,7 @@
 #include <algorithm>
 #include "core/platform/audio/AudioUtilities.h"
 #include "core/platform/audio/DenormalDisabler.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/audio/DynamicsCompressorKernel.h b/Source/core/platform/audio/DynamicsCompressorKernel.h
index a63a834..f9e821b 100644
--- a/Source/core/platform/audio/DynamicsCompressorKernel.h
+++ b/Source/core/platform/audio/DynamicsCompressorKernel.h
@@ -31,8 +31,8 @@
 
 #include "core/platform/audio/AudioArray.h"
 
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/EqualPowerPanner.cpp b/Source/core/platform/audio/EqualPowerPanner.cpp
index c01ed1f..6ebe93b 100644
--- a/Source/core/platform/audio/EqualPowerPanner.cpp
+++ b/Source/core/platform/audio/EqualPowerPanner.cpp
@@ -31,7 +31,7 @@
 #include <algorithm>
 #include "core/platform/audio/AudioBus.h"
 #include "core/platform/audio/AudioUtilities.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 // Use a 50ms smoothing / de-zippering time-constant.
 const float SmoothingTimeConstant = 0.050f;
diff --git a/Source/core/platform/audio/FFTFrame.cpp b/Source/core/platform/audio/FFTFrame.cpp
index c553dd2..1bd5a63 100644
--- a/Source/core/platform/audio/FFTFrame.cpp
+++ b/Source/core/platform/audio/FFTFrame.cpp
@@ -37,9 +37,9 @@
 #endif
 
 #include "core/platform/Logging.h"
-#include <wtf/Complex.h>
-#include <wtf/MathExtras.h>
-#include <wtf/OwnPtr.h>
+#include "wtf/Complex.h"
+#include "wtf/MathExtras.h"
+#include "wtf/OwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/FFTFrame.h b/Source/core/platform/audio/FFTFrame.h
index 5cd4e39..94b462a 100644
--- a/Source/core/platform/audio/FFTFrame.h
+++ b/Source/core/platform/audio/FFTFrame.h
@@ -56,9 +56,9 @@
 #include <ipps.h>
 #endif // USE(WEBAUDIO_IPP)
 
-#include <wtf/Forward.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/Threading.h>
+#include "wtf/Forward.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Threading.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/HRTFDatabase.h b/Source/core/platform/audio/HRTFDatabase.h
index 2ffe359..b265d64 100644
--- a/Source/core/platform/audio/HRTFDatabase.h
+++ b/Source/core/platform/audio/HRTFDatabase.h
@@ -30,11 +30,11 @@
 #define HRTFDatabase_h
 
 #include "core/platform/audio/HRTFElevation.h"
-#include <wtf/Forward.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/Forward.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/HRTFElevation.cpp b/Source/core/platform/audio/HRTFElevation.cpp
index 12c337f..998f604 100644
--- a/Source/core/platform/audio/HRTFElevation.cpp
+++ b/Source/core/platform/audio/HRTFElevation.cpp
@@ -36,7 +36,7 @@
 #include <algorithm>
 #include "core/platform/audio/AudioBus.h"
 #include "core/platform/audio/HRTFPanner.h"
-#include <wtf/OwnPtr.h>
+#include "wtf/OwnPtr.h"
 
 using namespace std;
  
diff --git a/Source/core/platform/audio/HRTFElevation.h b/Source/core/platform/audio/HRTFElevation.h
index 6a825a1..d201b97 100644
--- a/Source/core/platform/audio/HRTFElevation.h
+++ b/Source/core/platform/audio/HRTFElevation.h
@@ -30,14 +30,14 @@
 #define HRTFElevation_h
 
 #include "core/platform/audio/HRTFKernel.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Noncopyable.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/text/CString.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/HRTFKernel.cpp b/Source/core/platform/audio/HRTFKernel.cpp
index 7d22ec4..e7432a1 100644
--- a/Source/core/platform/audio/HRTFKernel.cpp
+++ b/Source/core/platform/audio/HRTFKernel.cpp
@@ -35,7 +35,7 @@
 #include "core/platform/FloatConversion.h"
 #include "core/platform/audio/AudioChannel.h"
 #include "core/platform/audio/FFTFrame.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/audio/HRTFKernel.h b/Source/core/platform/audio/HRTFKernel.h
index 087cecc..a076bf8 100644
--- a/Source/core/platform/audio/HRTFKernel.h
+++ b/Source/core/platform/audio/HRTFKernel.h
@@ -30,12 +30,12 @@
 #define HRTFKernel_h
 
 #include "core/platform/audio/FFTFrame.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/HRTFPanner.cpp b/Source/core/platform/audio/HRTFPanner.cpp
index 39c13d2..9234fed 100644
--- a/Source/core/platform/audio/HRTFPanner.cpp
+++ b/Source/core/platform/audio/HRTFPanner.cpp
@@ -32,8 +32,8 @@
 #include "core/platform/audio/AudioBus.h"
 #include "core/platform/audio/FFTConvolver.h"
 #include "core/platform/audio/HRTFDatabase.h"
-#include <wtf/MathExtras.h>
-#include <wtf/RefPtr.h>
+#include "wtf/MathExtras.h"
+#include "wtf/RefPtr.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/audio/MultiChannelResampler.h b/Source/core/platform/audio/MultiChannelResampler.h
index 851469f..a5164a7 100644
--- a/Source/core/platform/audio/MultiChannelResampler.h
+++ b/Source/core/platform/audio/MultiChannelResampler.h
@@ -30,7 +30,7 @@
 #define MultiChannelResampler_h
 
 #include "core/platform/audio/SincResampler.h"
-#include <wtf/OwnPtr.h>
+#include "wtf/OwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/Panner.cpp b/Source/core/platform/audio/Panner.cpp
index 96ca460..30fca6e 100644
--- a/Source/core/platform/audio/Panner.cpp
+++ b/Source/core/platform/audio/Panner.cpp
@@ -34,7 +34,7 @@
 
 #include "core/platform/audio/EqualPowerPanner.h"
 #include "core/platform/audio/HRTFPanner.h"
-#include <wtf/OwnPtr.h>
+#include "wtf/OwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/Panner.h b/Source/core/platform/audio/Panner.h
index efd76d8..a7b3bc4 100644
--- a/Source/core/platform/audio/Panner.h
+++ b/Source/core/platform/audio/Panner.h
@@ -29,7 +29,7 @@
 #ifndef Panner_h
 #define Panner_h
 
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/Reverb.cpp b/Source/core/platform/audio/Reverb.cpp
index 8286543..2eb9a6c 100644
--- a/Source/core/platform/audio/Reverb.cpp
+++ b/Source/core/platform/audio/Reverb.cpp
@@ -36,9 +36,9 @@
 #include "core/platform/audio/AudioBus.h"
 #include "core/platform/audio/ReverbConvolver.h"
 #include "core/platform/audio/VectorMath.h"
-#include <wtf/MathExtras.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
+#include "wtf/MathExtras.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
 
 #if OS(DARWIN)
 using namespace std;
diff --git a/Source/core/platform/audio/Reverb.h b/Source/core/platform/audio/Reverb.h
index 37c9095..38e42da 100644
--- a/Source/core/platform/audio/Reverb.h
+++ b/Source/core/platform/audio/Reverb.h
@@ -30,7 +30,7 @@
 #define Reverb_h
 
 #include "core/platform/audio/ReverbConvolver.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/ReverbConvolver.h b/Source/core/platform/audio/ReverbConvolver.h
index 76b306f..04b8cde 100644
--- a/Source/core/platform/audio/ReverbConvolver.h
+++ b/Source/core/platform/audio/ReverbConvolver.h
@@ -35,10 +35,10 @@
 #include "core/platform/audio/ReverbAccumulationBuffer.h"
 #include "core/platform/audio/ReverbConvolverStage.h"
 #include "core/platform/audio/ReverbInputBuffer.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Threading.h>
-#include <wtf/Vector.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/Threading.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/ReverbConvolverStage.cpp b/Source/core/platform/audio/ReverbConvolverStage.cpp
index 2e65d6f..75c61dc 100644
--- a/Source/core/platform/audio/ReverbConvolverStage.cpp
+++ b/Source/core/platform/audio/ReverbConvolverStage.cpp
@@ -36,8 +36,8 @@
 #include "core/platform/audio/ReverbConvolver.h"
 #include "core/platform/audio/ReverbInputBuffer.h"
 #include "core/platform/audio/VectorMath.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/ReverbConvolverStage.h b/Source/core/platform/audio/ReverbConvolverStage.h
index f61ac1f..b71554c 100644
--- a/Source/core/platform/audio/ReverbConvolverStage.h
+++ b/Source/core/platform/audio/ReverbConvolverStage.h
@@ -31,7 +31,7 @@
 
 #include "core/platform/audio/AudioArray.h"
 #include "core/platform/audio/FFTFrame.h"
-#include <wtf/OwnPtr.h>
+#include "wtf/OwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/SincResampler.cpp b/Source/core/platform/audio/SincResampler.cpp
index cb070f8..4faf98e 100644
--- a/Source/core/platform/audio/SincResampler.cpp
+++ b/Source/core/platform/audio/SincResampler.cpp
@@ -33,7 +33,7 @@
 #include "core/platform/audio/SincResampler.h"
 
 #include "core/platform/audio/AudioBus.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 #ifdef __SSE2__
 #include <emmintrin.h>
diff --git a/Source/core/platform/audio/chromium/FFTFrameOpenMAXDLAndroid.cpp b/Source/core/platform/audio/chromium/FFTFrameOpenMAXDLAndroid.cpp
index 74e5e05..9f5d9ba 100644
--- a/Source/core/platform/audio/chromium/FFTFrameOpenMAXDLAndroid.cpp
+++ b/Source/core/platform/audio/chromium/FFTFrameOpenMAXDLAndroid.cpp
@@ -35,7 +35,7 @@
 #include "dl/sp/api/armSP.h"
 #include "dl/sp/api/omxSP.h"
 
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/audio/ffmpeg/FFTFrameFFMPEG.cpp b/Source/core/platform/audio/ffmpeg/FFTFrameFFMPEG.cpp
index fe177d9..761c613 100644
--- a/Source/core/platform/audio/ffmpeg/FFTFrameFFMPEG.cpp
+++ b/Source/core/platform/audio/ffmpeg/FFTFrameFFMPEG.cpp
@@ -40,7 +40,7 @@
     #include <libavcodec/avfft.h>
 }
 
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 namespace {
 
diff --git a/Source/core/platform/audio/ipp/FFTFrameIPP.cpp b/Source/core/platform/audio/ipp/FFTFrameIPP.cpp
index 85ebb87..b484d8c 100644
--- a/Source/core/platform/audio/ipp/FFTFrameIPP.cpp
+++ b/Source/core/platform/audio/ipp/FFTFrameIPP.cpp
@@ -37,7 +37,7 @@
 
 #include "core/platform/audio/VectorMath.h"
 
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/chromium/ChromiumDataObject.h b/Source/core/platform/chromium/ChromiumDataObject.h
index de69be5..1279f0f 100644
--- a/Source/core/platform/chromium/ChromiumDataObject.h
+++ b/Source/core/platform/chromium/ChromiumDataObject.h
@@ -33,12 +33,12 @@
 
 #include "core/platform/Supplementable.h"
 #include "core/platform/chromium/ChromiumDataObjectItem.h"
-#include <wtf/ListHashSet.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "wtf/ListHashSet.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/text/StringHash.h"
+#include "wtf/text/WTFString.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/chromium/ClipboardChromium.cpp b/Source/core/platform/chromium/ClipboardChromium.cpp
index bd63bdb..ae03d4c 100644
--- a/Source/core/platform/chromium/ClipboardChromium.cpp
+++ b/Source/core/platform/chromium/ClipboardChromium.cpp
@@ -48,7 +48,7 @@
 #include "core/platform/graphics/Image.h"
 #include "core/rendering/RenderImage.h"
 
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
@@ -364,32 +364,38 @@
     if (!imageBuffer || !imageBuffer->size())
         return;
 
+    String imageExtension = cachedImage->image()->filenameExtension();
+    ASSERT(!imageExtension.isEmpty());
+
     // Determine the filename for the file contents of the image.
     String filename = cachedImage->response().suggestedFilename();
-    String extension;
     if (filename.isEmpty())
         filename = url.lastPathComponent();
-    if (filename.isEmpty())
+
+    String fileExtension;
+    if (filename.isEmpty()) {
         filename = element->getAttribute(altAttr);
-    else {
+    } else {
         // Strip any existing extension. Assume that alt text is usually not a filename.
         int extensionIndex = filename.reverseFind('.');
         if (extensionIndex != -1) {
-            extension = filename.substring(extensionIndex + 1);
+            fileExtension = filename.substring(extensionIndex + 1);
             filename.truncate(extensionIndex);
         }
     }
 
-    String extensionMimeType = MIMETypeRegistry::getMIMETypeForExtension(extension);
-    if (extensionMimeType != cachedImage->response().mimeType()) {
-        extension = MIMETypeRegistry::getPreferredExtensionForMIMEType(
-            cachedImage->response().mimeType());
+    if (!fileExtension.isEmpty() && fileExtension != imageExtension) {
+        String imageMimeType = MIMETypeRegistry::getMIMETypeForExtension(imageExtension);
+        ASSERT(imageMimeType.startsWith("image/"));
+        // Use the file extension only if it has imageMimeType: it's untrustworthy otherwise.
+        if (imageMimeType == MIMETypeRegistry::getMIMETypeForExtension(fileExtension))
+            imageExtension = fileExtension;
     }
 
-    extension = extension.isEmpty() ? emptyString() : "." + extension;
-    ClipboardChromium::validateFilename(filename, extension);
+    imageExtension = "." + imageExtension;
+    ClipboardChromium::validateFilename(filename, imageExtension);
 
-    dataObject->addSharedBuffer(filename + extension, imageBuffer);
+    dataObject->addSharedBuffer(filename + imageExtension, imageBuffer);
 }
 
 void ClipboardChromium::declareAndWriteDragImage(Element* element, const KURL& url, const String& title, Frame* frame)
diff --git a/Source/core/platform/chromium/ClipboardUtilitiesChromium.h b/Source/core/platform/chromium/ClipboardUtilitiesChromium.h
index 9ef3680..173f383 100644
--- a/Source/core/platform/chromium/ClipboardUtilitiesChromium.h
+++ b/Source/core/platform/chromium/ClipboardUtilitiesChromium.h
@@ -32,7 +32,7 @@
 #define ClipboardUtilitiesChromium_h
 
 #include "public/platform/WebClipboard.h"
-#include <wtf/Forward.h>
+#include "wtf/Forward.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/chromium/FileSystemChromium.cpp b/Source/core/platform/chromium/FileSystemChromium.cpp
index b798f54..05f6166 100644
--- a/Source/core/platform/chromium/FileSystemChromium.cpp
+++ b/Source/core/platform/chromium/FileSystemChromium.cpp
@@ -37,7 +37,7 @@
 #include "public/platform/Platform.h"
 #include "public/platform/WebFileInfo.h"
 #include "public/platform/WebFileUtilities.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/chromium/LanguageChromium.cpp b/Source/core/platform/chromium/LanguageChromium.cpp
index a8482f2..360af74 100644
--- a/Source/core/platform/chromium/LanguageChromium.cpp
+++ b/Source/core/platform/chromium/LanguageChromium.cpp
@@ -32,8 +32,8 @@
 #include "core/platform/Language.h"
 
 #include "public/platform/Platform.h"
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "wtf/text/WTFString.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/chromium/LocalizedStringsChromium.cpp b/Source/core/platform/chromium/LocalizedStringsChromium.cpp
index 59ace7a..b72a813 100644
--- a/Source/core/platform/chromium/LocalizedStringsChromium.cpp
+++ b/Source/core/platform/chromium/LocalizedStringsChromium.cpp
@@ -38,8 +38,8 @@
 #include "public/platform/Platform.h"
 #include "public/platform/WebLocalizedString.h"
 #include "public/platform/WebString.h"
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/text/StringBuilder.h"
+#include "wtf/text/WTFString.h"
 
 using WebKit::WebLocalizedString;
 using WebKit::WebString;
diff --git a/Source/core/platform/chromium/MIMETypeRegistryChromium.cpp b/Source/core/platform/chromium/MIMETypeRegistryChromium.cpp
index 56cfad9..bab382c 100644
--- a/Source/core/platform/chromium/MIMETypeRegistryChromium.cpp
+++ b/Source/core/platform/chromium/MIMETypeRegistryChromium.cpp
@@ -35,7 +35,7 @@
 
 #include "public/platform/Platform.h"
 #include "public/platform/WebMimeRegistry.h"
-#include <wtf/text/CString.h>
+#include "wtf/text/CString.h"
 
 // NOTE: Unlike other ports, we don't use the shared implementation in
 // MIMETypeRegistry.cpp.  Instead, we need to route most functions via
diff --git a/Source/core/platform/chromium/MemoryUsageSupportChromium.cpp b/Source/core/platform/chromium/MemoryUsageSupportChromium.cpp
index cd194cc..2975d48 100644
--- a/Source/core/platform/chromium/MemoryUsageSupportChromium.cpp
+++ b/Source/core/platform/chromium/MemoryUsageSupportChromium.cpp
@@ -33,7 +33,7 @@
 
 #include <SkGraphics.h>
 #include "public/platform/Platform.h"
-#include <wtf/OwnPtr.h>
+#include "wtf/OwnPtr.h"
 
 namespace WebCore {
 
@@ -69,13 +69,4 @@
     WebKit::Platform::current()->requestProcessMemorySizes(callback);
 }
 
-void MemoryUsageSupport::memoryUsageByComponents(Vector<ComponentInfo>& components)
-{
-    size_t size = SkGraphics::GetFontCacheUsed();
-    components.append(ComponentInfo("GlyphCache", size));
-
-    if (WebKit::Platform::current()->memoryAllocatorWasteInBytes(&size))
-        components.append(ComponentInfo("MallocWaste", size));
-}
-
 } // namespace WebCore
diff --git a/Source/core/platform/chromium/PlatformSpeechSynthesizerChromium.cpp b/Source/core/platform/chromium/PlatformSpeechSynthesizerChromium.cpp
index 333eb0c..370c43a 100644
--- a/Source/core/platform/chromium/PlatformSpeechSynthesizerChromium.cpp
+++ b/Source/core/platform/chromium/PlatformSpeechSynthesizerChromium.cpp
@@ -38,7 +38,7 @@
 #include "public/platform/WebSpeechSynthesisUtterance.h"
 #include "public/platform/WebSpeechSynthesizer.h"
 #include "public/platform/WebSpeechSynthesizerClient.h"
-#include <wtf/RetainPtr.h>
+#include "wtf/RetainPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/chromium/SSLKeyGeneratorChromium.cpp b/Source/core/platform/chromium/SSLKeyGeneratorChromium.cpp
index 5f3187c..80ef10b 100644
--- a/Source/core/platform/chromium/SSLKeyGeneratorChromium.cpp
+++ b/Source/core/platform/chromium/SSLKeyGeneratorChromium.cpp
@@ -34,7 +34,7 @@
 #include "public/platform/Platform.h"
 #include "public/platform/WebString.h"
 #include "public/platform/WebURL.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/chromium/TraceEvent.h b/Source/core/platform/chromium/TraceEvent.h
index 0af2ab7..e9dc7e1 100644
--- a/Source/core/platform/chromium/TraceEvent.h
+++ b/Source/core/platform/chromium/TraceEvent.h
@@ -165,8 +165,8 @@
 
 #include "core/platform/EventTracer.h"
 
-#include <wtf/DynamicAnnotations.h>
-#include <wtf/text/CString.h>
+#include "wtf/DynamicAnnotations.h"
+#include "wtf/text/CString.h"
 
 // By default, const char* argument values are assumed to have long-lived scope
 // and will not be copied. Use this macro to force a const char* to be copied.
diff --git a/Source/core/platform/chromium/support/WebActiveGestureAnimation.h b/Source/core/platform/chromium/support/WebActiveGestureAnimation.h
index 652e1bf..71a158e 100644
--- a/Source/core/platform/chromium/support/WebActiveGestureAnimation.h
+++ b/Source/core/platform/chromium/support/WebActiveGestureAnimation.h
@@ -26,9 +26,9 @@
 #ifndef WebActiveGestureAnimation_h
 #define WebActiveGestureAnimation_h
 
-#include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
+#include "wtf/Noncopyable.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
 
 namespace WebKit {
 
diff --git a/Source/core/platform/chromium/support/WebAudioBus.cpp b/Source/core/platform/chromium/support/WebAudioBus.cpp
index 5f5947a..666e1c5 100644
--- a/Source/core/platform/chromium/support/WebAudioBus.cpp
+++ b/Source/core/platform/chromium/support/WebAudioBus.cpp
@@ -28,7 +28,7 @@
 #if ENABLE(WEB_AUDIO)
 #include "core/platform/audio/AudioBus.h"
 #else
-#include <wtf/ThreadSafeRefCounted.h>
+#include "wtf/ThreadSafeRefCounted.h"
 
 namespace WebCore {
 class AudioBus : public ThreadSafeRefCounted<AudioBus> {
@@ -36,8 +36,8 @@
 } // namespace WebCore
 #endif
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
 
 using namespace WebCore;
 
diff --git a/Source/core/platform/chromium/support/WebCString.cpp b/Source/core/platform/chromium/support/WebCString.cpp
index c49f9a4..4077ca3 100644
--- a/Source/core/platform/chromium/support/WebCString.cpp
+++ b/Source/core/platform/chromium/support/WebCString.cpp
@@ -33,7 +33,7 @@
 #include "public/platform/WebCString.h"
 
 #include "public/platform/WebString.h"
-#include <wtf/text/CString.h>
+#include "wtf/text/CString.h"
 
 namespace WebKit {
 
diff --git a/Source/core/platform/chromium/support/WebMediaStream.cpp b/Source/core/platform/chromium/support/WebMediaStream.cpp
index 37784f7..d89f23e 100644
--- a/Source/core/platform/chromium/support/WebMediaStream.cpp
+++ b/Source/core/platform/chromium/support/WebMediaStream.cpp
@@ -33,9 +33,9 @@
 #include "public/platform/WebMediaStreamSource.h"
 #include "public/platform/WebMediaStreamTrack.h"
 #include "public/platform/WebString.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Vector.h"
 
 using namespace WebCore;
 
diff --git a/Source/core/platform/chromium/support/WebMediaStreamTrack.cpp b/Source/core/platform/chromium/support/WebMediaStreamTrack.cpp
index 9a2a7da..a671a60 100644
--- a/Source/core/platform/chromium/support/WebMediaStreamTrack.cpp
+++ b/Source/core/platform/chromium/support/WebMediaStreamTrack.cpp
@@ -31,7 +31,7 @@
 #include "public/platform/WebMediaStream.h"
 #include "public/platform/WebMediaStreamSource.h"
 #include "public/platform/WebString.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 using namespace WebCore;
 
diff --git a/Source/core/platform/chromium/support/WebPrerender.cpp b/Source/core/platform/chromium/support/WebPrerender.cpp
index df6d402..55d354e 100644
--- a/Source/core/platform/chromium/support/WebPrerender.cpp
+++ b/Source/core/platform/chromium/support/WebPrerender.cpp
@@ -30,7 +30,7 @@
 
 #include "config.h"
 #include "public/platform/WebPrerender.h"
-#include <wtf/PassRefPtr.h>
+#include "wtf/PassRefPtr.h"
 
 #include "core/platform/chromium/Prerender.h"
 
diff --git a/Source/core/platform/chromium/support/WebRTCSessionDescriptionRequest.cpp b/Source/core/platform/chromium/support/WebRTCSessionDescriptionRequest.cpp
index 07da4ae..7575a51 100644
--- a/Source/core/platform/chromium/support/WebRTCSessionDescriptionRequest.cpp
+++ b/Source/core/platform/chromium/support/WebRTCSessionDescriptionRequest.cpp
@@ -34,7 +34,7 @@
 
 #include "core/platform/mediastream/RTCSessionDescriptionRequest.h"
 #include "public/platform/WebRTCSessionDescription.h"
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 using namespace WebCore;
 
diff --git a/Source/core/platform/chromium/support/WebRTCStatsRequest.cpp b/Source/core/platform/chromium/support/WebRTCStatsRequest.cpp
index e69c0db..c5c925a 100644
--- a/Source/core/platform/chromium/support/WebRTCStatsRequest.cpp
+++ b/Source/core/platform/chromium/support/WebRTCStatsRequest.cpp
@@ -37,7 +37,7 @@
 #include "public/platform/WebMediaStream.h"
 #include "public/platform/WebMediaStreamTrack.h"
 #include "public/platform/WebRTCStatsResponse.h"
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 using namespace WebCore;
 
diff --git a/Source/core/platform/chromium/support/WebRTCStatsResponse.cpp b/Source/core/platform/chromium/support/WebRTCStatsResponse.cpp
index 859beec..59a6191 100644
--- a/Source/core/platform/chromium/support/WebRTCStatsResponse.cpp
+++ b/Source/core/platform/chromium/support/WebRTCStatsResponse.cpp
@@ -27,7 +27,7 @@
 #include "public/platform/WebRTCStatsResponse.h"
 
 #include "core/platform/mediastream/RTCStatsResponseBase.h"
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 using namespace WebCore;
 
diff --git a/Source/core/platform/chromium/support/WebRTCVoidRequest.cpp b/Source/core/platform/chromium/support/WebRTCVoidRequest.cpp
index 91075d3..0f5603b 100644
--- a/Source/core/platform/chromium/support/WebRTCVoidRequest.cpp
+++ b/Source/core/platform/chromium/support/WebRTCVoidRequest.cpp
@@ -33,7 +33,7 @@
 #include "public/platform/WebRTCVoidRequest.h"
 
 #include "core/platform/mediastream/RTCVoidRequest.h"
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 using namespace WebCore;
 
diff --git a/Source/core/platform/chromium/support/WebScrollbarThemeGeometryNative.h b/Source/core/platform/chromium/support/WebScrollbarThemeGeometryNative.h
index f85cd55..3c83bdd 100644
--- a/Source/core/platform/chromium/support/WebScrollbarThemeGeometryNative.h
+++ b/Source/core/platform/chromium/support/WebScrollbarThemeGeometryNative.h
@@ -28,7 +28,7 @@
 
 #include "public/platform/WebRect.h"
 #include "public/platform/WebScrollbarThemeGeometry.h"
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
 class ScrollbarThemeComposite;
diff --git a/Source/core/platform/chromium/support/WebSpeechSynthesisUtterance.cpp b/Source/core/platform/chromium/support/WebSpeechSynthesisUtterance.cpp
index d416028..9a511a2 100644
--- a/Source/core/platform/chromium/support/WebSpeechSynthesisUtterance.cpp
+++ b/Source/core/platform/chromium/support/WebSpeechSynthesisUtterance.cpp
@@ -28,8 +28,8 @@
 #include "public/platform/WebSpeechSynthesisUtterance.h"
 
 #include "core/platform/PlatformSpeechSynthesisUtterance.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
 
 using namespace WebCore;
 
diff --git a/Source/core/platform/chromium/support/WebSpeechSynthesisVoice.cpp b/Source/core/platform/chromium/support/WebSpeechSynthesisVoice.cpp
index 7a31aa8..1fcbd29 100644
--- a/Source/core/platform/chromium/support/WebSpeechSynthesisVoice.cpp
+++ b/Source/core/platform/chromium/support/WebSpeechSynthesisVoice.cpp
@@ -28,8 +28,8 @@
 
 #include "modules/speech/SpeechRecognitionAlternative.h"
 #include "modules/speech/SpeechSynthesisVoice.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebKit {
 
diff --git a/Source/core/platform/chromium/support/WebSpeechSynthesizerClientImpl.h b/Source/core/platform/chromium/support/WebSpeechSynthesizerClientImpl.h
index d9e4bb3..91681a1 100644
--- a/Source/core/platform/chromium/support/WebSpeechSynthesizerClientImpl.h
+++ b/Source/core/platform/chromium/support/WebSpeechSynthesizerClientImpl.h
@@ -30,8 +30,8 @@
 #include "public/platform/WebSpeechSynthesisUtterance.h"
 #include "public/platform/WebSpeechSynthesisVoice.h"
 #include "public/platform/WebSpeechSynthesizerClient.h"
-#include <wtf/HashMap.h>
-#include <wtf/Vector.h>
+#include "wtf/HashMap.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/chromium/support/WebString.cpp b/Source/core/platform/chromium/support/WebString.cpp
index 64847e3..d110a8c 100644
--- a/Source/core/platform/chromium/support/WebString.cpp
+++ b/Source/core/platform/chromium/support/WebString.cpp
@@ -32,9 +32,9 @@
 #include "public/platform/WebString.h"
 
 #include "public/platform/WebCString.h"
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/text/AtomicString.h"
+#include "wtf/text/CString.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebKit {
 
diff --git a/Source/core/platform/chromium/support/WebURLResponse.cpp b/Source/core/platform/chromium/support/WebURLResponse.cpp
index 5cca628..1ca9712 100644
--- a/Source/core/platform/chromium/support/WebURLResponse.cpp
+++ b/Source/core/platform/chromium/support/WebURLResponse.cpp
@@ -39,7 +39,7 @@
 #include "public/platform/WebString.h"
 #include "public/platform/WebURL.h"
 #include "public/platform/WebURLLoadTiming.h"
-#include <wtf/RefPtr.h>
+#include "wtf/RefPtr.h"
 
 using namespace WebCore;
 
diff --git a/Source/core/platform/cocoa/KeyEventCocoa.h b/Source/core/platform/cocoa/KeyEventCocoa.h
index d6e206e..f45c593 100644
--- a/Source/core/platform/cocoa/KeyEventCocoa.h
+++ b/Source/core/platform/cocoa/KeyEventCocoa.h
@@ -26,7 +26,7 @@
 #ifndef KeyEventCocoa_h
 #define KeyEventCocoa_h
 
-#include <wtf/Forward.h>
+#include "wtf/Forward.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/ANGLEWebKitBridge.cpp b/Source/core/platform/graphics/ANGLEWebKitBridge.cpp
index a19e9a3..7e6ac3d 100644
--- a/Source/core/platform/graphics/ANGLEWebKitBridge.cpp
+++ b/Source/core/platform/graphics/ANGLEWebKitBridge.cpp
@@ -26,7 +26,7 @@
 #include "config.h"
 
 #include "core/platform/graphics/ANGLEWebKitBridge.h"
-#include <wtf/OwnArrayPtr.h>
+#include "wtf/OwnArrayPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/ANGLEWebKitBridge.h b/Source/core/platform/graphics/ANGLEWebKitBridge.h
index d4518c4..12757ac 100644
--- a/Source/core/platform/graphics/ANGLEWebKitBridge.h
+++ b/Source/core/platform/graphics/ANGLEWebKitBridge.h
@@ -26,8 +26,8 @@
 #ifndef ANGLEWebKitBridge_h
 #define ANGLEWebKitBridge_h
 
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/text/CString.h"
+#include "wtf/text/WTFString.h"
 
 #include "ShaderLang.h"
 
diff --git a/Source/core/platform/graphics/Color.cpp b/Source/core/platform/graphics/Color.cpp
index 568815d..2be4404 100644
--- a/Source/core/platform/graphics/Color.cpp
+++ b/Source/core/platform/graphics/Color.cpp
@@ -27,11 +27,11 @@
 #include "core/platform/graphics/Color.h"
 
 #include "core/platform/HashTools.h"
-#include <wtf/Assertions.h>
-#include <wtf/DecimalNumber.h>
-#include <wtf/HexNumber.h>
-#include <wtf/MathExtras.h>
-#include <wtf/text/StringBuilder.h>
+#include "wtf/Assertions.h"
+#include "wtf/DecimalNumber.h"
+#include "wtf/HexNumber.h"
+#include "wtf/MathExtras.h"
+#include "wtf/text/StringBuilder.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/graphics/Color.h b/Source/core/platform/graphics/Color.h
index 8753060..1288d4b 100644
--- a/Source/core/platform/graphics/Color.h
+++ b/Source/core/platform/graphics/Color.h
@@ -27,9 +27,9 @@
 #define Color_h
 
 #include "core/platform/animation/AnimationUtilities.h"
-#include <wtf/FastAllocBase.h>
-#include <wtf/Forward.h>
-#include <wtf/unicode/Unicode.h>
+#include "wtf/FastAllocBase.h"
+#include "wtf/Forward.h"
+#include "wtf/unicode/Unicode.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/CrossfadeGeneratedImage.h b/Source/core/platform/graphics/CrossfadeGeneratedImage.h
index 1f52692..4090d7a 100644
--- a/Source/core/platform/graphics/CrossfadeGeneratedImage.h
+++ b/Source/core/platform/graphics/CrossfadeGeneratedImage.h
@@ -30,7 +30,7 @@
 #include "core/platform/graphics/Image.h"
 #include "core/platform/graphics/ImageObserver.h"
 #include "core/platform/graphics/IntSize.h"
-#include <wtf/RefPtr.h>
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/DashArray.h b/Source/core/platform/graphics/DashArray.h
index 4f6ab3d..1a59f53 100644
--- a/Source/core/platform/graphics/DashArray.h
+++ b/Source/core/platform/graphics/DashArray.h
@@ -26,7 +26,7 @@
 #ifndef DashArray_h
 #define DashArray_h
 
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 typedef float DashArrayElement;
 
diff --git a/Source/core/platform/graphics/Extensions3D.cpp b/Source/core/platform/graphics/Extensions3D.cpp
index 0502138..2a9342b 100644
--- a/Source/core/platform/graphics/Extensions3D.cpp
+++ b/Source/core/platform/graphics/Extensions3D.cpp
@@ -30,7 +30,7 @@
 #include "core/platform/NotImplemented.h"
 #include "core/platform/graphics/GraphicsContext3D.h"
 #include "public/platform/WebGraphicsContext3D.h"
-#include <wtf/text/CString.h>
+#include "wtf/text/CString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/Extensions3D.h b/Source/core/platform/graphics/Extensions3D.h
index 4000829..b1ddf79 100644
--- a/Source/core/platform/graphics/Extensions3D.h
+++ b/Source/core/platform/graphics/Extensions3D.h
@@ -28,7 +28,7 @@
 
 #include "core/platform/graphics/GraphicsTypes3D.h"
 
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/FloatPolygon.cpp b/Source/core/platform/graphics/FloatPolygon.cpp
index ff1b39a..0fe4893 100644
--- a/Source/core/platform/graphics/FloatPolygon.cpp
+++ b/Source/core/platform/graphics/FloatPolygon.cpp
@@ -30,7 +30,7 @@
 #include "config.h"
 #include "core/platform/graphics/FloatPolygon.h"
 
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/FloatPolygon.h b/Source/core/platform/graphics/FloatPolygon.h
index d09c936..5fa75a2 100644
--- a/Source/core/platform/graphics/FloatPolygon.h
+++ b/Source/core/platform/graphics/FloatPolygon.h
@@ -34,9 +34,9 @@
 #include "core/platform/graphics/FloatPoint.h"
 #include "core/platform/graphics/FloatRect.h"
 #include "core/platform/graphics/WindRule.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/FloatRect.h b/Source/core/platform/graphics/FloatRect.h
index b5aa3e4..fc17a27 100644
--- a/Source/core/platform/graphics/FloatRect.h
+++ b/Source/core/platform/graphics/FloatRect.h
@@ -28,7 +28,7 @@
 #define FloatRect_h
 
 #include "core/platform/graphics/FloatPoint.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 #if OS(DARWIN)
 typedef struct CGRect CGRect;
diff --git a/Source/core/platform/graphics/FloatSize.h b/Source/core/platform/graphics/FloatSize.h
index 9dcc46a..e9606f0 100644
--- a/Source/core/platform/graphics/FloatSize.h
+++ b/Source/core/platform/graphics/FloatSize.h
@@ -29,7 +29,7 @@
 #define FloatSize_h
 
 #include "core/platform/graphics/IntPoint.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 
 #if OS(DARWIN)
diff --git a/Source/core/platform/graphics/Font.cpp b/Source/core/platform/graphics/Font.cpp
index f948c7e..6ad8d47 100644
--- a/Source/core/platform/graphics/Font.cpp
+++ b/Source/core/platform/graphics/Font.cpp
@@ -28,10 +28,10 @@
 #include "core/platform/graphics/TextRun.h"
 #include "core/platform/graphics/WidthIterator.h"
 #include "core/platform/text/transcoder/FontTranscoder.h"
-#include <wtf/MainThread.h>
-#include <wtf/MathExtras.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/UnusedParam.h>
+#include "wtf/MainThread.h"
+#include "wtf/MathExtras.h"
+#include "wtf/text/StringBuilder.h"
+#include "wtf/UnusedParam.h"
 
 using namespace WTF;
 using namespace Unicode;
diff --git a/Source/core/platform/graphics/Font.h b/Source/core/platform/graphics/Font.h
index 117a942..429a506 100644
--- a/Source/core/platform/graphics/Font.h
+++ b/Source/core/platform/graphics/Font.h
@@ -30,10 +30,10 @@
 #include "core/platform/graphics/SimpleFontData.h"
 #include "core/platform/graphics/TypesettingFeatures.h"
 #include "core/platform/text/TextDirection.h"
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/MathExtras.h>
-#include <wtf/unicode/CharacterNames.h>
+#include "wtf/HashMap.h"
+#include "wtf/HashSet.h"
+#include "wtf/MathExtras.h"
+#include "wtf/unicode/CharacterNames.h"
 
 // "X11/X.h" defines Complex to 0 and conflicts
 // with Complex value in CodePath enum.
diff --git a/Source/core/platform/graphics/FontCache.h b/Source/core/platform/graphics/FontCache.h
index 2058738..d7d194a 100644
--- a/Source/core/platform/graphics/FontCache.h
+++ b/Source/core/platform/graphics/FontCache.h
@@ -31,12 +31,12 @@
 #define FontCache_h
 
 #include <limits.h>
-#include <wtf/Forward.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/unicode/Unicode.h>
+#include "wtf/Forward.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
+#include "wtf/unicode/Unicode.h"
 
 #if OS(WINDOWS)
 #include <windows.h>
diff --git a/Source/core/platform/graphics/FontData.h b/Source/core/platform/graphics/FontData.h
index 6e6e19f..b710095 100644
--- a/Source/core/platform/graphics/FontData.h
+++ b/Source/core/platform/graphics/FontData.h
@@ -26,12 +26,12 @@
 #ifndef FontData_h
 #define FontData_h
 
-#include <wtf/FastAllocBase.h>
-#include <wtf/Forward.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/unicode/Unicode.h>
+#include "wtf/FastAllocBase.h"
+#include "wtf/Forward.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/unicode/Unicode.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/FontDescription.h b/Source/core/platform/graphics/FontDescription.h
index 66ab2b9..eebb777 100644
--- a/Source/core/platform/graphics/FontDescription.h
+++ b/Source/core/platform/graphics/FontDescription.h
@@ -34,9 +34,9 @@
 #include "core/platform/graphics/FontWidthVariant.h"
 #include "core/platform/graphics/TextRenderingMode.h"
 #include "core/platform/text/NonCJKGlyphOrientation.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
-#include <wtf/RefPtr.h>
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/FontFallbackList.h b/Source/core/platform/graphics/FontFallbackList.h
index a0f631a..c78a2af 100644
--- a/Source/core/platform/graphics/FontFallbackList.h
+++ b/Source/core/platform/graphics/FontFallbackList.h
@@ -24,8 +24,8 @@
 #include "core/platform/graphics/FontSelector.h"
 #include "core/platform/graphics/SimpleFontData.h"
 #include "core/platform/graphics/WidthCache.h"
-#include <wtf/Forward.h>
-#include <wtf/MainThread.h>
+#include "wtf/Forward.h"
+#include "wtf/MainThread.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/FontFamily.h b/Source/core/platform/graphics/FontFamily.h
index a25c6a1..c1aa3ff 100644
--- a/Source/core/platform/graphics/FontFamily.h
+++ b/Source/core/platform/graphics/FontFamily.h
@@ -26,9 +26,9 @@
 #ifndef FontFamily_h
 #define FontFamily_h
 
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/AtomicString.h>
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/text/AtomicString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/FontFastPath.cpp b/Source/core/platform/graphics/FontFastPath.cpp
index 977e5c8..ded212c 100644
--- a/Source/core/platform/graphics/FontFastPath.cpp
+++ b/Source/core/platform/graphics/FontFastPath.cpp
@@ -31,10 +31,10 @@
 #include "core/platform/graphics/SimpleFontData.h"
 #include "core/platform/graphics/TextRun.h"
 #include "core/platform/graphics/WidthIterator.h"
-#include <wtf/MainThread.h>
-#include <wtf/MathExtras.h>
-#include <wtf/unicode/CharacterNames.h>
-#include <wtf/unicode/Unicode.h>
+#include "wtf/MainThread.h"
+#include "wtf/MathExtras.h"
+#include "wtf/unicode/CharacterNames.h"
+#include "wtf/unicode/Unicode.h"
 
 using namespace WTF;
 using namespace Unicode;
diff --git a/Source/core/platform/graphics/FontFeatureSettings.h b/Source/core/platform/graphics/FontFeatureSettings.h
index 1bd9b33..b40c4bf 100644
--- a/Source/core/platform/graphics/FontFeatureSettings.h
+++ b/Source/core/platform/graphics/FontFeatureSettings.h
@@ -26,11 +26,11 @@
 #ifndef FontFeatureSettings_h
 #define FontFeatureSettings_h
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
-#include <wtf/text/AtomicString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
+#include "wtf/text/AtomicString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/FontMetrics.h b/Source/core/platform/graphics/FontMetrics.h
index 6714887..d8ac0b0 100644
--- a/Source/core/platform/graphics/FontMetrics.h
+++ b/Source/core/platform/graphics/FontMetrics.h
@@ -21,7 +21,7 @@
 #define FontMetrics_h
 
 #include "core/platform/graphics/FontBaseline.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/FontPlatformData.cpp b/Source/core/platform/graphics/FontPlatformData.cpp
index 539f2b4..06b9cca 100644
--- a/Source/core/platform/graphics/FontPlatformData.cpp
+++ b/Source/core/platform/graphics/FontPlatformData.cpp
@@ -21,11 +21,11 @@
 #include "config.h"
 #include "core/platform/graphics/FontPlatformData.h"
 
-#include <wtf/HashMap.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "wtf/HashMap.h"
+#include "wtf/RetainPtr.h"
+#include "wtf/text/StringHash.h"
+#include "wtf/text/WTFString.h"
+#include "wtf/Vector.h"
 
 #if OS(DARWIN)
 #include "core/platform/graphics/harfbuzz/HarfBuzzFace.h"
diff --git a/Source/core/platform/graphics/FontSelector.h b/Source/core/platform/graphics/FontSelector.h
index aaaaae2..4f5469c 100644
--- a/Source/core/platform/graphics/FontSelector.h
+++ b/Source/core/platform/graphics/FontSelector.h
@@ -26,9 +26,9 @@
 #ifndef FontSelector_h
 #define FontSelector_h
 
-#include <wtf/Forward.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
+#include "wtf/Forward.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/GeneratorGeneratedImage.h b/Source/core/platform/graphics/GeneratorGeneratedImage.h
index eeac3f1..1b7b0f3 100644
--- a/Source/core/platform/graphics/GeneratorGeneratedImage.h
+++ b/Source/core/platform/graphics/GeneratorGeneratedImage.h
@@ -32,7 +32,7 @@
 #include "core/platform/graphics/Image.h"
 #include "core/platform/graphics/ImageBuffer.h"
 #include "core/platform/graphics/IntSize.h"
-#include <wtf/RefPtr.h>
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/GlyphBuffer.h b/Source/core/platform/graphics/GlyphBuffer.h
index 1375588..d3cf331 100644
--- a/Source/core/platform/graphics/GlyphBuffer.h
+++ b/Source/core/platform/graphics/GlyphBuffer.h
@@ -32,8 +32,8 @@
 
 #include "core/platform/graphics/FloatSize.h"
 #include "core/platform/graphics/Glyph.h"
-#include <wtf/UnusedParam.h>
-#include <wtf/Vector.h>
+#include "wtf/UnusedParam.h"
+#include "wtf/Vector.h"
 
 #if OS(DARWIN)
 #include <ApplicationServices/ApplicationServices.h>
diff --git a/Source/core/platform/graphics/GlyphPage.h b/Source/core/platform/graphics/GlyphPage.h
index caa3007..cf39d98 100644
--- a/Source/core/platform/graphics/GlyphPage.h
+++ b/Source/core/platform/graphics/GlyphPage.h
@@ -32,10 +32,10 @@
 
 #include <string.h>
 #include "core/platform/graphics/Glyph.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/unicode/Unicode.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/unicode/Unicode.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/GlyphPageTreeNode.cpp b/Source/core/platform/graphics/GlyphPageTreeNode.cpp
index 1a03ee3..912a59d 100644
--- a/Source/core/platform/graphics/GlyphPageTreeNode.cpp
+++ b/Source/core/platform/graphics/GlyphPageTreeNode.cpp
@@ -33,10 +33,10 @@
 #include "core/platform/graphics/SegmentedFontData.h"
 #include "core/platform/graphics/SimpleFontData.h"
 #include "core/platform/graphics/opentype/OpenTypeVerticalData.h"
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/unicode/CharacterNames.h>
-#include <wtf/unicode/Unicode.h>
+#include "wtf/text/CString.h"
+#include "wtf/text/WTFString.h"
+#include "wtf/unicode/CharacterNames.h"
+#include "wtf/unicode/Unicode.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/GlyphPageTreeNode.h b/Source/core/platform/graphics/GlyphPageTreeNode.h
index 6ee83af..def0192 100644
--- a/Source/core/platform/graphics/GlyphPageTreeNode.h
+++ b/Source/core/platform/graphics/GlyphPageTreeNode.h
@@ -31,11 +31,11 @@
 
 #include <string.h>
 #include "core/platform/graphics/GlyphPage.h"
-#include <wtf/HashMap.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/unicode/Unicode.h>
+#include "wtf/HashMap.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/unicode/Unicode.h"
 
 #ifndef NDEBUG
 void showGlyphPageTrees();
diff --git a/Source/core/platform/graphics/GraphicsContext.cpp b/Source/core/platform/graphics/GraphicsContext.cpp
index c9da39c..c3a16ac 100644
--- a/Source/core/platform/graphics/GraphicsContext.cpp
+++ b/Source/core/platform/graphics/GraphicsContext.cpp
@@ -806,20 +806,14 @@
     originY *= deviceScaleFactor;
 #endif
 
-    // Make a shader for the bitmap with an origin of the box we'll draw. This
-    // shader is refcounted and will have an initial refcount of 1.
-    SkShader* shader = SkShader::CreateBitmapShader(
-        *misspellBitmap[index], SkShader::kRepeat_TileMode,
-        SkShader::kRepeat_TileMode);
+    RefPtr<SkShader> shader = adoptRef(SkShader::CreateBitmapShader(
+        *misspellBitmap[index], SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode));
     SkMatrix matrix;
     matrix.setTranslate(originX, originY);
     shader->setLocalMatrix(matrix);
 
-    // Assign the shader to the paint & release our reference. The paint will
-    // now own the shader and the shader will be destroyed when the paint goes
-    // out of scope.
     SkPaint paint;
-    paint.setShader(shader)->unref();
+    paint.setShader(shader.get());
 
     SkRect rect;
     rect.set(originX, originY, originX + WebCoreFloatToSkScalar(width) * deviceScaleFactor, originY + SkIntToScalar(misspellBitmap[index]->height()));
@@ -1861,7 +1855,7 @@
 
 void GraphicsContext::setupShader(SkPaint* paint, Gradient* grad, Pattern* pat, SkColor color) const
 {
-    SkShader* shader = 0;
+    RefPtr<SkShader> shader;
 
     if (grad) {
         shader = grad->shader();
@@ -1873,7 +1867,7 @@
     }
 
     paint->setColor(m_state->applyAlpha(color));
-    paint->setShader(shader);
+    paint->setShader(shader.get());
 }
 
 
diff --git a/Source/core/platform/graphics/GraphicsLayerFactory.h b/Source/core/platform/graphics/GraphicsLayerFactory.h
index 3a0eb7a..da054e8 100644
--- a/Source/core/platform/graphics/GraphicsLayerFactory.h
+++ b/Source/core/platform/graphics/GraphicsLayerFactory.h
@@ -26,7 +26,7 @@
 #ifndef GraphicsLayerFactory_h
 #define GraphicsLayerFactory_h
 
-#include <wtf/Forward.h>
+#include "wtf/Forward.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/GraphicsTypes.cpp b/Source/core/platform/graphics/GraphicsTypes.cpp
index ddb8bea..ba9886f 100644
--- a/Source/core/platform/graphics/GraphicsTypes.cpp
+++ b/Source/core/platform/graphics/GraphicsTypes.cpp
@@ -27,8 +27,8 @@
 #include "config.h"
 #include "core/platform/graphics/GraphicsTypes.h"
 
-#include <wtf/Assertions.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Assertions.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/GraphicsTypes3D.h b/Source/core/platform/graphics/GraphicsTypes3D.h
index 1fa8eaa..a593cc8 100644
--- a/Source/core/platform/graphics/GraphicsTypes3D.h
+++ b/Source/core/platform/graphics/GraphicsTypes3D.h
@@ -26,7 +26,7 @@
 #ifndef GraphicsTypes3D_h
 #define GraphicsTypes3D_h
 
-#include <wtf/Forward.h>
+#include "wtf/Forward.h"
 
 // GC3D types match the corresponding GL types as defined in OpenGL ES 2.0
 // header file gl2.h from khronos.org.
diff --git a/Source/core/platform/graphics/Icon.h b/Source/core/platform/graphics/Icon.h
index 9c6fc06..bd4bb98 100644
--- a/Source/core/platform/graphics/Icon.h
+++ b/Source/core/platform/graphics/Icon.h
@@ -21,10 +21,10 @@
 #ifndef Icon_h
 #define Icon_h
 
-#include <wtf/Forward.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.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"
diff --git a/Source/core/platform/graphics/Image.h b/Source/core/platform/graphics/Image.h
index 85c30d2..0db90f3 100644
--- a/Source/core/platform/graphics/Image.h
+++ b/Source/core/platform/graphics/Image.h
@@ -33,11 +33,11 @@
 #include "core/platform/graphics/IntRect.h"
 #include "core/platform/graphics/skia/NativeImageSkia.h"
 #include "third_party/skia/include/core/SkXfermode.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/RetainPtr.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/InbandTextTrackPrivate.h b/Source/core/platform/graphics/InbandTextTrackPrivate.h
index d06f9a5..9492d8a 100644
--- a/Source/core/platform/graphics/InbandTextTrackPrivate.h
+++ b/Source/core/platform/graphics/InbandTextTrackPrivate.h
@@ -26,10 +26,10 @@
 #ifndef InbandTextTrackPrivate_h
 #define InbandTextTrackPrivate_h
 
-#include <wtf/Forward.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/AtomicString.h>
+#include "wtf/Forward.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/RefCounted.h"
+#include "wtf/text/AtomicString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/InbandTextTrackPrivateClient.h b/Source/core/platform/graphics/InbandTextTrackPrivateClient.h
index 27024dc..b9da62e 100644
--- a/Source/core/platform/graphics/InbandTextTrackPrivateClient.h
+++ b/Source/core/platform/graphics/InbandTextTrackPrivateClient.h
@@ -27,8 +27,8 @@
 #define InbandTextTrackPrivateClient_h
 
 #include "core/platform/graphics/Color.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Noncopyable.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/IntSize.h b/Source/core/platform/graphics/IntSize.h
index 4382ca7..ba6e3cf 100644
--- a/Source/core/platform/graphics/IntSize.h
+++ b/Source/core/platform/graphics/IntSize.h
@@ -27,7 +27,7 @@
 #ifndef IntSize_h
 #define IntSize_h
 
-#include <wtf/Platform.h>
+#include "wtf/Platform.h"
 
 #if OS(DARWIN)
 typedef struct CGSize CGSize;
diff --git a/Source/core/platform/graphics/IntSizeHash.h b/Source/core/platform/graphics/IntSizeHash.h
index f882904..71f2640 100644
--- a/Source/core/platform/graphics/IntSizeHash.h
+++ b/Source/core/platform/graphics/IntSizeHash.h
@@ -21,8 +21,8 @@
 #define IntSizeHash_h
 
 #include "core/platform/graphics/IntSize.h"
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
+#include "wtf/HashMap.h"
+#include "wtf/HashSet.h"
 
 namespace WTF {
 
diff --git a/Source/core/platform/graphics/Latin1TextIterator.h b/Source/core/platform/graphics/Latin1TextIterator.h
index c40189b..7b9d6c1 100644
--- a/Source/core/platform/graphics/Latin1TextIterator.h
+++ b/Source/core/platform/graphics/Latin1TextIterator.h
@@ -22,7 +22,7 @@
 #ifndef Latin1TextIterator_h
 #define Latin1TextIterator_h
 
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/LayoutPoint.h b/Source/core/platform/graphics/LayoutPoint.h
index ba14b0d..299a697 100644
--- a/Source/core/platform/graphics/LayoutPoint.h
+++ b/Source/core/platform/graphics/LayoutPoint.h
@@ -33,7 +33,7 @@
 
 #include "core/platform/graphics/FloatPoint.h"
 #include "core/platform/graphics/LayoutSize.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/LayoutRect.h b/Source/core/platform/graphics/LayoutRect.h
index b125d00..a9a5a4d 100644
--- a/Source/core/platform/graphics/LayoutRect.h
+++ b/Source/core/platform/graphics/LayoutRect.h
@@ -34,7 +34,7 @@
 #include "core/platform/graphics/IntRect.h"
 #include "core/platform/graphics/LayoutBoxExtent.h"
 #include "core/platform/graphics/LayoutPoint.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/MediaSourcePrivate.h b/Source/core/platform/graphics/MediaSourcePrivate.h
index 48bf31d..e3f606e 100644
--- a/Source/core/platform/graphics/MediaSourcePrivate.h
+++ b/Source/core/platform/graphics/MediaSourcePrivate.h
@@ -30,7 +30,7 @@
 #ifndef MediaSourcePrivate_h
 #define MediaSourcePrivate_h
 
-#include <wtf/Forward.h>
+#include "wtf/Forward.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/Path.cpp b/Source/core/platform/graphics/Path.cpp
index efe5425..fd913d6 100644
--- a/Source/core/platform/graphics/Path.cpp
+++ b/Source/core/platform/graphics/Path.cpp
@@ -38,7 +38,7 @@
 #include "third_party/skia/include/core/SkPath.h"
 #include "third_party/skia/include/core/SkPathMeasure.h"
 #include "third_party/skia/include/pathops/SkPathOps.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/Path.h b/Source/core/platform/graphics/Path.h
index cf56bb7..a804036 100644
--- a/Source/core/platform/graphics/Path.h
+++ b/Source/core/platform/graphics/Path.h
@@ -32,8 +32,8 @@
 #include "core/platform/graphics/RoundedRect.h"
 #include "core/platform/graphics/WindRule.h"
 #include "third_party/skia/include/core/SkPath.h"
-#include <wtf/FastAllocBase.h>
-#include <wtf/Forward.h>
+#include "wtf/FastAllocBase.h"
+#include "wtf/Forward.h"
 
 class SkPath;
 
diff --git a/Source/core/platform/graphics/PathTraversalState.cpp b/Source/core/platform/graphics/PathTraversalState.cpp
index d689e46..5a56f84 100644
--- a/Source/core/platform/graphics/PathTraversalState.cpp
+++ b/Source/core/platform/graphics/PathTraversalState.cpp
@@ -20,8 +20,8 @@
 #include "config.h"
 #include "core/platform/graphics/PathTraversalState.h"
 
-#include <wtf/MathExtras.h>
-#include <wtf/Vector.h>
+#include "wtf/MathExtras.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/Pattern.h b/Source/core/platform/graphics/Pattern.h
index 12cec68..cbede45 100644
--- a/Source/core/platform/graphics/Pattern.h
+++ b/Source/core/platform/graphics/Pattern.h
@@ -33,9 +33,9 @@
 #include "core/platform/graphics/Image.h"
 #include "core/platform/graphics/transforms/AffineTransform.h"
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/Region.h b/Source/core/platform/graphics/Region.h
index 052d743..8658729 100644
--- a/Source/core/platform/graphics/Region.h
+++ b/Source/core/platform/graphics/Region.h
@@ -27,7 +27,7 @@
 #define Region_h
 
 #include "core/platform/graphics/IntRect.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/SVGGlyph.cpp b/Source/core/platform/graphics/SVGGlyph.cpp
index 1bedff0..9956c21 100644
--- a/Source/core/platform/graphics/SVGGlyph.cpp
+++ b/Source/core/platform/graphics/SVGGlyph.cpp
@@ -23,7 +23,7 @@
 #if ENABLE(SVG_FONTS)
 #include "core/platform/graphics/SVGGlyph.h"
 
-#include <wtf/unicode/Unicode.h>
+#include "wtf/unicode/Unicode.h"
 
 using namespace WTF::Unicode;
 
diff --git a/Source/core/platform/graphics/SVGGlyph.h b/Source/core/platform/graphics/SVGGlyph.h
index c68fe31..740faae 100644
--- a/Source/core/platform/graphics/SVGGlyph.h
+++ b/Source/core/platform/graphics/SVGGlyph.h
@@ -28,8 +28,8 @@
 #include "core/platform/graphics/Path.h"
 
 #include <limits>
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "wtf/text/WTFString.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/SegmentedFontData.cpp b/Source/core/platform/graphics/SegmentedFontData.cpp
index e914367..d1815c1 100644
--- a/Source/core/platform/graphics/SegmentedFontData.cpp
+++ b/Source/core/platform/graphics/SegmentedFontData.cpp
@@ -27,8 +27,8 @@
 #include "core/platform/graphics/SegmentedFontData.h"
 
 #include "core/platform/graphics/SimpleFontData.h"
-#include <wtf/Assertions.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Assertions.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/SegmentedFontData.h b/Source/core/platform/graphics/SegmentedFontData.h
index fa2c422..2df1256 100644
--- a/Source/core/platform/graphics/SegmentedFontData.h
+++ b/Source/core/platform/graphics/SegmentedFontData.h
@@ -27,7 +27,7 @@
 #define SegmentedFontData_h
 
 #include "core/platform/graphics/FontData.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/ShadowBlur.cpp b/Source/core/platform/graphics/ShadowBlur.cpp
index 31ebbe2..652d13a 100644
--- a/Source/core/platform/graphics/ShadowBlur.cpp
+++ b/Source/core/platform/graphics/ShadowBlur.cpp
@@ -29,7 +29,7 @@
 #include "config.h"
 #include "core/platform/graphics/ShadowBlur.h"
 
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/graphics/ShadowBlur.h b/Source/core/platform/graphics/ShadowBlur.h
index bee32bc..2dada77 100644
--- a/Source/core/platform/graphics/ShadowBlur.h
+++ b/Source/core/platform/graphics/ShadowBlur.h
@@ -32,7 +32,7 @@
 #include "core/platform/graphics/Color.h"
 #include "core/platform/graphics/FloatSize.h"
 
-#include <wtf/Noncopyable.h>
+#include "wtf/Noncopyable.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/SimpleFontData.cpp b/Source/core/platform/graphics/SimpleFontData.cpp
index 5a80236..8c6bc00 100644
--- a/Source/core/platform/graphics/SimpleFontData.cpp
+++ b/Source/core/platform/graphics/SimpleFontData.cpp
@@ -32,8 +32,8 @@
 
 #include "core/platform/graphics/opentype/OpenTypeVerticalData.h"
 
-#include <wtf/MathExtras.h>
-#include <wtf/UnusedParam.h>
+#include "wtf/MathExtras.h"
+#include "wtf/UnusedParam.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/graphics/SimpleFontData.h b/Source/core/platform/graphics/SimpleFontData.h
index df24e07..a1fd20b 100644
--- a/Source/core/platform/graphics/SimpleFontData.h
+++ b/Source/core/platform/graphics/SimpleFontData.h
@@ -36,13 +36,13 @@
 #include "core/platform/graphics/opentype/OpenTypeVerticalData.h"
 #endif
 #include "core/platform/graphics/TypesettingFeatures.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/UnusedParam.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/StringHash.h"
+#include "wtf/UnusedParam.h"
 
 #if OS(DARWIN)
-#include <wtf/RetainPtr.h>
+#include "wtf/RetainPtr.h"
 #endif
 
 namespace WebCore {
diff --git a/Source/core/platform/graphics/StringTruncator.cpp b/Source/core/platform/graphics/StringTruncator.cpp
index e34bcab..4bc39ef 100644
--- a/Source/core/platform/graphics/StringTruncator.cpp
+++ b/Source/core/platform/graphics/StringTruncator.cpp
@@ -32,9 +32,9 @@
 #include "core/platform/graphics/Font.h"
 #include "core/platform/graphics/TextRun.h"
 #include "core/platform/text/TextBreakIterator.h"
-#include <wtf/Assertions.h>
-#include <wtf/unicode/CharacterNames.h>
-#include <wtf/Vector.h>
+#include "wtf/Assertions.h"
+#include "wtf/unicode/CharacterNames.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/StringTruncator.h b/Source/core/platform/graphics/StringTruncator.h
index 0c9e429..8e81a54 100644
--- a/Source/core/platform/graphics/StringTruncator.h
+++ b/Source/core/platform/graphics/StringTruncator.h
@@ -29,7 +29,7 @@
 #ifndef StringTruncator_h
 #define StringTruncator_h
 
-#include <wtf/Forward.h>
+#include "wtf/Forward.h"
 
 namespace WebCore {
     
diff --git a/Source/core/platform/graphics/StrokeData.cpp b/Source/core/platform/graphics/StrokeData.cpp
index 23e4424..039df5e 100644
--- a/Source/core/platform/graphics/StrokeData.cpp
+++ b/Source/core/platform/graphics/StrokeData.cpp
@@ -28,6 +28,8 @@
 
 #include "config.h"
 #include "core/platform/graphics/StrokeData.h"
+#include "wtf/OwnArrayPtr.h"
+#include "wtf/PassOwnArrayPtr.h"
 
 namespace WebCore {
 
@@ -42,21 +44,17 @@
         // If no dash is set, revert to solid stroke
         // FIXME: do we need to set NoStroke in some cases?
         m_style = SolidStroke;
-        SkSafeUnref(m_dash);
-        m_dash = 0;
+        m_dash.clear();
         return;
     }
 
     size_t count = !(dashLength % 2) ? dashLength : dashLength * 2;
-    SkScalar* intervals = new SkScalar[count];
+    OwnArrayPtr<SkScalar> intervals = adoptArrayPtr(new SkScalar[count]);
 
     for (unsigned i = 0; i < count; i++)
         intervals[i] = dashes[i % dashLength];
 
-    SkSafeUnref(m_dash);
-    m_dash = new SkDashPathEffect(intervals, count, dashOffset);
-
-    delete[] intervals;
+    m_dash = adoptRef(new SkDashPathEffect(intervals.get(), count, dashOffset));
 }
 
 float StrokeData::setupPaint(SkPaint* paint, int length) const
@@ -70,7 +68,7 @@
     paint->setStrokeMiter(SkFloatToScalar(m_miterLimit));
 
     if (m_dash) {
-        paint->setPathEffect(m_dash);
+        paint->setPathEffect(m_dash.get());
     } else {
         switch (m_style) {
         case NoStroke:
@@ -102,7 +100,8 @@
             }
             SkScalar dashLengthSk = SkIntToScalar(dashLength);
             SkScalar intervals[2] = { dashLengthSk, dashLengthSk };
-            paint->setPathEffect(new SkDashPathEffect(intervals, 2, SkIntToScalar(phase)))->unref();
+            RefPtr<SkDashPathEffect> pathEffect = adoptRef(new SkDashPathEffect(intervals, 2, SkIntToScalar(phase)));
+            paint->setPathEffect(pathEffect.get());
         }
     }
 
diff --git a/Source/core/platform/graphics/StrokeData.h b/Source/core/platform/graphics/StrokeData.h
index 1cdb4bd..e5904e0 100644
--- a/Source/core/platform/graphics/StrokeData.h
+++ b/Source/core/platform/graphics/StrokeData.h
@@ -37,7 +37,8 @@
 #include "third_party/skia/include/core/SkColorPriv.h"
 #include "third_party/skia/include/effects/SkDashPathEffect.h"
 
-#include "wtf/PassOwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
@@ -52,29 +53,9 @@
         , m_lineCap(SkPaint::kDefault_Cap)
         , m_lineJoin(SkPaint::kDefault_Join)
         , m_miterLimit(4)
-        , m_dash(0)
     {
     }
 
-    StrokeData(const StrokeData& other)
-        : m_style(other.m_style)
-        , m_thickness(other.m_thickness)
-        , m_color(other.m_color)
-        , m_gradient(other.m_gradient)
-        , m_pattern(other.m_pattern)
-        , m_lineCap(other.m_lineCap)
-        , m_lineJoin(other.m_lineJoin)
-        , m_miterLimit(other.m_miterLimit)
-        , m_dash(other.m_dash)
-    {
-        SkSafeRef(m_dash);
-    }
-
-    ~StrokeData()
-    {
-        SkSafeUnref(m_dash);
-    }
-
     StrokeStyle style() const { return m_style; }
     void setStyle(const StrokeStyle style) { m_style = style; }
 
@@ -119,7 +100,7 @@
     SkPaint::Cap m_lineCap;
     SkPaint::Join m_lineJoin;
     float m_miterLimit;
-    SkDashPathEffect* m_dash;
+    RefPtr<SkDashPathEffect> m_dash;
 };
 
 } // namespace WebCore
diff --git a/Source/core/platform/graphics/SurrogatePairAwareTextIterator.h b/Source/core/platform/graphics/SurrogatePairAwareTextIterator.h
index 85c9694..7cf7340 100644
--- a/Source/core/platform/graphics/SurrogatePairAwareTextIterator.h
+++ b/Source/core/platform/graphics/SurrogatePairAwareTextIterator.h
@@ -21,8 +21,8 @@
 #ifndef SurrogatePairAwareTextIterator_h
 #define SurrogatePairAwareTextIterator_h
 
-#include <wtf/unicode/CharacterNames.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/unicode/CharacterNames.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/TextRun.h b/Source/core/platform/graphics/TextRun.h
index 7205423..f2e8482 100644
--- a/Source/core/platform/graphics/TextRun.h
+++ b/Source/core/platform/graphics/TextRun.h
@@ -26,8 +26,8 @@
 
 #include "core/platform/graphics/FloatRect.h"
 #include "core/platform/text/TextDirection.h"
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
@@ -98,7 +98,7 @@
     {
         m_data.characters16 = c;
     }
-    
+
     TextRun(const String& string, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true, RoundingHacks roundingHacks = RunRounding | WordRounding)
         : m_charactersLength(string.length())
         , m_len(string.length())
@@ -127,6 +127,34 @@
         }
     }
 
+    TextRun(const StringView& string, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true, RoundingHacks roundingHacks = RunRounding | WordRounding)
+        : m_charactersLength(string.length())
+        , m_len(string.length())
+        , m_xpos(xpos)
+        , m_horizontalGlyphStretch(1)
+        , m_expansion(expansion)
+        , m_expansionBehavior(expansionBehavior)
+        , m_allowTabs(false)
+        , m_direction(direction)
+        , m_directionalOverride(directionalOverride)
+        , m_characterScanForCodePath(characterScanForCodePath)
+        , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHacks)
+        , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRoundingHacks)
+        , m_disableSpacing(false)
+        , m_tabSize(0)
+    {
+        if (!m_charactersLength) {
+            m_is8Bit = true;
+            m_data.characters8 = 0;
+        } else if (string.is8Bit()) {
+            m_data.characters8 = string.characters8();
+            m_is8Bit = true;
+        } else {
+            m_data.characters16 = string.characters16();
+            m_is8Bit = false;
+        }
+    }
+
     TextRun subRun(unsigned startOffset, unsigned length) const
     {
         ASSERT(startOffset < m_len);
diff --git a/Source/core/platform/graphics/WidthIterator.cpp b/Source/core/platform/graphics/WidthIterator.cpp
index b73c478..4e41ebf 100644
--- a/Source/core/platform/graphics/WidthIterator.cpp
+++ b/Source/core/platform/graphics/WidthIterator.cpp
@@ -27,7 +27,7 @@
 #include "core/platform/graphics/Latin1TextIterator.h"
 #include "core/platform/graphics/SimpleFontData.h"
 #include "core/platform/graphics/SurrogatePairAwareTextIterator.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 using namespace WTF;
 using namespace Unicode;
diff --git a/Source/core/platform/graphics/WidthIterator.h b/Source/core/platform/graphics/WidthIterator.h
index 2e8aadd..929fc11 100644
--- a/Source/core/platform/graphics/WidthIterator.h
+++ b/Source/core/platform/graphics/WidthIterator.h
@@ -25,9 +25,9 @@
 #include "core/platform/graphics/Font.h"
 #include "core/platform/graphics/SVGGlyph.h"
 #include "core/platform/graphics/TextRun.h"
-#include <wtf/HashSet.h>
-#include <wtf/unicode/Unicode.h>
-#include <wtf/Vector.h>
+#include "wtf/HashSet.h"
+#include "wtf/unicode/Unicode.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/chromium/AnimationTranslationUtil.cpp b/Source/core/platform/graphics/chromium/AnimationTranslationUtil.cpp
index 78d7dc5..bd8043d 100644
--- a/Source/core/platform/graphics/chromium/AnimationTranslationUtil.cpp
+++ b/Source/core/platform/graphics/chromium/AnimationTranslationUtil.cpp
@@ -47,8 +47,8 @@
 #include "public/platform/WebTransformAnimationCurve.h"
 #include "public/platform/WebTransformOperations.h"
 
-#include <wtf/OwnPtr.h>
-#include <wtf/text/CString.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/text/CString.h"
 
 using namespace std;
 using namespace WebKit;
diff --git a/Source/core/platform/graphics/chromium/AnimationTranslationUtil.h b/Source/core/platform/graphics/chromium/AnimationTranslationUtil.h
index abfabbf..95af52a 100644
--- a/Source/core/platform/graphics/chromium/AnimationTranslationUtil.h
+++ b/Source/core/platform/graphics/chromium/AnimationTranslationUtil.h
@@ -31,7 +31,7 @@
 #ifndef AnimationTranslationUtil_h
 #define AnimationTranslationUtil_h
 
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 namespace WebKit {
 class WebAnimation;
diff --git a/Source/core/platform/graphics/chromium/Canvas2DLayerBridge.h b/Source/core/platform/graphics/chromium/Canvas2DLayerBridge.h
index 9b12a14..e77fc69 100644
--- a/Source/core/platform/graphics/chromium/Canvas2DLayerBridge.h
+++ b/Source/core/platform/graphics/chromium/Canvas2DLayerBridge.h
@@ -33,9 +33,9 @@
 #include "public/platform/WebExternalTextureLayer.h"
 #include "public/platform/WebExternalTextureLayerClient.h"
 #include "public/platform/WebExternalTextureMailbox.h"
-#include <wtf/DoublyLinkedList.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefPtr.h>
+#include "wtf/DoublyLinkedList.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/RefPtr.h"
 
 namespace WebKit {
 class WebGraphicsContext3D;
diff --git a/Source/core/platform/graphics/chromium/Canvas2DLayerManager.cpp b/Source/core/platform/graphics/chromium/Canvas2DLayerManager.cpp
index 75a5e19..6b1f7ce 100644
--- a/Source/core/platform/graphics/chromium/Canvas2DLayerManager.cpp
+++ b/Source/core/platform/graphics/chromium/Canvas2DLayerManager.cpp
@@ -26,7 +26,7 @@
 #include "core/platform/graphics/chromium/Canvas2DLayerManager.h"
 
 #include "public/platform/Platform.h"
-#include <wtf/StdLibExtras.h>
+#include "wtf/StdLibExtras.h"
 
 using WebKit::WebThread;
 
diff --git a/Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp b/Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp
index 774640f..eb3c197 100644
--- a/Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp
+++ b/Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp
@@ -28,8 +28,8 @@
 
 #include "core/platform/graphics/chromium/ImageFrameGenerator.h"
 #include "core/platform/graphics/chromium/LazyDecodingPixelRef.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
 
@@ -46,6 +46,7 @@
     : m_allDataReceived(false)
     , m_actualDecoder(actualDecoder)
     , m_orientation(DefaultImageOrientation)
+    , m_repetitionCount(cAnimationNone)
 {
 }
 
@@ -84,7 +85,7 @@
     // FIXME: This code has the potential problem that multiple
     // LazyDecodingPixelRefs are created even though they share the same
     // scaled size and ImageFrameGenerator.
-    resizedBitmap.setPixelRef(new LazyDecodingPixelRef(pixelRef->frameGenerator(), scaledSize, scaledSubset))->unref();
+    resizedBitmap.setPixelRef(new LazyDecodingPixelRef(pixelRef->frameGenerator(), scaledSize, pixelRef->frameIndex(), scaledSubset))->unref();
 
     // See comments in createLazyDecodingBitmap().
     resizedBitmap.setImmutable();
@@ -103,45 +104,29 @@
 
 ImageFrame* DeferredImageDecoder::frameBufferAtIndex(size_t index)
 {
-    // Only defer image decoding if this is a single frame image. The reason is
-    // because a multiframe is usually animated GIF. Animation is handled by
-    // BitmapImage which uses some metadata functions that do synchronous image
-    // decoding.
-    if (s_enabled
-        && m_actualDecoder
-        && m_actualDecoder->repetitionCount() == cAnimationNone
-        && m_actualDecoder->isSizeAvailable()
-        && m_actualDecoder->frameCount() == 1) {
-
-        m_size = m_actualDecoder->size();
-        m_filenameExtension = m_actualDecoder->filenameExtension();
-        m_orientation = m_actualDecoder->orientation();
-
-        SkBitmap lazyDecodedSkBitmap = createLazyDecodingBitmap();
-        m_lazyDecodedFrame.setSkBitmap(lazyDecodedSkBitmap);
-
-        // Don't mark the frame as completely decoded until the underlying
-        // decoder has really decoded it. Until then, our data and metadata may
-        // be incorrect, so callers can't rely on them.
-        m_lazyDecodedFrame.setStatus(ImageFrame::FramePartial);
+    prepareLazyDecodedFrames();
+    if (index < m_lazyDecodedFrames.size()) {
+        // ImageFrameGenerator has the latest known alpha state. There will
+        // be a performance boost if this frame is opaque.
+        m_lazyDecodedFrames[index]->setHasAlpha(m_frameGenerator->hasAlpha(index));
+        return m_lazyDecodedFrames[index].get();
     }
-
-    return m_actualDecoder ? m_actualDecoder->frameBufferAtIndex(index) : &m_lazyDecodedFrame;
+    if (m_actualDecoder)
+        return m_actualDecoder->frameBufferAtIndex(index);
+    return 0;
 }
 
 void DeferredImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
 {
     if (m_actualDecoder) {
-        // Keep a reference to data until image decoding is deferred.
-        // When image decoding is deferred then ownership of m_data is
-        // transferred to ImageDecodingStore.
         m_data = data;
         m_allDataReceived = allDataReceived;
         m_actualDecoder->setData(data, allDataReceived);
-    } else {
-        ASSERT(!m_data);
-        m_frameGenerator->setData(data, allDataReceived);
+        prepareLazyDecodedFrames();
     }
+
+    if (m_frameGenerator)
+        m_frameGenerator->setData(data, allDataReceived);
 }
 
 bool DeferredImageDecoder::isSizeAvailable()
@@ -158,17 +143,19 @@
 
 IntSize DeferredImageDecoder::frameSizeAtIndex(size_t index) const
 {
+    // FIXME: Frame size is assumed to be uniform. This might not be true for
+    // future supported codecs.
     return m_actualDecoder ? m_actualDecoder->frameSizeAtIndex(index) : m_size;
 }
 
 size_t DeferredImageDecoder::frameCount()
 {
-    return m_actualDecoder ? m_actualDecoder->frameCount() : 1;
+    return m_actualDecoder ? m_actualDecoder->frameCount() : m_lazyDecodedFrames.size();
 }
 
 int DeferredImageDecoder::repetitionCount() const
 {
-    return m_actualDecoder ? m_actualDecoder->repetitionCount() : cAnimationNone;
+    return m_actualDecoder ? m_actualDecoder->repetitionCount() : m_repetitionCount;
 }
 
 size_t DeferredImageDecoder::clearCacheExceptFrame(size_t clearExceptFrame)
@@ -180,26 +167,36 @@
 
 bool DeferredImageDecoder::frameHasAlphaAtIndex(size_t index) const
 {
-    return m_actualDecoder ? m_actualDecoder->frameHasAlphaAtIndex(index) : m_frameGenerator->hasAlpha();
+    if (m_actualDecoder)
+        return m_actualDecoder->frameHasAlphaAtIndex(index);
+    if (!m_frameGenerator->isMultiFrame())
+        return m_frameGenerator->hasAlpha(index);
+    return true;
 }
 
 bool DeferredImageDecoder::frameIsCompleteAtIndex(size_t index) const
 {
-    // TODO: Implement this for deferred decoding.
-    return m_actualDecoder && m_actualDecoder->frameIsCompleteAtIndex(index);
+    if (m_actualDecoder)
+        return m_actualDecoder->frameIsCompleteAtIndex(index);
+    if (index < m_lazyDecodedFrames.size())
+        return m_lazyDecodedFrames[index]->status() == ImageFrame::FrameComplete;
+    return false;
 }
 
 float DeferredImageDecoder::frameDurationAtIndex(size_t index) const
 {
-    // TODO: Implement this for deferred decoding.
-    return m_actualDecoder ? m_actualDecoder->frameDurationAtIndex(index) : 0;
+    if (m_actualDecoder)
+        return m_actualDecoder->frameDurationAtIndex(index);
+    if (index < m_lazyDecodedFrames.size())
+        return m_lazyDecodedFrames[index]->duration();
+    return 0;
 }
 
 unsigned DeferredImageDecoder::frameBytesAtIndex(size_t index) const
 {
     // If frame decoding is deferred then it is not managed by MemoryCache
     // so return 0 here.
-    return m_actualDecoder ? m_actualDecoder->frameBytesAtIndex(index) : 0;
+    return m_frameGenerator ? 0 : m_actualDecoder->frameBytesAtIndex(index);
 }
 
 ImageOrientation DeferredImageDecoder::orientation() const
@@ -207,7 +204,50 @@
     return m_actualDecoder ? m_actualDecoder->orientation() : m_orientation;
 }
 
-SkBitmap DeferredImageDecoder::createLazyDecodingBitmap()
+void DeferredImageDecoder::activateLazyDecoding()
+{
+    if (m_frameGenerator)
+        return;
+    m_size = m_actualDecoder->size();
+    m_orientation = m_actualDecoder->orientation();
+    m_filenameExtension = m_actualDecoder->filenameExtension();
+    const bool isSingleFrame = m_actualDecoder->repetitionCount() == cAnimationNone || (m_allDataReceived && m_actualDecoder->frameCount() == 1u);
+    m_frameGenerator = ImageFrameGenerator::create(SkISize::Make(m_size.width(), m_size.height()), m_data, m_allDataReceived, !isSingleFrame);
+}
+
+void DeferredImageDecoder::prepareLazyDecodedFrames()
+{
+    if (!s_enabled
+        || !m_actualDecoder
+        || !m_actualDecoder->isSizeAvailable()
+        || m_actualDecoder->filenameExtension() == "ico")
+        return;
+
+    activateLazyDecoding();
+
+    const size_t previousSize = m_lazyDecodedFrames.size();
+    m_lazyDecodedFrames.resize(m_actualDecoder->frameCount());
+    for (size_t i = previousSize; i < m_lazyDecodedFrames.size(); ++i) {
+        OwnPtr<ImageFrame> frame(adoptPtr(new ImageFrame()));
+        frame->setSkBitmap(createLazyDecodingBitmap(i));
+        frame->setDuration(m_actualDecoder->frameDurationAtIndex(i));
+        frame->setStatus(m_actualDecoder->frameIsCompleteAtIndex(i) ? ImageFrame::FrameComplete : ImageFrame::FramePartial);
+        m_lazyDecodedFrames[i] = frame.release();
+    }
+
+    // The last lazy decoded frame created from previous call might be
+    // incomplete so update its state.
+    if (previousSize)
+        m_lazyDecodedFrames[previousSize - 1]->setStatus(m_actualDecoder->frameIsCompleteAtIndex(previousSize - 1) ? ImageFrame::FrameComplete : ImageFrame::FramePartial);
+
+    if (m_allDataReceived) {
+        m_repetitionCount = m_actualDecoder->repetitionCount();
+        m_actualDecoder.clear();
+        m_data = nullptr;
+    }
+}
+
+SkBitmap DeferredImageDecoder::createLazyDecodingBitmap(size_t index)
 {
     SkISize fullSize = SkISize::Make(m_actualDecoder->size().width(), m_actualDecoder->size().height());
     ASSERT(!fullSize.isEmpty());
@@ -217,11 +257,7 @@
     // Creates a lazily decoded SkPixelRef that references the entire image without scaling.
     SkBitmap bitmap;
     bitmap.setConfig(SkBitmap::kARGB_8888_Config, fullSize.width(), fullSize.height());
-
-    m_frameGenerator = ImageFrameGenerator::create(fullSize, m_data.release(), m_allDataReceived);
-    m_actualDecoder.clear();
-
-    bitmap.setPixelRef(new LazyDecodingPixelRef(m_frameGenerator, fullSize, fullRect))->unref();
+    bitmap.setPixelRef(new LazyDecodingPixelRef(m_frameGenerator, fullSize, index, fullRect))->unref();
 
     // Use the URI to identify this as a lazily decoded SkPixelRef of type LazyDecodingPixelRef.
     // FIXME: It would be more useful to give the actual image URI.
@@ -231,15 +267,12 @@
     // subsystems that may try to cache this bitmap (e.g. pictures, pipes, gpu, pdf, etc.)
     bitmap.setImmutable();
 
-    // FIXME: Setting bitmap.setIsOpaque() is big performance gain if possible. We can
-    // do so safely if the image is fully loaded and it is a JPEG image, or if the image was
-    // decoded before.
-
     return bitmap;
 }
 
 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const
 {
+    // TODO: Implement.
     return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false;
 }
 
diff --git a/Source/core/platform/graphics/chromium/DeferredImageDecoder.h b/Source/core/platform/graphics/chromium/DeferredImageDecoder.h
index 4183ee3..390a364 100644
--- a/Source/core/platform/graphics/chromium/DeferredImageDecoder.h
+++ b/Source/core/platform/graphics/chromium/DeferredImageDecoder.h
@@ -30,7 +30,9 @@
 #include "core/platform/graphics/ImageSource.h"
 #include "core/platform/graphics/IntSize.h"
 #include "core/platform/image-decoders/ImageDecoder.h"
-#include <wtf/Forward.h>
+#include "wtf/Forward.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
@@ -71,7 +73,9 @@
 
 private:
     explicit DeferredImageDecoder(PassOwnPtr<ImageDecoder> actualDecoder);
-    SkBitmap createLazyDecodingBitmap();
+    void prepareLazyDecodedFrames();
+    SkBitmap createLazyDecodingBitmap(size_t index);
+    void activateLazyDecoding();
     void setData(PassRefPtr<SharedBuffer>, bool allDataReceived);
 
     RefPtr<SharedBuffer> m_data;
@@ -81,8 +85,9 @@
     String m_filenameExtension;
     IntSize m_size;
     ImageOrientation m_orientation;
+    int m_repetitionCount;
 
-    ImageFrame m_lazyDecodedFrame;
+    Vector<OwnPtr<ImageFrame> > m_lazyDecodedFrames;
     RefPtr<ImageFrameGenerator> m_frameGenerator;
 
     static bool s_enabled;
diff --git a/Source/core/platform/graphics/chromium/DeferredImageDecoderTest.cpp b/Source/core/platform/graphics/chromium/DeferredImageDecoderTest.cpp
index 6a4edad..78857c8 100644
--- a/Source/core/platform/graphics/chromium/DeferredImageDecoderTest.cpp
+++ b/Source/core/platform/graphics/chromium/DeferredImageDecoderTest.cpp
@@ -79,9 +79,12 @@
         m_actualDecoder = decoder.get();
         m_actualDecoder->setSize(1, 1);
         m_lazyDecoder = DeferredImageDecoder::createForTesting(decoder.release());
-        m_lazyDecoder->setData(m_data.get(), true);
         m_canvas.reset(createRasterCanvas(100, 100));
         m_frameBufferRequestCount = 0;
+        m_frameCount = 1;
+        m_repetitionCount = cAnimationNone;
+        m_frameStatus = ImageFrame::FrameComplete;
+        m_frameDuration = 0;
     }
 
     virtual void TearDown()
@@ -99,9 +102,24 @@
         ++m_frameBufferRequestCount;
     }
 
+    virtual size_t frameCount()
+    {
+        return m_frameCount;
+    }
+
+    virtual int repetitionCount() const
+    {
+        return m_repetitionCount;
+    }
+
     virtual ImageFrame::FrameStatus frameStatus()
     {
-        return ImageFrame::FrameComplete;
+        return m_frameStatus;
+    }
+
+    virtual float frameDuration() const
+    {
+        return m_frameDuration;
     }
 
 protected:
@@ -112,10 +130,15 @@
     SkAutoTUnref<SkCanvas> m_canvas;
     int m_frameBufferRequestCount;
     RefPtr<SharedBuffer> m_data;
+    size_t m_frameCount;
+    int m_repetitionCount;
+    ImageFrame::FrameStatus m_frameStatus;
+    float m_frameDuration;
 };
 
 TEST_F(DeferredImageDecoderTest, drawIntoSkPicture)
 {
+    m_lazyDecoder->setData(m_data.get(), true);
     RefPtr<NativeImageSkia> image = m_lazyDecoder->frameBufferAtIndex(0)->asNewNativeImage();
     EXPECT_EQ(1, image->bitmap().width());
     EXPECT_EQ(1, image->bitmap().height());
@@ -139,6 +162,7 @@
 
 TEST_F(DeferredImageDecoderTest, DISABLED_drawScaledIntoSkPicture)
 {
+    m_lazyDecoder->setData(m_data.get(), true);
     RefPtr<NativeImageSkia> image = m_lazyDecoder->frameBufferAtIndex(0)->asNewNativeImage();
     SkBitmap scaledBitmap = image->resizedBitmap(SkISize::Make(50, 51), SkIRect::MakeWH(50, 51));
     EXPECT_FALSE(scaledBitmap.isNull());
@@ -171,6 +195,7 @@
 
 TEST_F(DeferredImageDecoderTest, decodeOnOtherThread)
 {
+    m_lazyDecoder->setData(m_data.get(), true);
     RefPtr<NativeImageSkia> image = m_lazyDecoder->frameBufferAtIndex(0)->asNewNativeImage();
     EXPECT_EQ(1, image->bitmap().width());
     EXPECT_EQ(1, image->bitmap().height());
@@ -197,4 +222,67 @@
     EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0));
 }
 
+TEST_F(DeferredImageDecoderTest, singleFrameImageLoading)
+{
+    m_frameStatus = ImageFrame::FramePartial;
+    m_lazyDecoder->setData(m_data.get(), false);
+    EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0));
+    ImageFrame* frame = m_lazyDecoder->frameBufferAtIndex(0);
+    EXPECT_EQ(ImageFrame::FramePartial, frame->status());
+    EXPECT_TRUE(m_actualDecoder);
+
+    m_frameStatus = ImageFrame::FrameComplete;
+    m_lazyDecoder->setData(m_data.get(), true);
+    EXPECT_FALSE(m_actualDecoder);
+    EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0));
+    frame = m_lazyDecoder->frameBufferAtIndex(0);
+    EXPECT_EQ(ImageFrame::FrameComplete, frame->status());
+    EXPECT_FALSE(m_frameBufferRequestCount);
+}
+
+TEST_F(DeferredImageDecoderTest, multiFrameImageLoading)
+{
+    m_repetitionCount = 10;
+    m_frameCount = 1;
+    m_frameDuration = 10;
+    m_frameStatus = ImageFrame::FramePartial;
+    m_lazyDecoder->setData(m_data.get(), false);
+    EXPECT_EQ(ImageFrame::FramePartial, m_lazyDecoder->frameBufferAtIndex(0)->status());
+    EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0));
+    EXPECT_EQ(10.0f, m_lazyDecoder->frameBufferAtIndex(0)->duration());
+    EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0));
+
+    m_frameCount = 2;
+    m_frameDuration = 20;
+    m_frameStatus = ImageFrame::FrameComplete;
+    m_lazyDecoder->setData(m_data.get(), false);
+    EXPECT_EQ(ImageFrame::FrameComplete, m_lazyDecoder->frameBufferAtIndex(0)->status());
+    EXPECT_EQ(ImageFrame::FrameComplete, m_lazyDecoder->frameBufferAtIndex(1)->status());
+    EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0));
+    EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(1));
+    EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1));
+    EXPECT_EQ(10.0f, m_lazyDecoder->frameBufferAtIndex(0)->duration());
+    EXPECT_EQ(20.0f, m_lazyDecoder->frameBufferAtIndex(1)->duration());
+    EXPECT_TRUE(m_actualDecoder);
+
+    m_frameCount = 3;
+    m_frameDuration = 30;
+    m_frameStatus = ImageFrame::FrameComplete;
+    m_lazyDecoder->setData(m_data.get(), true);
+    EXPECT_FALSE(m_actualDecoder);
+    EXPECT_EQ(ImageFrame::FrameComplete, m_lazyDecoder->frameBufferAtIndex(0)->status());
+    EXPECT_EQ(ImageFrame::FrameComplete, m_lazyDecoder->frameBufferAtIndex(1)->status());
+    EXPECT_EQ(ImageFrame::FrameComplete, m_lazyDecoder->frameBufferAtIndex(2)->status());
+    EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0));
+    EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(1));
+    EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(2));
+    EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0));
+    EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1));
+    EXPECT_EQ(30.0f, m_lazyDecoder->frameDurationAtIndex(2));
+    EXPECT_EQ(10.0f, m_lazyDecoder->frameBufferAtIndex(0)->duration());
+    EXPECT_EQ(20.0f, m_lazyDecoder->frameBufferAtIndex(1)->duration());
+    EXPECT_EQ(30.0f, m_lazyDecoder->frameBufferAtIndex(2)->duration());
+    EXPECT_EQ(10, m_lazyDecoder->repetitionCount());
+}
+
 } // namespace
diff --git a/Source/core/platform/graphics/chromium/DiscardablePixelRef.cpp b/Source/core/platform/graphics/chromium/DiscardablePixelRef.cpp
index 5ce75ee..ffb6adf 100644
--- a/Source/core/platform/graphics/chromium/DiscardablePixelRef.cpp
+++ b/Source/core/platform/graphics/chromium/DiscardablePixelRef.cpp
@@ -27,7 +27,7 @@
 #include "core/platform/graphics/chromium/DiscardablePixelRef.h"
 
 #include "public/platform/Platform.h"
-#include <wtf/StdLibExtras.h>
+#include "wtf/StdLibExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/chromium/DiscardablePixelRef.h b/Source/core/platform/graphics/chromium/DiscardablePixelRef.h
index fbc7685..552ce51 100644
--- a/Source/core/platform/graphics/chromium/DiscardablePixelRef.h
+++ b/Source/core/platform/graphics/chromium/DiscardablePixelRef.h
@@ -30,8 +30,8 @@
 #include "SkPixelRef.h"
 
 #include "public/platform/WebDiscardableMemory.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/chromium/FontCacheAndroid.cpp b/Source/core/platform/graphics/chromium/FontCacheAndroid.cpp
index b1b659d..0b6605c 100644
--- a/Source/core/platform/graphics/chromium/FontCacheAndroid.cpp
+++ b/Source/core/platform/graphics/chromium/FontCacheAndroid.cpp
@@ -42,9 +42,9 @@
 #include "SkUtils.h"
 
 #include <unicode/locid.h>
-#include <wtf/Assertions.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/CString.h>
+#include "wtf/Assertions.h"
+#include "wtf/text/AtomicString.h"
+#include "wtf/text/CString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/chromium/FontCacheChromiumWin.cpp b/Source/core/platform/graphics/chromium/FontCacheChromiumWin.cpp
index e449c1c..5574b29 100644
--- a/Source/core/platform/graphics/chromium/FontCacheChromiumWin.cpp
+++ b/Source/core/platform/graphics/chromium/FontCacheChromiumWin.cpp
@@ -39,9 +39,9 @@
 #include "core/platform/graphics/chromium/FontPlatformDataChromiumWin.h"
 #include "core/platform/graphics/chromium/FontUtilsChromiumWin.h"
 #include "core/platform/win/HWndDC.h"
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/text/StringHash.h>
+#include "wtf/HashMap.h"
+#include "wtf/HashSet.h"
+#include "wtf/text/StringHash.h"
 
 #include <windows.h>
 #include <mlang.h>
diff --git a/Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp b/Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp
index 3ea7c21..b22bd02 100644
--- a/Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp
+++ b/Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp
@@ -43,7 +43,8 @@
 #include "core/platform/win/HWndDC.h"
 #include "public/platform/Platform.h"
 #include "public/platform/win/WebSandboxSupport.h"
-#include <wtf/StdLibExtras.h>
+#include "wtf/PassOwnPtr.h"
+#include "wtf/StdLibExtras.h"
 
 namespace WebCore {
 
@@ -102,7 +103,7 @@
     return textFlags & getDefaultGDITextFlags();
 }
 
-SkTypeface* CreateTypefaceFromHFont(HFONT hfont, int* size, int* paintTextFlags)
+PassRefPtr<SkTypeface> CreateTypefaceFromHFont(HFONT hfont, int* size, int* paintTextFlags)
 {
     LOGFONT info;
     GetObject(hfont, sizeof(info), &info);
@@ -114,7 +115,7 @@
     }
     if (paintTextFlags)
         *paintTextFlags = computePaintTextFlags(info);
-    return SkCreateTypefaceFromLOGFONT(info);
+    return adoptRef(SkCreateTypefaceFromLOGFONT(info));
 }
 
 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
@@ -122,8 +123,6 @@
     , m_size(-1)
     , m_orientation(Horizontal)
     , m_scriptCache(0)
-    , m_scriptFontProperties(0)
-    , m_typeface(0)
     , m_paintTextFlags(0)
 {
 }
@@ -133,8 +132,6 @@
     , m_size(0)
     , m_orientation(Horizontal)
     , m_scriptCache(0)
-    , m_scriptFontProperties(0)
-    , m_typeface(0)
     , m_paintTextFlags(0)
 {
 }
@@ -144,7 +141,6 @@
     , m_size(size)
     , m_orientation(orientation)
     , m_scriptCache(0)
-    , m_scriptFontProperties(0)
     , m_typeface(CreateTypefaceFromHFont(font, 0, &m_paintTextFlags))
 {
 }
@@ -155,8 +151,6 @@
     , m_size(size)
     , m_orientation(Horizontal)
     , m_scriptCache(0)
-    , m_scriptFontProperties(0)
-    , m_typeface(0)
     , m_paintTextFlags(0)
 {
 }
@@ -166,11 +160,9 @@
     , m_size(data.m_size)
     , m_orientation(data.m_orientation)
     , m_scriptCache(0)
-    , m_scriptFontProperties(0)
     , m_typeface(data.m_typeface)
     , m_paintTextFlags(data.m_paintTextFlags)
 {
-    SkSafeRef(m_typeface);
 }
 
 FontPlatformData::FontPlatformData(const FontPlatformData& data, float textSize)
@@ -178,11 +170,9 @@
     , m_size(textSize)
     , m_orientation(data.m_orientation)
     , m_scriptCache(0)
-    , m_scriptFontProperties(0)
     , m_typeface(data.m_typeface)
     , m_paintTextFlags(data.m_paintTextFlags)
 {
-    SkSafeRef(m_typeface);
 }
 
 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data)
@@ -191,28 +181,21 @@
         m_font = data.m_font;
         m_size = data.m_size;
         m_orientation = data.m_orientation;
-        SkRefCnt_SafeAssign(m_typeface, data.m_typeface);
+        m_typeface = data.m_typeface;
         m_paintTextFlags = data.m_paintTextFlags;
 
         // The following fields will get re-computed if necessary.
         ScriptFreeCache(&m_scriptCache);
         m_scriptCache = 0;
-
-        delete m_scriptFontProperties;
-        m_scriptFontProperties = 0;
+        m_scriptFontProperties.clear();
     } 
     return *this;
 }
 
 FontPlatformData::~FontPlatformData()
 {
-    SkSafeUnref(m_typeface);
-
     ScriptFreeCache(&m_scriptCache);
     m_scriptCache = 0;
-
-    delete m_scriptFontProperties;
-    m_scriptFontProperties = 0;
 }
 
 bool FontPlatformData::isFixedPitch() const
@@ -262,21 +245,18 @@
 SCRIPT_FONTPROPERTIES* FontPlatformData::scriptFontProperties() const
 {
     if (!m_scriptFontProperties) {
-        m_scriptFontProperties = new SCRIPT_FONTPROPERTIES;
-        memset(m_scriptFontProperties, 0, sizeof(SCRIPT_FONTPROPERTIES));
+        m_scriptFontProperties = adoptPtr(new SCRIPT_FONTPROPERTIES);
+        memset(m_scriptFontProperties.get(), 0, sizeof(SCRIPT_FONTPROPERTIES));
         m_scriptFontProperties->cBytes = sizeof(SCRIPT_FONTPROPERTIES);
-        HRESULT result = ScriptGetFontProperties(0, scriptCache(),
-                                                 m_scriptFontProperties);
+        HRESULT result = ScriptGetFontProperties(0, scriptCache(), m_scriptFontProperties.get());
         if (result == E_PENDING) {
             HWndDC dc(0);
             HGDIOBJ oldFont = SelectObject(dc, hfont());
-            HRESULT hr = ScriptGetFontProperties(dc, scriptCache(),
-                                                 m_scriptFontProperties);
+            HRESULT hr = ScriptGetFontProperties(dc, scriptCache(), m_scriptFontProperties.get());
             if (S_OK != hr) {
                 if (FontPlatformData::ensureFontLoaded(hfont())) {
                     // FIXME: Handle gracefully the error if this call also fails.
-                    hr = ScriptGetFontProperties(dc, scriptCache(),
-                                                 m_scriptFontProperties);
+                    hr = ScriptGetFontProperties(dc, scriptCache(), m_scriptFontProperties.get());
                     if (S_OK != hr) {
                         LOG_ERROR("Unable to get the font properties after second attempt");
                     }
@@ -286,7 +266,7 @@
             SelectObject(dc, oldFont);
         }
     }
-    return m_scriptFontProperties;
+    return m_scriptFontProperties.get();
 }
 
 #ifndef NDEBUG
diff --git a/Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.h b/Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.h
index 0caf5bc..bf3fea4 100644
--- a/Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.h
+++ b/Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.h
@@ -41,8 +41,10 @@
 #include "core/platform/graphics/opentype/OpenTypeVerticalData.h"
 #include "wtf/Forward.h"
 #include "wtf/HashTableDeletedValueType.h"
+#include "wtf/OwnPtr.h"
 #include "wtf/PassRefPtr.h"
 #include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
 #include "wtf/text/StringImpl.h"
 
 #include <usp10.h>
@@ -52,9 +54,8 @@
 namespace WebCore {
 
 // Return a typeface associated with the hfont, and return its size and
-// lfQuality from the hfont's LOGFONT. The caller is now an owner of the
-// typeface.
-SkTypeface* CreateTypefaceFromHFont(HFONT, int* size, int* paintTextFlags);
+// lfQuality from the hfont's LOGFONT.
+PassRefPtr<SkTypeface> CreateTypefaceFromHFont(HFONT, int* size, int* paintTextFlags);
 
 class FontDescription;
 
@@ -86,7 +87,7 @@
     bool isFixedPitch() const;
     HFONT hfont() const { return m_font ? m_font->hfont() : 0; }
     float size() const { return m_size; }
-    SkTypeface* typeface() const { return m_typeface; }
+    SkTypeface* typeface() const { return m_typeface.get(); }
     int paintTextFlags() const { return m_paintTextFlags; }
 
     FontOrientation orientation() const { return m_orientation; }
@@ -156,11 +157,11 @@
     float m_size;  // Point size of the font in pixels.
     FontOrientation m_orientation;
 
-    SkTypeface* m_typeface; // cached from m_font
+    RefPtr<SkTypeface> m_typeface; // cached from m_font
     int m_paintTextFlags; // cached from m_font
 
     mutable SCRIPT_CACHE m_scriptCache;
-    mutable SCRIPT_FONTPROPERTIES* m_scriptFontProperties;
+    mutable OwnPtr<SCRIPT_FONTPROPERTIES> m_scriptFontProperties;
 };
 
 } // WebCore
diff --git a/Source/core/platform/graphics/chromium/FontUtilsChromiumWin.cpp b/Source/core/platform/graphics/chromium/FontUtilsChromiumWin.cpp
index c2d7842..5fbebba 100644
--- a/Source/core/platform/graphics/chromium/FontUtilsChromiumWin.cpp
+++ b/Source/core/platform/graphics/chromium/FontUtilsChromiumWin.cpp
@@ -37,9 +37,9 @@
 #include <unicode/uchar.h>
 #include "core/platform/graphics/chromium/UniscribeHelper.h"
 #include "core/platform/win/HWndDC.h"
-#include <wtf/HashMap.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/HashMap.h"
+#include "wtf/text/StringHash.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/chromium/IconChromium.cpp b/Source/core/platform/graphics/chromium/IconChromium.cpp
index cadfd52..ab3f829 100644
--- a/Source/core/platform/graphics/chromium/IconChromium.cpp
+++ b/Source/core/platform/graphics/chromium/IconChromium.cpp
@@ -32,7 +32,7 @@
 #include "core/platform/graphics/Icon.h"
 
 #include "core/platform/graphics/GraphicsContext.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/chromium/IconChromiumAndroid.cpp b/Source/core/platform/graphics/chromium/IconChromiumAndroid.cpp
index 9c1131f..91b7bc6 100644
--- a/Source/core/platform/graphics/chromium/IconChromiumAndroid.cpp
+++ b/Source/core/platform/graphics/chromium/IconChromiumAndroid.cpp
@@ -28,7 +28,7 @@
 
 #include "core/platform/NotImplemented.h"
 #include "core/platform/graphics/GraphicsContext.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/chromium/ImageDecodingStore.h b/Source/core/platform/graphics/chromium/ImageDecodingStore.h
index 28c87c5..45d1fb0 100644
--- a/Source/core/platform/graphics/chromium/ImageDecodingStore.h
+++ b/Source/core/platform/graphics/chromium/ImageDecodingStore.h
@@ -33,12 +33,12 @@
 #include "core/platform/graphics/chromium/SkSizeHash.h"
 #include "core/platform/image-decoders/ImageDecoder.h"
 
-#include <wtf/DoublyLinkedList.h>
-#include <wtf/HashSet.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/ThreadingPrimitives.h>
-#include <wtf/Vector.h>
+#include "wtf/DoublyLinkedList.h"
+#include "wtf/HashSet.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/ThreadingPrimitives.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/chromium/ImageDecodingStoreTest.cpp b/Source/core/platform/graphics/chromium/ImageDecodingStoreTest.cpp
index 997f3fa..47d3e63 100644
--- a/Source/core/platform/graphics/chromium/ImageDecodingStoreTest.cpp
+++ b/Source/core/platform/graphics/chromium/ImageDecodingStoreTest.cpp
@@ -68,6 +68,10 @@
         return ImageFrame::FramePartial;
     }
 
+    virtual size_t frameCount() { return 1; }
+    virtual int repetitionCount() const { return cAnimationNone; }
+    virtual float frameDuration() const { return 0; }
+
 protected:
     PassOwnPtr<ScaledImageFragment> createCompleteImage(const SkISize& size, bool discardable = false, size_t index = 0)
     {
diff --git a/Source/core/platform/graphics/chromium/ImageFrameGenerator.cpp b/Source/core/platform/graphics/chromium/ImageFrameGenerator.cpp
index e5027cb..5c32e12 100644
--- a/Source/core/platform/graphics/chromium/ImageFrameGenerator.cpp
+++ b/Source/core/platform/graphics/chromium/ImageFrameGenerator.cpp
@@ -47,10 +47,10 @@
 
 } // namespace
 
-ImageFrameGenerator::ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer> data, bool allDataReceived)
+ImageFrameGenerator::ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer> data, bool allDataReceived, bool isMultiFrame)
     : m_fullSize(fullSize)
+    , m_isMultiFrame(isMultiFrame)
     , m_decodeFailedAndEmpty(false)
-    , m_hasAlpha(true)
     , m_decodeCount(ScaledImageFragment::FirstPartialImage)
 {
     setData(data.get(), allDataReceived);
@@ -78,7 +78,7 @@
         *data = buffer->copy();
 }
 
-const ScaledImageFragment* ImageFrameGenerator::decodeAndScale(const SkISize& scaledSize)
+const ScaledImageFragment* ImageFrameGenerator::decodeAndScale(const SkISize& scaledSize, size_t index)
 {
     // Prevents concurrent decode or scale operations on the same image data.
     // Multiple LazyDecodingPixelRefs can call this method at the same time.
@@ -88,35 +88,35 @@
 
     const ScaledImageFragment* cachedImage = 0;
 
-    cachedImage = tryToLockCompleteCache(scaledSize);
+    cachedImage = tryToLockCompleteCache(scaledSize, index);
     if (cachedImage)
         return cachedImage;
 
     TRACE_EVENT2("webkit", "ImageFrameGenerator::decodeAndScale", "generator", this, "decodeCount", static_cast<int>(m_decodeCount));
 
-    cachedImage = tryToScale(0, scaledSize);
+    cachedImage = tryToScale(0, scaledSize, index);
     if (cachedImage)
         return cachedImage;
 
-    cachedImage = tryToResumeDecodeAndScale(scaledSize);
+    cachedImage = tryToResumeDecodeAndScale(scaledSize, index);
     if (cachedImage)
         return cachedImage;
 
-    cachedImage = tryToDecodeAndScale(scaledSize);
+    cachedImage = tryToDecodeAndScale(scaledSize, index);
     if (cachedImage)
         return cachedImage;
     return 0;
 }
 
-const ScaledImageFragment* ImageFrameGenerator::tryToLockCompleteCache(const SkISize& scaledSize)
+const ScaledImageFragment* ImageFrameGenerator::tryToLockCompleteCache(const SkISize& scaledSize, size_t index)
 {
     const ScaledImageFragment* cachedImage = 0;
-    if (ImageDecodingStore::instance()->lockCache(this, scaledSize, 0, &cachedImage))
+    if (ImageDecodingStore::instance()->lockCache(this, scaledSize, index, &cachedImage))
         return cachedImage;
     return 0;
 }
 
-const ScaledImageFragment* ImageFrameGenerator::tryToScale(const ScaledImageFragment* fullSizeImage, const SkISize& scaledSize)
+const ScaledImageFragment* ImageFrameGenerator::tryToScale(const ScaledImageFragment* fullSizeImage, const SkISize& scaledSize, size_t index)
 {
     TRACE_EVENT0("webkit", "ImageFrameGenerator::tryToScale");
 
@@ -125,7 +125,7 @@
     if (scaledSize == m_fullSize)
         return 0;
 
-    if (!fullSizeImage && !ImageDecodingStore::instance()->lockCache(this, m_fullSize, 0, &fullSizeImage))
+    if (!fullSizeImage && !ImageDecodingStore::instance()->lockCache(this, m_fullSize, index, &fullSizeImage))
         return 0;
 
     // This call allocates the DiscardablePixelRef and lock/unlocks it
@@ -143,9 +143,9 @@
     return ImageDecodingStore::instance()->insertAndLockCache(this, scaledImage.release());
 }
 
-const ScaledImageFragment* ImageFrameGenerator::tryToResumeDecodeAndScale(const SkISize& scaledSize)
+const ScaledImageFragment* ImageFrameGenerator::tryToResumeDecodeAndScale(const SkISize& scaledSize, size_t index)
 {
-    TRACE_EVENT0("webkit", "ImageFrameGenerator::tryToResumeDecodeAndScale");
+    TRACE_EVENT1("webkit", "ImageFrameGenerator::tryToResumeDecodeAndScale", "index", static_cast<int>(index));
 
     ImageDecoder* cachedDecoder = 0;
 
@@ -154,27 +154,37 @@
     ASSERT(cachedDecoder);
 
     // Always generate a new image and insert it into cache.
-    OwnPtr<ScaledImageFragment> fullSizeImage = decode(&cachedDecoder);
+    OwnPtr<ScaledImageFragment> fullSizeImage = decode(index, &cachedDecoder);
+
+    if (!fullSizeImage) {
+        // If decode has failed and resulted an empty image we can save work
+        // in the future by returning early.
+        m_decodeFailedAndEmpty = !m_isMultiFrame && cachedDecoder->failed();
+        ImageDecodingStore::instance()->unlockDecoder(this, cachedDecoder);
+        return 0;
+    }
+
     const ScaledImageFragment* cachedImage = ImageDecodingStore::instance()->insertAndLockCache(this, fullSizeImage.release());
 
     // If the image generated is complete then there is no need to keep
-    // the decoder.
-    if (cachedImage->isComplete())
+    // the decoder. The exception is multi-frame decoder which can generate
+    // multiple complete frames.
+    if (cachedImage->isComplete() && !m_isMultiFrame)
         ImageDecodingStore::instance()->removeDecoder(this, cachedDecoder);
     else
         ImageDecodingStore::instance()->unlockDecoder(this, cachedDecoder);
 
     if (m_fullSize == scaledSize)
         return cachedImage;
-    return tryToScale(cachedImage, scaledSize);
+    return tryToScale(cachedImage, scaledSize, index);
 }
 
-const ScaledImageFragment* ImageFrameGenerator::tryToDecodeAndScale(const SkISize& scaledSize)
+const ScaledImageFragment* ImageFrameGenerator::tryToDecodeAndScale(const SkISize& scaledSize, size_t index)
 {
-    TRACE_EVENT0("webkit", "ImageFrameGenerator::tryToDecodeAndScale");
+    TRACE_EVENT1("webkit", "ImageFrameGenerator::tryToDecodeAndScale", "index", static_cast<int>(index));
 
     ImageDecoder* decoder = 0;
-    OwnPtr<ScaledImageFragment> fullSizeImage = decode(&decoder);
+    OwnPtr<ScaledImageFragment> fullSizeImage = decode(index, &decoder);
 
     if (!decoder)
         return 0;
@@ -182,25 +192,26 @@
     OwnPtr<ImageDecoder> decoderContainer = adoptPtr(decoder);
 
     if (!fullSizeImage) {
-        // If decode has failed and resulted an empty image we need to make
-        // sure we don't do wasted work in the future.
-        m_decodeFailedAndEmpty = decoderContainer->failed();
+        // If decode has failed and resulted an empty image we can save work
+        // in the future by returning early.
+        m_decodeFailedAndEmpty = !m_isMultiFrame && decoderContainer->failed();
         return 0;
     }
 
     const ScaledImageFragment* cachedImage = ImageDecodingStore::instance()->insertAndLockCache(this, fullSizeImage.release());
 
     // If image is complete then decoder is not needed in the future.
-    // Otherwise save the decoder for later use.
-    if (!cachedImage->isComplete())
+    // Otherwise save the decoder for later use. The exception is
+    // multi-frame decoder which can generate multiple complete frames.
+    if (!cachedImage->isComplete() || m_isMultiFrame)
         ImageDecodingStore::instance()->insertDecoder(this, decoderContainer.release(), DiscardablePixelRef::isDiscardable(cachedImage->bitmap().pixelRef()));
 
     if (m_fullSize == scaledSize)
         return cachedImage;
-    return tryToScale(cachedImage, scaledSize);
+    return tryToScale(cachedImage, scaledSize, index);
 }
 
-PassOwnPtr<ScaledImageFragment> ImageFrameGenerator::decode(ImageDecoder** decoder)
+PassOwnPtr<ScaledImageFragment> ImageFrameGenerator::decode(size_t index, ImageDecoder** decoder)
 {
     TRACE_EVENT2("webkit", "ImageFrameGenerator::decode", "width", m_fullSize.width(), "height", m_fullSize.height());
 
@@ -222,15 +233,17 @@
 
     // TODO: this is very ugly. We need to refactor the way how we can pass a
     // memory allocator to image decoders.
-    (*decoder)->setMemoryAllocator(&m_allocator);
+    if (!m_isMultiFrame)
+        (*decoder)->setMemoryAllocator(&m_allocator);
     (*decoder)->setData(data, allDataReceived);
     // If this call returns a newly allocated DiscardablePixelRef, then
     // ImageFrame::m_bitmap and the contained DiscardablePixelRef are locked.
     // They will be unlocked when ImageDecoder is destroyed since ImageDecoder
     // owns the ImageFrame. Partially decoded SkBitmap is thus inserted into the
     // ImageDecodingStore while locked.
-    ImageFrame* frame = (*decoder)->frameBufferAtIndex(0);
+    ImageFrame* frame = (*decoder)->frameBufferAtIndex(index);
     (*decoder)->setData(0, false); // Unref SharedBuffer from ImageDecoder.
+    (*decoder)->clearCacheExceptFrame(index);
 
     if (!frame || frame->status() == ImageFrame::FrameEmpty)
         return nullptr;
@@ -239,24 +252,32 @@
     SkBitmap fullSizeBitmap = frame->getSkBitmap();
     {
         MutexLocker lock(m_alphaMutex);
-        m_hasAlpha = !fullSizeBitmap.isOpaque();
+        if (index >= m_hasAlpha.size()) {
+            const size_t oldSize = m_hasAlpha.size();
+            m_hasAlpha.resize(index + 1);
+            for (size_t i = oldSize; i < m_hasAlpha.size(); ++i)
+                m_hasAlpha[i] = true;
+        }
+        m_hasAlpha[index] = !fullSizeBitmap.isOpaque();
     }
     ASSERT(fullSizeBitmap.width() == m_fullSize.width() && fullSizeBitmap.height() == m_fullSize.height());
 
     if (isComplete)
-        return ScaledImageFragment::createComplete(m_fullSize, 0, fullSizeBitmap);
+        return ScaledImageFragment::createComplete(m_fullSize, index, fullSizeBitmap);
 
     // If the image is partial we need to return a copy. This is to avoid future
     // decode operations writing to the same bitmap.
     SkBitmap copyBitmap;
     fullSizeBitmap.copyTo(&copyBitmap, fullSizeBitmap.config(), &m_allocator);
-    return ScaledImageFragment::createPartial(m_fullSize, 0, nextGenerationId(), copyBitmap);
+    return ScaledImageFragment::createPartial(m_fullSize, index, nextGenerationId(), copyBitmap);
 }
 
-bool ImageFrameGenerator::hasAlpha()
+bool ImageFrameGenerator::hasAlpha(size_t index)
 {
     MutexLocker lock(m_alphaMutex);
-    return m_hasAlpha;
+    if (index < m_hasAlpha.size())
+        return m_hasAlpha[index];
+    return true;
 }
 
 } // namespace WebCore
diff --git a/Source/core/platform/graphics/chromium/ImageFrameGenerator.h b/Source/core/platform/graphics/chromium/ImageFrameGenerator.h
index 4c8be42..6d0f35c 100644
--- a/Source/core/platform/graphics/chromium/ImageFrameGenerator.h
+++ b/Source/core/platform/graphics/chromium/ImageFrameGenerator.h
@@ -31,13 +31,13 @@
 #include "SkTypes.h"
 #include "core/platform/graphics/chromium/DiscardablePixelRef.h"
 #include "core/platform/graphics/chromium/ThreadSafeDataTransport.h"
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/ThreadingPrimitives.h>
-#include <wtf/ThreadSafeRefCounted.h>
-#include <wtf/Vector.h>
+#include "wtf/PassOwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/ThreadingPrimitives.h"
+#include "wtf/ThreadSafeRefCounted.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
@@ -53,15 +53,15 @@
 
 class ImageFrameGenerator : public ThreadSafeRefCounted<ImageFrameGenerator> {
 public:
-    static PassRefPtr<ImageFrameGenerator> create(const SkISize& fullSize, PassRefPtr<SharedBuffer> data, bool allDataReceived)
+    static PassRefPtr<ImageFrameGenerator> create(const SkISize& fullSize, PassRefPtr<SharedBuffer> data, bool allDataReceived, bool isMultiFrame = false)
     {
-        return adoptRef(new ImageFrameGenerator(fullSize, data, allDataReceived));
+        return adoptRef(new ImageFrameGenerator(fullSize, data, allDataReceived, isMultiFrame));
     }
 
-    ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer>, bool allDataReceived);
+    ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer>, bool allDataReceived, bool isMultiFrame);
     ~ImageFrameGenerator();
 
-    const ScaledImageFragment* decodeAndScale(const SkISize& scaledSize);
+    const ScaledImageFragment* decodeAndScale(const SkISize& scaledSize, size_t index = 0);
 
     void setData(PassRefPtr<SharedBuffer>, bool allDataReceived);
 
@@ -70,19 +70,22 @@
 
     SkISize getFullSize() const { return m_fullSize; }
 
+    bool isMultiFrame() const { return m_isMultiFrame; }
+
     void setImageDecoderFactoryForTesting(PassOwnPtr<ImageDecoderFactory> factory) { m_imageDecoderFactory = factory; }
 
-    bool hasAlpha();
+    // FIXME: Return alpha state for each frame.
+    bool hasAlpha(size_t);
 
 private:
     // These methods are called while m_decodeMutex is locked.
-    const ScaledImageFragment* tryToLockCompleteCache(const SkISize& scaledSize);
-    const ScaledImageFragment* tryToScale(const ScaledImageFragment* fullSizeImage, const SkISize& scaledSize);
-    const ScaledImageFragment* tryToResumeDecodeAndScale(const SkISize& scaledSize);
-    const ScaledImageFragment* tryToDecodeAndScale(const SkISize& scaledSize);
+    const ScaledImageFragment* tryToLockCompleteCache(const SkISize& scaledSize, size_t index);
+    const ScaledImageFragment* tryToScale(const ScaledImageFragment* fullSizeImage, const SkISize& scaledSize, size_t index);
+    const ScaledImageFragment* tryToResumeDecodeAndScale(const SkISize& scaledSize, size_t index);
+    const ScaledImageFragment* tryToDecodeAndScale(const SkISize& scaledSize, size_t index);
 
     // Use the given decoder to decode. If a decoder is not given then try to create one.
-    PassOwnPtr<ScaledImageFragment> decode(ImageDecoder**);
+    PassOwnPtr<ScaledImageFragment> decode(size_t index, ImageDecoder**);
 
     // Return the next generation ID of a new image object. This is used
     // to identify images of the same frame from different stages of
@@ -91,8 +94,9 @@
 
     SkISize m_fullSize;
     ThreadSafeDataTransport m_data;
+    bool m_isMultiFrame;
     bool m_decodeFailedAndEmpty;
-    bool m_hasAlpha;
+    Vector<bool> m_hasAlpha;
     size_t m_decodeCount;
     DiscardablePixelRefAllocator m_allocator;
 
diff --git a/Source/core/platform/graphics/chromium/ImageFrameGeneratorTest.cpp b/Source/core/platform/graphics/chromium/ImageFrameGeneratorTest.cpp
index 7335763..4e04d87 100644
--- a/Source/core/platform/graphics/chromium/ImageFrameGeneratorTest.cpp
+++ b/Source/core/platform/graphics/chromium/ImageFrameGeneratorTest.cpp
@@ -95,6 +95,10 @@
         return m_frameStatus;
     }
 
+    virtual size_t frameCount() { return 1; }
+    virtual int repetitionCount() const { return cAnimationNone; }
+    virtual float frameDuration() const { return 0; }
+
 protected:
     PassOwnPtr<ScaledImageFragment> createCompleteImage(const SkISize& size)
     {
@@ -137,7 +141,7 @@
     const ScaledImageFragment* tempImage = m_generator->decodeAndScale(fullSize());
     EXPECT_EQ(fullImage, tempImage);
     EXPECT_EQ(fullSize(), tempImage->scaledSize());
-    EXPECT_TRUE(m_generator->hasAlpha());
+    EXPECT_TRUE(m_generator->hasAlpha(0));
     ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
     EXPECT_EQ(0, m_frameBufferRequestCount);
 }
@@ -153,14 +157,14 @@
     const ScaledImageFragment* scaledImage = m_generator->decodeAndScale(scaledSize());
     EXPECT_NE(fullImage, scaledImage);
     EXPECT_EQ(scaledSize(), scaledImage->scaledSize());
-    EXPECT_TRUE(m_generator->hasAlpha());
+    EXPECT_TRUE(m_generator->hasAlpha(0));
     ImageDecodingStore::instance()->unlockCache(m_generator.get(), scaledImage);
 
     // Cache hit.
     const ScaledImageFragment* tempImage = m_generator->decodeAndScale(scaledSize());
     EXPECT_EQ(scaledImage, tempImage);
     EXPECT_EQ(scaledSize(), tempImage->scaledSize());
-    EXPECT_TRUE(m_generator->hasAlpha());
+    EXPECT_TRUE(m_generator->hasAlpha(0));
     ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
     EXPECT_EQ(0, m_frameBufferRequestCount);
 }
@@ -173,7 +177,7 @@
     const ScaledImageFragment* scaledImage = m_generator->decodeAndScale(scaledSize());
     EXPECT_EQ(1, m_frameBufferRequestCount);
     EXPECT_EQ(scaledSize(), scaledImage->scaledSize());
-    EXPECT_FALSE(m_generator->hasAlpha());
+    EXPECT_FALSE(m_generator->hasAlpha(0));
     ImageDecodingStore::instance()->unlockCache(m_generator.get(), scaledImage);
     EXPECT_EQ(1, m_decodersDestroyed);
 
@@ -181,14 +185,14 @@
     const ScaledImageFragment* fullImage = m_generator->decodeAndScale(fullSize());
     EXPECT_NE(scaledImage, fullImage);
     EXPECT_EQ(fullSize(), fullImage->scaledSize());
-    EXPECT_FALSE(m_generator->hasAlpha());
+    EXPECT_FALSE(m_generator->hasAlpha(0));
     ImageDecodingStore::instance()->unlockCache(m_generator.get(), fullImage);
 
     // Cache hit.
     const ScaledImageFragment* tempImage = m_generator->decodeAndScale(scaledSize());
     EXPECT_EQ(scaledImage, tempImage);
     EXPECT_EQ(scaledSize(), tempImage->scaledSize());
-    EXPECT_FALSE(m_generator->hasAlpha());
+    EXPECT_FALSE(m_generator->hasAlpha(0));
     ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
     EXPECT_EQ(1, m_frameBufferRequestCount);
 }
@@ -388,4 +392,35 @@
     ImageDecodingStore::instance()->unlockDecoder(m_generator.get(), tempDecoder);
 }
 
+TEST_F(ImageFrameGeneratorTest, resumeDecodeEmptyFrame)
+{
+    m_generator = ImageFrameGenerator::create(fullSize(), m_data, false, true);
+    m_generator->setImageDecoderFactoryForTesting(MockImageDecoderFactory::create(this));
+    setFrameStatus(ImageFrame::FrameComplete);
+
+    const ScaledImageFragment* tempImage = m_generator->decodeAndScale(fullSize(), 0);
+    EXPECT_TRUE(tempImage->isComplete());
+    ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage);
+
+    setFrameStatus(ImageFrame::FrameEmpty);
+    EXPECT_FALSE(m_generator->decodeAndScale(fullSize(), 1));
+}
+
+TEST_F(ImageFrameGeneratorTest, frameHasAlpha)
+{
+    setFrameStatus(ImageFrame::FramePartial);
+    ImageDecodingStore::instance()->unlockCache(m_generator.get(), m_generator->decodeAndScale(fullSize(), 1));
+    EXPECT_TRUE(m_generator->hasAlpha(1));
+
+    ImageDecoder* tempDecoder = 0;
+    EXPECT_TRUE(ImageDecodingStore::instance()->lockDecoder(m_generator.get(), fullSize(), &tempDecoder));
+    ASSERT_TRUE(tempDecoder);
+    static_cast<MockImageDecoder*>(tempDecoder)->setFrameHasAlpha(false);
+    ImageDecodingStore::instance()->unlockDecoder(m_generator.get(), tempDecoder);
+
+    setFrameStatus(ImageFrame::FrameComplete);
+    ImageDecodingStore::instance()->unlockCache(m_generator.get(), m_generator->decodeAndScale(fullSize(), 1));
+    EXPECT_FALSE(m_generator->hasAlpha(1));
+}
+
 } // namespace
diff --git a/Source/core/platform/graphics/chromium/LazyDecodingPixelRef.cpp b/Source/core/platform/graphics/chromium/LazyDecodingPixelRef.cpp
index d4f704b..8c3ad27 100644
--- a/Source/core/platform/graphics/chromium/LazyDecodingPixelRef.cpp
+++ b/Source/core/platform/graphics/chromium/LazyDecodingPixelRef.cpp
@@ -30,12 +30,12 @@
 #include "core/platform/chromium/TraceEvent.h"
 #include "core/platform/graphics/chromium/ImageDecodingStore.h"
 #include "core/platform/graphics/chromium/ImageFrameGenerator.h"
-#include <wtf/MainThread.h>
 
 namespace WebCore {
 
-LazyDecodingPixelRef::LazyDecodingPixelRef(PassRefPtr<ImageFrameGenerator> frameGenerator, const SkISize& scaledSize, const SkIRect& scaledSubset)
+LazyDecodingPixelRef::LazyDecodingPixelRef(PassRefPtr<ImageFrameGenerator> frameGenerator, const SkISize& scaledSize, size_t index, const SkIRect& scaledSubset)
     : m_frameGenerator(frameGenerator)
+    , m_frameIndex(index)
     , m_scaledSize(scaledSize)
     , m_scaledSubset(scaledSubset)
     , m_lockedCachedImage(0)
@@ -76,16 +76,15 @@
 {
     TRACE_EVENT_ASYNC_BEGIN0("webkit", "LazyDecodingPixelRef::lockPixels", this);
 
-    m_mutex.lock();
     ASSERT(!m_lockedCachedImage);
 
-    if (!ImageDecodingStore::instance()->lockCache(m_frameGenerator.get(), m_scaledSize, 0, &m_lockedCachedImage))
+    if (!ImageDecodingStore::instance()->lockCache(m_frameGenerator.get(), m_scaledSize, m_frameIndex, &m_lockedCachedImage))
         m_lockedCachedImage = 0;
 
     // Use ImageFrameGenerator to generate the image. It will lock the cache
     // entry for us.
     if (!m_lockedCachedImage)
-        m_lockedCachedImage = m_frameGenerator->decodeAndScale(m_scaledSize);
+        m_lockedCachedImage = m_frameGenerator->decodeAndScale(m_scaledSize, m_frameIndex);
 
     if (!m_lockedCachedImage)
         return 0;
@@ -101,7 +100,6 @@
         ImageDecodingStore::instance()->unlockCache(m_frameGenerator.get(), m_lockedCachedImage);
         m_lockedCachedImage = 0;
     }
-    m_mutex.unlock();
 
     TRACE_EVENT_ASYNC_END0("webkit", "LazyDecodingPixelRef::lockPixels", this);
 }
@@ -113,18 +111,13 @@
 
 bool LazyDecodingPixelRef::MaybeDecoded()
 {
-    return ImageDecodingStore::instance()->isCached(m_frameGenerator.get(), m_scaledSize, 0);
+    return ImageDecodingStore::instance()->isCached(m_frameGenerator.get(), m_scaledSize, m_frameIndex);
 }
 
 bool LazyDecodingPixelRef::PrepareToDecode(const LazyPixelRef::PrepareParams& params)
 {
-    // TODO: check if only a particular rect is available in image cache.
-    UNUSED_PARAM(params);
-    const ScaledImageFragment* cachedImage = 0;
-    bool cached = ImageDecodingStore::instance()->lockCache(m_frameGenerator.get(), m_scaledSize, 0, &cachedImage);
-    if (cached)
-        ImageDecodingStore::instance()->unlockCache(m_frameGenerator.get(), cachedImage);
-    return cached;
+    ASSERT(false);
+    return false;
 }
 
 void LazyDecodingPixelRef::Decode()
diff --git a/Source/core/platform/graphics/chromium/LazyDecodingPixelRef.h b/Source/core/platform/graphics/chromium/LazyDecodingPixelRef.h
index a455c21..bb288eb 100644
--- a/Source/core/platform/graphics/chromium/LazyDecodingPixelRef.h
+++ b/Source/core/platform/graphics/chromium/LazyDecodingPixelRef.h
@@ -33,8 +33,7 @@
 #include "SkTypes.h"
 #include "skia/ext/lazy_pixel_ref.h"
 
-#include <wtf/RefPtr.h>
-#include <wtf/ThreadingPrimitives.h>
+#include "wtf/RefPtr.h"
 
 using skia::LazyPixelRef;
 
@@ -47,12 +46,13 @@
 
 class LazyDecodingPixelRef : public LazyPixelRef {
 public:
-    LazyDecodingPixelRef(PassRefPtr<ImageFrameGenerator>, const SkISize& scaledSize, const SkIRect& scaledSubset);
+    LazyDecodingPixelRef(PassRefPtr<ImageFrameGenerator>, const SkISize& scaledSize, size_t index, const SkIRect& scaledSubset);
     virtual ~LazyDecodingPixelRef();
 
     SK_DECLARE_UNFLATTENABLE_OBJECT()
 
     PassRefPtr<ImageFrameGenerator> frameGenerator() const { return m_frameGenerator; }
+    size_t frameIndex() const { return m_frameIndex; }
     bool isScaled(const SkISize& fullSize) const;
     bool isClipped() const;
 
@@ -72,11 +72,11 @@
 
 private:
     RefPtr<ImageFrameGenerator> m_frameGenerator;
+    size_t m_frameIndex;
     SkISize m_scaledSize;
     SkIRect m_scaledSubset;
 
     const ScaledImageFragment* m_lockedCachedImage;
-    Mutex m_mutex;
 };
 
 } // namespace WebCore
diff --git a/Source/core/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h b/Source/core/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h
index f671db9..e83ce93 100644
--- a/Source/core/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h
+++ b/Source/core/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h
@@ -26,8 +26,8 @@
 #define OpaqueRectTrackingContentLayerDelegate_h
 
 #include "public/platform/WebContentLayerClient.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
+#include "wtf/Noncopyable.h"
+#include "wtf/PassOwnPtr.h"
 
 class SkCanvas;
 
diff --git a/Source/core/platform/graphics/chromium/ScaledImageFragment.h b/Source/core/platform/graphics/chromium/ScaledImageFragment.h
index 4bbc417..0bfdea1 100644
--- a/Source/core/platform/graphics/chromium/ScaledImageFragment.h
+++ b/Source/core/platform/graphics/chromium/ScaledImageFragment.h
@@ -30,7 +30,7 @@
 #include "SkRect.h"
 #include "SkSize.h"
 
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp b/Source/core/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp
index 640b5d8..3907453 100644
--- a/Source/core/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp
+++ b/Source/core/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp
@@ -42,7 +42,7 @@
 #include "core/platform/graphics/FontDescription.h"
 #include "core/platform/graphics/chromium/FontPlatformDataChromiumWin.h"
 #include "core/platform/win/HWndDC.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/chromium/SkSizeHash.h b/Source/core/platform/graphics/chromium/SkSizeHash.h
index 6f297cf..dd95c82 100644
--- a/Source/core/platform/graphics/chromium/SkSizeHash.h
+++ b/Source/core/platform/graphics/chromium/SkSizeHash.h
@@ -29,7 +29,7 @@
 #include "SkScalar.h"
 #include "SkSize.h"
 
-#include <wtf/HashMap.h>
+#include "wtf/HashMap.h"
 
 namespace WTF {
 
diff --git a/Source/core/platform/graphics/chromium/ThreadSafeDataTransport.h b/Source/core/platform/graphics/chromium/ThreadSafeDataTransport.h
index 81cc64b..431f545 100644
--- a/Source/core/platform/graphics/chromium/ThreadSafeDataTransport.h
+++ b/Source/core/platform/graphics/chromium/ThreadSafeDataTransport.h
@@ -26,11 +26,11 @@
 #ifndef ThreadSafeDataTransport_h
 #define ThreadSafeDataTransport_h
 
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefPtr.h>
-#include <wtf/ThreadingPrimitives.h>
-#include <wtf/Vector.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/RefPtr.h"
+#include "wtf/ThreadingPrimitives.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/chromium/TransparencyWin.h b/Source/core/platform/graphics/chromium/TransparencyWin.h
index 98c3c01..e755bb4 100644
--- a/Source/core/platform/graphics/chromium/TransparencyWin.h
+++ b/Source/core/platform/graphics/chromium/TransparencyWin.h
@@ -36,8 +36,8 @@
 #include "core/platform/graphics/ImageBuffer.h"
 #include "core/platform/graphics/transforms/AffineTransform.h"
  
-#include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
+#include "wtf/Noncopyable.h"
+#include "wtf/OwnPtr.h"
 
 class SkBitmap;
 class SkCanvas;
diff --git a/Source/core/platform/graphics/chromium/UniscribeHelper.cpp b/Source/core/platform/graphics/chromium/UniscribeHelper.cpp
index ffdd746..5fd554c 100644
--- a/Source/core/platform/graphics/chromium/UniscribeHelper.cpp
+++ b/Source/core/platform/graphics/chromium/UniscribeHelper.cpp
@@ -38,7 +38,7 @@
 #include "core/platform/graphics/skia/SkiaFontWin.h"
 #include "core/platform/win/HWndDC.h"
 #include "third_party/skia/include/core/SkPoint.h"
-#include <wtf/Assertions.h>
+#include "wtf/Assertions.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/chromium/UniscribeHelper.h b/Source/core/platform/graphics/chromium/UniscribeHelper.h
index 8db169a..9287dcc 100644
--- a/Source/core/platform/graphics/chromium/UniscribeHelper.h
+++ b/Source/core/platform/graphics/chromium/UniscribeHelper.h
@@ -38,7 +38,7 @@
 #include <map>
 
 #include <unicode/uchar.h>
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 class UniscribeTest_TooBig_Test; // A gunit test for UniscribeHelper.
 
diff --git a/Source/core/platform/graphics/chromium/VDMXParser.cpp b/Source/core/platform/graphics/chromium/VDMXParser.cpp
index 1d6d3d0..6ff8eb4 100644
--- a/Source/core/platform/graphics/chromium/VDMXParser.cpp
+++ b/Source/core/platform/graphics/chromium/VDMXParser.cpp
@@ -32,7 +32,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <wtf/ByteOrder.h>
+#include "wtf/ByteOrder.h"
 
 // Buffer helper class
 //
diff --git a/Source/core/platform/graphics/chromium/test/MockImageDecoder.h b/Source/core/platform/graphics/chromium/test/MockImageDecoder.h
index b29c722..50b05c8 100644
--- a/Source/core/platform/graphics/chromium/test/MockImageDecoder.h
+++ b/Source/core/platform/graphics/chromium/test/MockImageDecoder.h
@@ -35,6 +35,9 @@
     virtual void decoderBeingDestroyed() = 0;
     virtual void frameBufferRequested() = 0;
     virtual ImageFrame::FrameStatus frameStatus() = 0;
+    virtual size_t frameCount() = 0;
+    virtual int repetitionCount() const = 0;
+    virtual float frameDuration() const = 0;
 };
 
 class MockImageDecoder : public ImageDecoder {
@@ -43,7 +46,6 @@
 
     MockImageDecoder(MockImageDecoderClient* client)
         : ImageDecoder(ImageSource::AlphaPremultiplied, ImageSource::GammaAndColorProfileApplied)
-        , m_frameBufferRequestCount(0)
         , m_client(client)
     { }
 
@@ -67,19 +69,35 @@
         return "mock";
     }
 
+    virtual size_t frameCount()
+    {
+        return m_client->frameCount();
+    }
+
+    virtual int repetitionCount() const
+    {
+        return m_client->repetitionCount();
+    }
+
     virtual ImageFrame* frameBufferAtIndex(size_t)
     {
-        ++m_frameBufferRequestCount;
         m_client->frameBufferRequested();
 
         m_frameBufferCache[0].setStatus(m_client->frameStatus());
         return &m_frameBufferCache[0];
     }
 
-    int frameBufferRequestCount() const { return m_frameBufferRequestCount; }
+    virtual bool frameIsCompleteAtIndex(size_t) const
+    {
+        return m_client->frameStatus() == ImageFrame::FrameComplete;
+    }
+
+    virtual float frameDurationAtIndex(size_t) const
+    {
+        return m_client->frameDuration();
+    }
 
 private:
-    int m_frameBufferRequestCount;
     MockImageDecoderClient* m_client;
 };
 
diff --git a/Source/core/platform/graphics/filters/FEBlend.cpp b/Source/core/platform/graphics/filters/FEBlend.cpp
index 4df9e5c..b4fb7cb 100644
--- a/Source/core/platform/graphics/filters/FEBlend.cpp
+++ b/Source/core/platform/graphics/filters/FEBlend.cpp
@@ -32,7 +32,7 @@
 #include "core/platform/text/TextStream.h"
 #include "core/rendering/RenderTreeAsText.h"
 
-#include <wtf/Uint8ClampedArray.h>
+#include "wtf/Uint8ClampedArray.h"
 
 #include "SkBitmapSource.h"
 #include "SkXfermodeImageFilter.h"
diff --git a/Source/core/platform/graphics/filters/FEColorMatrix.cpp b/Source/core/platform/graphics/filters/FEColorMatrix.cpp
index 3abca59..64dbcd4 100644
--- a/Source/core/platform/graphics/filters/FEColorMatrix.cpp
+++ b/Source/core/platform/graphics/filters/FEColorMatrix.cpp
@@ -32,8 +32,8 @@
 #include "core/platform/text/TextStream.h"
 #include "core/rendering/RenderTreeAsText.h"
 
-#include <wtf/MathExtras.h>
-#include <wtf/Uint8ClampedArray.h>
+#include "wtf/MathExtras.h"
+#include "wtf/Uint8ClampedArray.h"
 
 #include "SkColorFilterImageFilter.h"
 #include "SkColorMatrixFilter.h"
diff --git a/Source/core/platform/graphics/filters/FEColorMatrix.h b/Source/core/platform/graphics/filters/FEColorMatrix.h
index 73e915f..1a86288 100644
--- a/Source/core/platform/graphics/filters/FEColorMatrix.h
+++ b/Source/core/platform/graphics/filters/FEColorMatrix.h
@@ -26,7 +26,7 @@
 #include "core/platform/graphics/filters/FilterEffect.h"
 
 #include "core/platform/graphics/filters/Filter.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/FEComponentTransfer.cpp b/Source/core/platform/graphics/filters/FEComponentTransfer.cpp
index 86d2fc3..2a16160 100644
--- a/Source/core/platform/graphics/filters/FEComponentTransfer.cpp
+++ b/Source/core/platform/graphics/filters/FEComponentTransfer.cpp
@@ -31,9 +31,9 @@
 #include "core/platform/text/TextStream.h"
 #include "core/rendering/RenderTreeAsText.h"
 
-#include <wtf/MathExtras.h>
-#include <wtf/StdLibExtras.h>
-#include <wtf/Uint8ClampedArray.h>
+#include "wtf/MathExtras.h"
+#include "wtf/StdLibExtras.h"
+#include "wtf/Uint8ClampedArray.h"
 
 #include "SkColorFilterImageFilter.h"
 #include "SkTableColorFilter.h"
diff --git a/Source/core/platform/graphics/filters/FEComponentTransfer.h b/Source/core/platform/graphics/filters/FEComponentTransfer.h
index f2d87d2..03c18c2 100644
--- a/Source/core/platform/graphics/filters/FEComponentTransfer.h
+++ b/Source/core/platform/graphics/filters/FEComponentTransfer.h
@@ -26,7 +26,7 @@
 #include "core/platform/graphics/filters/FilterEffect.h"
 
 #include "core/platform/graphics/filters/Filter.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/FEComposite.cpp b/Source/core/platform/graphics/filters/FEComposite.cpp
index 35c7268..4dfeed4 100644
--- a/Source/core/platform/graphics/filters/FEComposite.cpp
+++ b/Source/core/platform/graphics/filters/FEComposite.cpp
@@ -37,7 +37,7 @@
 #include "core/rendering/RenderTreeAsText.h"
 #include "third_party/skia/include/core/SkDevice.h"
 
-#include <wtf/Uint8ClampedArray.h>
+#include "wtf/Uint8ClampedArray.h"
 
 #include "core/platform/graphics/filters/SkiaImageFilterBuilder.h"
 
diff --git a/Source/core/platform/graphics/filters/FEComposite.h b/Source/core/platform/graphics/filters/FEComposite.h
index f2dca6c..9d66533 100644
--- a/Source/core/platform/graphics/filters/FEComposite.h
+++ b/Source/core/platform/graphics/filters/FEComposite.h
@@ -26,7 +26,7 @@
 #include "core/platform/graphics/filters/FilterEffect.h"
 
 #include "core/platform/graphics/filters/Filter.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/FEConvolveMatrix.cpp b/Source/core/platform/graphics/filters/FEConvolveMatrix.cpp
index 5c5882c..c8ab271 100644
--- a/Source/core/platform/graphics/filters/FEConvolveMatrix.cpp
+++ b/Source/core/platform/graphics/filters/FEConvolveMatrix.cpp
@@ -30,9 +30,9 @@
 #include "core/platform/text/TextStream.h"
 #include "core/rendering/RenderTreeAsText.h"
 
-#include <wtf/OwnArrayPtr.h>
-#include <wtf/ParallelJobs.h>
-#include <wtf/Uint8ClampedArray.h>
+#include "wtf/OwnArrayPtr.h"
+#include "wtf/ParallelJobs.h"
+#include "wtf/Uint8ClampedArray.h"
 
 #include "SkMatrixConvolutionImageFilter.h"
 #include "core/platform/graphics/filters/SkiaImageFilterBuilder.h"
diff --git a/Source/core/platform/graphics/filters/FEConvolveMatrix.h b/Source/core/platform/graphics/filters/FEConvolveMatrix.h
index d3ad00d..4f8915e 100644
--- a/Source/core/platform/graphics/filters/FEConvolveMatrix.h
+++ b/Source/core/platform/graphics/filters/FEConvolveMatrix.h
@@ -28,7 +28,7 @@
 #include "core/platform/graphics/FloatSize.h"
 #include "core/platform/graphics/filters/Filter.h"
 #include "core/platform/graphics/filters/FilterEffect.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/FEDisplacementMap.cpp b/Source/core/platform/graphics/filters/FEDisplacementMap.cpp
index 5f9a0b8..abb22c1 100644
--- a/Source/core/platform/graphics/filters/FEDisplacementMap.cpp
+++ b/Source/core/platform/graphics/filters/FEDisplacementMap.cpp
@@ -31,7 +31,7 @@
 #include "core/platform/text/TextStream.h"
 #include "core/rendering/RenderTreeAsText.h"
 
-#include <wtf/Uint8ClampedArray.h>
+#include "wtf/Uint8ClampedArray.h"
 
 #include "SkBitmapSource.h"
 #include "SkDisplacementMapEffect.h"
diff --git a/Source/core/platform/graphics/filters/FEDisplacementMap.h b/Source/core/platform/graphics/filters/FEDisplacementMap.h
index 47ea409..0d914f7 100644
--- a/Source/core/platform/graphics/filters/FEDisplacementMap.h
+++ b/Source/core/platform/graphics/filters/FEDisplacementMap.h
@@ -25,7 +25,7 @@
 
 #include "core/platform/graphics/filters/Filter.h"
 #include "core/platform/graphics/filters/FilterEffect.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/FEDropShadow.cpp b/Source/core/platform/graphics/filters/FEDropShadow.cpp
index 4afb16b..04bb1e9 100644
--- a/Source/core/platform/graphics/filters/FEDropShadow.cpp
+++ b/Source/core/platform/graphics/filters/FEDropShadow.cpp
@@ -28,8 +28,8 @@
 #include "core/platform/graphics/filters/Filter.h"
 #include "core/platform/text/TextStream.h"
 #include "core/rendering/RenderTreeAsText.h"
-#include <wtf/MathExtras.h>
-#include <wtf/Uint8ClampedArray.h>
+#include "wtf/MathExtras.h"
+#include "wtf/Uint8ClampedArray.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/graphics/filters/FEGaussianBlur.cpp b/Source/core/platform/graphics/filters/FEGaussianBlur.cpp
index c90d001..cb13681 100644
--- a/Source/core/platform/graphics/filters/FEGaussianBlur.cpp
+++ b/Source/core/platform/graphics/filters/FEGaussianBlur.cpp
@@ -34,9 +34,9 @@
 #include "core/platform/text/TextStream.h"
 #include "core/rendering/RenderTreeAsText.h"
 
-#include <wtf/MathExtras.h>
-#include <wtf/ParallelJobs.h>
-#include <wtf/Uint8ClampedArray.h>
+#include "wtf/MathExtras.h"
+#include "wtf/ParallelJobs.h"
+#include "wtf/Uint8ClampedArray.h"
 
 #include "SkBlurImageFilter.h"
 
diff --git a/Source/core/platform/graphics/filters/FELighting.cpp b/Source/core/platform/graphics/filters/FELighting.cpp
index c1449ef..246d269 100644
--- a/Source/core/platform/graphics/filters/FELighting.cpp
+++ b/Source/core/platform/graphics/filters/FELighting.cpp
@@ -30,7 +30,7 @@
 #include "core/platform/graphics/filters/FELighting.h"
 
 #include "core/platform/graphics/cpu/arm/filters/FELightingNEON.h"
-#include <wtf/ParallelJobs.h>
+#include "wtf/ParallelJobs.h"
 
 #include "SkLightingImageFilter.h"
 #include "core/platform/graphics/filters/DistantLightSource.h"
diff --git a/Source/core/platform/graphics/filters/FELighting.h b/Source/core/platform/graphics/filters/FELighting.h
index 149c3c2..c2c674c 100644
--- a/Source/core/platform/graphics/filters/FELighting.h
+++ b/Source/core/platform/graphics/filters/FELighting.h
@@ -34,7 +34,7 @@
 #include "core/platform/graphics/filters/LightSource.h"
 #include "core/platform/graphics/filters/PointLightSource.h"
 #include "core/platform/graphics/filters/SpotLightSource.h"
-#include <wtf/Uint8ClampedArray.h>
+#include "wtf/Uint8ClampedArray.h"
 
 // Common base class for FEDiffuseLighting and FESpecularLighting
 
diff --git a/Source/core/platform/graphics/filters/FEMerge.cpp b/Source/core/platform/graphics/filters/FEMerge.cpp
index 330e881..0bcdeca 100644
--- a/Source/core/platform/graphics/filters/FEMerge.cpp
+++ b/Source/core/platform/graphics/filters/FEMerge.cpp
@@ -30,7 +30,7 @@
 #include "core/platform/graphics/filters/SkiaImageFilterBuilder.h"
 #include "core/platform/text/TextStream.h"
 #include "core/rendering/RenderTreeAsText.h"
-#include <wtf/OwnArrayPtr.h>
+#include "wtf/OwnArrayPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/FEMerge.h b/Source/core/platform/graphics/filters/FEMerge.h
index 3c8a48e..20b0c4a 100644
--- a/Source/core/platform/graphics/filters/FEMerge.h
+++ b/Source/core/platform/graphics/filters/FEMerge.h
@@ -25,7 +25,7 @@
 
 #include "core/platform/graphics/filters/Filter.h"
 #include "core/platform/graphics/filters/FilterEffect.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/FEMorphology.cpp b/Source/core/platform/graphics/filters/FEMorphology.cpp
index 1d9f783..c2a4b2d 100644
--- a/Source/core/platform/graphics/filters/FEMorphology.cpp
+++ b/Source/core/platform/graphics/filters/FEMorphology.cpp
@@ -32,9 +32,9 @@
 #include "core/platform/text/TextStream.h"
 #include "core/rendering/RenderTreeAsText.h"
 
-#include <wtf/ParallelJobs.h>
-#include <wtf/Uint8ClampedArray.h>
-#include <wtf/Vector.h>
+#include "wtf/ParallelJobs.h"
+#include "wtf/Uint8ClampedArray.h"
+#include "wtf/Vector.h"
 
 #include "SkMorphologyImageFilter.h"
 
diff --git a/Source/core/platform/graphics/filters/FETurbulence.cpp b/Source/core/platform/graphics/filters/FETurbulence.cpp
index 57b74d5..1cae91a 100644
--- a/Source/core/platform/graphics/filters/FETurbulence.cpp
+++ b/Source/core/platform/graphics/filters/FETurbulence.cpp
@@ -32,9 +32,9 @@
 #include "core/platform/text/TextStream.h"
 #include "core/rendering/RenderTreeAsText.h"
 
-#include <wtf/MathExtras.h>
-#include <wtf/ParallelJobs.h>
-#include <wtf/Uint8ClampedArray.h>
+#include "wtf/MathExtras.h"
+#include "wtf/ParallelJobs.h"
+#include "wtf/Uint8ClampedArray.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/Filter.h b/Source/core/platform/graphics/filters/Filter.h
index 786f653..187bfd7 100644
--- a/Source/core/platform/graphics/filters/Filter.h
+++ b/Source/core/platform/graphics/filters/Filter.h
@@ -24,7 +24,7 @@
 #include "core/platform/graphics/FloatRect.h"
 #include "core/platform/graphics/FloatSize.h"
 #include "core/platform/graphics/ImageBuffer.h"
-#include <wtf/RefCounted.h>
+#include "wtf/RefCounted.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/FilterEffect.cpp b/Source/core/platform/graphics/filters/FilterEffect.cpp
index c1b9ed2..f555397 100644
--- a/Source/core/platform/graphics/filters/FilterEffect.cpp
+++ b/Source/core/platform/graphics/filters/FilterEffect.cpp
@@ -27,7 +27,7 @@
 
 #include "core/platform/graphics/ImageBuffer.h"
 #include "core/platform/graphics/filters/Filter.h"
-#include <wtf/Uint8ClampedArray.h>
+#include "wtf/Uint8ClampedArray.h"
 
 #if HAVE(ARM_NEON_INTRINSICS)
 #include <arm_neon.h>
diff --git a/Source/core/platform/graphics/filters/FilterEffect.h b/Source/core/platform/graphics/filters/FilterEffect.h
index cb79746..e7a7036 100644
--- a/Source/core/platform/graphics/filters/FilterEffect.h
+++ b/Source/core/platform/graphics/filters/FilterEffect.h
@@ -27,11 +27,11 @@
 #include "core/platform/graphics/FloatRect.h"
 #include "core/platform/graphics/IntRect.h"
 
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/Uint8ClampedArray.h>
-#include <wtf/Vector.h>
+#include "wtf/PassOwnPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/Uint8ClampedArray.h"
+#include "wtf/Vector.h"
 
 static const float kMaxFilterSize = 5000.0f;
 
diff --git a/Source/core/platform/graphics/filters/FilterOperations.h b/Source/core/platform/graphics/filters/FilterOperations.h
index e1d0851..bedf2a4 100644
--- a/Source/core/platform/graphics/filters/FilterOperations.h
+++ b/Source/core/platform/graphics/filters/FilterOperations.h
@@ -28,8 +28,8 @@
 
 #include "core/platform/graphics/IntRectExtent.h"
 #include "core/platform/graphics/filters/FilterOperation.h"
-#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/LightSource.h b/Source/core/platform/graphics/filters/LightSource.h
index 560410c..e47e850 100644
--- a/Source/core/platform/graphics/filters/LightSource.h
+++ b/Source/core/platform/graphics/filters/LightSource.h
@@ -25,8 +25,8 @@
 #define LightSource_h
 
 #include "core/platform/graphics/FloatPoint3D.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/SkiaImageFilterBuilder.h b/Source/core/platform/graphics/filters/SkiaImageFilterBuilder.h
index c5dcbad..aa90df3 100644
--- a/Source/core/platform/graphics/filters/SkiaImageFilterBuilder.h
+++ b/Source/core/platform/graphics/filters/SkiaImageFilterBuilder.h
@@ -27,7 +27,7 @@
 #define SkiaImageFilterBuilder_h
 
 #include "core/platform/graphics/ColorSpace.h"
-#include <wtf/HashMap.h>
+#include "wtf/HashMap.h"
 
 class SkImageFilter;
 
diff --git a/Source/core/platform/graphics/filters/SourceAlpha.cpp b/Source/core/platform/graphics/filters/SourceAlpha.cpp
index 74662e9..3eb1228 100644
--- a/Source/core/platform/graphics/filters/SourceAlpha.cpp
+++ b/Source/core/platform/graphics/filters/SourceAlpha.cpp
@@ -27,8 +27,8 @@
 #include "core/platform/graphics/filters/Filter.h"
 #include "core/platform/text/TextStream.h"
 #include "core/rendering/RenderTreeAsText.h"
-#include <wtf/StdLibExtras.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/StdLibExtras.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/SourceGraphic.cpp b/Source/core/platform/graphics/filters/SourceGraphic.cpp
index 8c22fd9..2a1ced8 100644
--- a/Source/core/platform/graphics/filters/SourceGraphic.cpp
+++ b/Source/core/platform/graphics/filters/SourceGraphic.cpp
@@ -26,8 +26,8 @@
 #include "core/platform/graphics/filters/Filter.h"
 #include "core/platform/text/TextStream.h"
 #include "core/rendering/RenderTreeAsText.h"
-#include <wtf/StdLibExtras.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/StdLibExtras.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/CustomFilterArrayParameter.h b/Source/core/platform/graphics/filters/custom/CustomFilterArrayParameter.h
index d57a1ef..ae1fe46 100644
--- a/Source/core/platform/graphics/filters/custom/CustomFilterArrayParameter.h
+++ b/Source/core/platform/graphics/filters/custom/CustomFilterArrayParameter.h
@@ -32,7 +32,7 @@
 
 #include "core/platform/animation/AnimationUtilities.h"
 #include "core/platform/graphics/filters/custom/CustomFilterParameter.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/CustomFilterCompiledProgram.h b/Source/core/platform/graphics/filters/custom/CustomFilterCompiledProgram.h
index 23d25a1..c5a5d42 100644
--- a/Source/core/platform/graphics/filters/custom/CustomFilterCompiledProgram.h
+++ b/Source/core/platform/graphics/filters/custom/CustomFilterCompiledProgram.h
@@ -32,8 +32,8 @@
 
 #include "core/platform/graphics/GraphicsContext3D.h"
 #include "core/platform/graphics/filters/custom/CustomFilterProgramInfo.h"
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/CustomFilterGlobalContext.h b/Source/core/platform/graphics/filters/custom/CustomFilterGlobalContext.h
index 7bc28d6..8d4d0f2 100644
--- a/Source/core/platform/graphics/filters/custom/CustomFilterGlobalContext.h
+++ b/Source/core/platform/graphics/filters/custom/CustomFilterGlobalContext.h
@@ -32,8 +32,8 @@
 
 #include "core/platform/graphics/ANGLEWebKitBridge.h"
 #include "core/platform/graphics/filters/custom/CustomFilterProgramInfo.h"
-#include <wtf/HashMap.h>
-#include <wtf/RefPtr.h>
+#include "wtf/HashMap.h"
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/CustomFilterMesh.h b/Source/core/platform/graphics/filters/custom/CustomFilterMesh.h
index 056dbba..022479f 100644
--- a/Source/core/platform/graphics/filters/custom/CustomFilterMesh.h
+++ b/Source/core/platform/graphics/filters/custom/CustomFilterMesh.h
@@ -33,7 +33,7 @@
 #include "core/platform/graphics/FloatRect.h"
 #include "core/platform/graphics/GraphicsTypes3D.h"
 #include "core/platform/graphics/filters/custom/CustomFilterOperation.h"
-#include <wtf/RefCounted.h>
+#include "wtf/RefCounted.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/CustomFilterNumberParameter.h b/Source/core/platform/graphics/filters/custom/CustomFilterNumberParameter.h
index df01f11..9706639 100644
--- a/Source/core/platform/graphics/filters/custom/CustomFilterNumberParameter.h
+++ b/Source/core/platform/graphics/filters/custom/CustomFilterNumberParameter.h
@@ -32,7 +32,7 @@
 
 #include "core/platform/animation/AnimationUtilities.h"
 #include "core/platform/graphics/filters/custom/CustomFilterParameter.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/CustomFilterParameter.h b/Source/core/platform/graphics/filters/custom/CustomFilterParameter.h
index 187a69c..57c2a55 100644
--- a/Source/core/platform/graphics/filters/custom/CustomFilterParameter.h
+++ b/Source/core/platform/graphics/filters/custom/CustomFilterParameter.h
@@ -30,9 +30,9 @@
 #ifndef CustomFilterParameter_h
 #define CustomFilterParameter_h
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/CustomFilterParameterList.cpp b/Source/core/platform/graphics/filters/custom/CustomFilterParameterList.cpp
index 2141758..c526d36 100644
--- a/Source/core/platform/graphics/filters/custom/CustomFilterParameterList.cpp
+++ b/Source/core/platform/graphics/filters/custom/CustomFilterParameterList.cpp
@@ -32,7 +32,7 @@
 #include "core/platform/graphics/filters/custom/CustomFilterParameterList.h"
 
 #include "core/platform/graphics/filters/custom/CustomFilterParameter.h"
-#include <wtf/text/StringHash.h>
+#include "wtf/text/StringHash.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/CustomFilterParameterList.h b/Source/core/platform/graphics/filters/custom/CustomFilterParameterList.h
index 182a9ab..6db3e99 100644
--- a/Source/core/platform/graphics/filters/custom/CustomFilterParameterList.h
+++ b/Source/core/platform/graphics/filters/custom/CustomFilterParameterList.h
@@ -31,7 +31,7 @@
 #define CustomFilterParameterList_h
 
 #include "core/platform/graphics/LayoutSize.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/CustomFilterProgram.h b/Source/core/platform/graphics/filters/custom/CustomFilterProgram.h
index b307328..e8b62b2 100644
--- a/Source/core/platform/graphics/filters/custom/CustomFilterProgram.h
+++ b/Source/core/platform/graphics/filters/custom/CustomFilterProgram.h
@@ -32,9 +32,9 @@
 
 #include "core/platform/graphics/filters/custom/CustomFilterProgramInfo.h"
 
-#include <wtf/HashCountedSet.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/HashCountedSet.h"
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/CustomFilterProgramInfo.cpp b/Source/core/platform/graphics/filters/custom/CustomFilterProgramInfo.cpp
index e7363b0..b2578e7 100644
--- a/Source/core/platform/graphics/filters/custom/CustomFilterProgramInfo.cpp
+++ b/Source/core/platform/graphics/filters/custom/CustomFilterProgramInfo.cpp
@@ -31,8 +31,8 @@
 
 #include "core/platform/graphics/filters/custom/CustomFilterProgramInfo.h"
 
-#include <wtf/HashFunctions.h>
-#include <wtf/text/StringHash.h>
+#include "wtf/HashFunctions.h"
+#include "wtf/text/StringHash.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/CustomFilterRenderer.h b/Source/core/platform/graphics/filters/custom/CustomFilterRenderer.h
index be22620..eeb6808 100644
--- a/Source/core/platform/graphics/filters/custom/CustomFilterRenderer.h
+++ b/Source/core/platform/graphics/filters/custom/CustomFilterRenderer.h
@@ -36,8 +36,8 @@
 #include "core/platform/graphics/IntSize.h"
 #include "core/platform/graphics/filters/custom/CustomFilterConstants.h"
 #include "core/platform/graphics/filters/custom/CustomFilterParameterList.h"
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/CustomFilterValidatedProgram.cpp b/Source/core/platform/graphics/filters/custom/CustomFilterValidatedProgram.cpp
index 90a32af..02076ea 100644
--- a/Source/core/platform/graphics/filters/custom/CustomFilterValidatedProgram.cpp
+++ b/Source/core/platform/graphics/filters/custom/CustomFilterValidatedProgram.cpp
@@ -36,10 +36,10 @@
 #include "core/platform/graphics/filters/custom/CustomFilterConstants.h"
 #include "core/platform/graphics/filters/custom/CustomFilterGlobalContext.h"
 #include "core/platform/graphics/filters/custom/CustomFilterProgramInfo.h"
-#include <wtf/HashMap.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/Vector.h>
+#include "wtf/HashMap.h"
+#include "wtf/text/StringBuilder.h"
+#include "wtf/text/StringHash.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/CustomFilterValidatedProgram.h b/Source/core/platform/graphics/filters/custom/CustomFilterValidatedProgram.h
index bfba3fb..9155709 100644
--- a/Source/core/platform/graphics/filters/custom/CustomFilterValidatedProgram.h
+++ b/Source/core/platform/graphics/filters/custom/CustomFilterValidatedProgram.h
@@ -32,10 +32,10 @@
 
 #include "core/platform/graphics/filters/custom/CustomFilterCompiledProgram.h"
 #include "core/platform/graphics/filters/custom/CustomFilterProgramInfo.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/text/WTFString.h"
 
 // PlatformCompiledProgram defines a type that is compatible with the framework used to implement accelerated compositing on a particular platform.
 namespace WebCore {
diff --git a/Source/core/platform/graphics/filters/custom/FECustomFilter.cpp b/Source/core/platform/graphics/filters/custom/FECustomFilter.cpp
index b6ce6c8..8cd3610 100644
--- a/Source/core/platform/graphics/filters/custom/FECustomFilter.cpp
+++ b/Source/core/platform/graphics/filters/custom/FECustomFilter.cpp
@@ -40,7 +40,7 @@
 #include "core/platform/text/TextStream.h"
 #include "core/rendering/RenderTreeAsText.h"
 
-#include <wtf/Uint8ClampedArray.h>
+#include "wtf/Uint8ClampedArray.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/FECustomFilter.h b/Source/core/platform/graphics/filters/custom/FECustomFilter.h
index 5f1fe54..e3d42b2 100644
--- a/Source/core/platform/graphics/filters/custom/FECustomFilter.h
+++ b/Source/core/platform/graphics/filters/custom/FECustomFilter.h
@@ -36,7 +36,7 @@
 #include "core/platform/graphics/filters/FilterEffect.h"
 #include "core/platform/graphics/filters/custom/CustomFilterConstants.h"
 #include "core/platform/graphics/filters/custom/CustomFilterOperation.h"
-#include <wtf/RefPtr.h>
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/filters/custom/ValidatedCustomFilterOperation.cpp b/Source/core/platform/graphics/filters/custom/ValidatedCustomFilterOperation.cpp
index dca2450..37cc3d1 100644
--- a/Source/core/platform/graphics/filters/custom/ValidatedCustomFilterOperation.cpp
+++ b/Source/core/platform/graphics/filters/custom/ValidatedCustomFilterOperation.cpp
@@ -34,7 +34,7 @@
 #include "core/platform/graphics/LayoutSize.h"
 #include "core/platform/graphics/filters/custom/CustomFilterParameter.h"
 #include "core/platform/graphics/filters/custom/CustomFilterValidatedProgram.h"
-#include <wtf/UnusedParam.h>
+#include "wtf/UnusedParam.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/gpu/DrawingBuffer.h b/Source/core/platform/graphics/gpu/DrawingBuffer.h
index 0cbb8a9..af55434 100644
--- a/Source/core/platform/graphics/gpu/DrawingBuffer.h
+++ b/Source/core/platform/graphics/gpu/DrawingBuffer.h
@@ -37,9 +37,9 @@
 
 #include "public/platform/WebExternalTextureLayerClient.h"
 #include "public/platform/WebExternalTextureMailbox.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
+#include "wtf/Noncopyable.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
 
 namespace WebKit {
 class WebExternalBitmap;
diff --git a/Source/core/platform/graphics/gpu/SharedGraphicsContext3D.cpp b/Source/core/platform/graphics/gpu/SharedGraphicsContext3D.cpp
index 258a45a..f8fe903 100644
--- a/Source/core/platform/graphics/gpu/SharedGraphicsContext3D.cpp
+++ b/Source/core/platform/graphics/gpu/SharedGraphicsContext3D.cpp
@@ -33,7 +33,7 @@
 #include "public/platform/Platform.h"
 #include "public/platform/WebGraphicsContext3D.h"
 #include "public/platform/WebGraphicsContext3DProvider.h"
-#include <wtf/MainThread.h>
+#include "wtf/MainThread.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/gpu/SharedGraphicsContext3D.h b/Source/core/platform/graphics/gpu/SharedGraphicsContext3D.h
index dd787a7..4525ee8 100644
--- a/Source/core/platform/graphics/gpu/SharedGraphicsContext3D.h
+++ b/Source/core/platform/graphics/gpu/SharedGraphicsContext3D.h
@@ -27,8 +27,8 @@
 #define SharedGraphicsContext3D_h
 
 #include "core/platform/graphics/GraphicsContext3D.h"
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/harfbuzz/FontHarfBuzz.cpp b/Source/core/platform/graphics/harfbuzz/FontHarfBuzz.cpp
index 61eceb9..534614f 100644
--- a/Source/core/platform/graphics/harfbuzz/FontHarfBuzz.cpp
+++ b/Source/core/platform/graphics/harfbuzz/FontHarfBuzz.cpp
@@ -41,7 +41,7 @@
 #include "SkPaint.h"
 #include "SkTemplates.h"
 
-#include <wtf/unicode/Unicode.h>
+#include "wtf/unicode/Unicode.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp b/Source/core/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp
index b7ad003..1c0af7d 100644
--- a/Source/core/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp
+++ b/Source/core/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp
@@ -41,8 +41,8 @@
 #include "public/platform/linux/WebFontRenderStyle.h"
 #include "public/platform/linux/WebSandboxSupport.h"
 #include "public/platform/Platform.h"
-#include <wtf/text/StringImpl.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/text/StringImpl.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/harfbuzz/HarfBuzzFace.h b/Source/core/platform/graphics/harfbuzz/HarfBuzzFace.h
index b3776dc..cf16c33 100644
--- a/Source/core/platform/graphics/harfbuzz/HarfBuzzFace.h
+++ b/Source/core/platform/graphics/harfbuzz/HarfBuzzFace.h
@@ -33,10 +33,10 @@
 
 #include <hb.h>
 
-#include <wtf/HashMap.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
+#include "wtf/HashMap.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/harfbuzz/HarfBuzzFaceSkia.cpp b/Source/core/platform/graphics/harfbuzz/HarfBuzzFaceSkia.cpp
index 1684573..f689991 100644
--- a/Source/core/platform/graphics/harfbuzz/HarfBuzzFaceSkia.cpp
+++ b/Source/core/platform/graphics/harfbuzz/HarfBuzzFaceSkia.cpp
@@ -43,7 +43,7 @@
 #include "core/platform/graphics/harfbuzz/HarfBuzzShaper.h"
 
 #include "hb.h"
-#include <wtf/HashMap.h>
+#include "wtf/HashMap.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/harfbuzz/HarfBuzzShaper.cpp b/Source/core/platform/graphics/harfbuzz/HarfBuzzShaper.cpp
index 6738b7f..0cbb258 100644
--- a/Source/core/platform/graphics/harfbuzz/HarfBuzzShaper.cpp
+++ b/Source/core/platform/graphics/harfbuzz/HarfBuzzShaper.cpp
@@ -38,9 +38,9 @@
 #include "core/platform/graphics/TextRun.h"
 #include "core/platform/graphics/harfbuzz/HarfBuzzFace.h"
 #include "hb-icu.h"
-#include <wtf/MathExtras.h>
-#include <wtf/unicode/Unicode.h>
-#include <wtf/Vector.h>
+#include "wtf/MathExtras.h"
+#include "wtf/unicode/Unicode.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/harfbuzz/HarfBuzzShaper.h b/Source/core/platform/graphics/harfbuzz/HarfBuzzShaper.h
index aeb47e3..2035779 100644
--- a/Source/core/platform/graphics/harfbuzz/HarfBuzzShaper.h
+++ b/Source/core/platform/graphics/harfbuzz/HarfBuzzShaper.h
@@ -35,12 +35,12 @@
 #include "core/platform/graphics/GlyphBuffer.h"
 #include "core/platform/graphics/TextRun.h"
 #include "hb.h"
-#include <wtf/HashSet.h>
-#include <wtf/OwnArrayPtr.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/unicode/CharacterNames.h>
-#include <wtf/Vector.h>
+#include "wtf/HashSet.h"
+#include "wtf/OwnArrayPtr.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/unicode/CharacterNames.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/mac/ComplexTextController.cpp b/Source/core/platform/graphics/mac/ComplexTextController.cpp
index 3072c08..e027ce6 100644
--- a/Source/core/platform/graphics/mac/ComplexTextController.cpp
+++ b/Source/core/platform/graphics/mac/ComplexTextController.cpp
@@ -32,8 +32,8 @@
 #include "core/platform/text/TextBreakIterator.h"
 #include "core/rendering/RenderBlock.h"
 #include "core/rendering/RenderText.h"
-#include <wtf/StdLibExtras.h>
-#include <wtf/unicode/CharacterNames.h>
+#include "wtf/StdLibExtras.h"
+#include "wtf/unicode/CharacterNames.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/graphics/mac/ComplexTextController.h b/Source/core/platform/graphics/mac/ComplexTextController.h
index 511e7fb..3693841 100644
--- a/Source/core/platform/graphics/mac/ComplexTextController.h
+++ b/Source/core/platform/graphics/mac/ComplexTextController.h
@@ -26,13 +26,13 @@
 #define ComplexTextController_h
 
 #include "core/platform/graphics/GlyphBuffer.h"
-#include <wtf/HashSet.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/unicode/Unicode.h>
-#include <wtf/Vector.h>
+#include "wtf/HashSet.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RetainPtr.h"
+#include "wtf/text/WTFString.h"
+#include "wtf/unicode/Unicode.h"
+#include "wtf/Vector.h"
 
 typedef unsigned short CGGlyph;
 
diff --git a/Source/core/platform/graphics/mac/FontComplexTextMac.cpp b/Source/core/platform/graphics/mac/FontComplexTextMac.cpp
index 56aaca6..0da9a0f 100644
--- a/Source/core/platform/graphics/mac/FontComplexTextMac.cpp
+++ b/Source/core/platform/graphics/mac/FontComplexTextMac.cpp
@@ -32,7 +32,7 @@
 #include "core/platform/graphics/SimpleFontData.h"
 #include "core/platform/graphics/TextRun.h"
 #include "core/platform/graphics/mac/ComplexTextController.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 #include "core/platform/graphics/harfbuzz/HarfBuzzShaper.h"
 
diff --git a/Source/core/platform/graphics/mac/FontCustomPlatformData.h b/Source/core/platform/graphics/mac/FontCustomPlatformData.h
index 5716c43..a1fe50f 100644
--- a/Source/core/platform/graphics/mac/FontCustomPlatformData.h
+++ b/Source/core/platform/graphics/mac/FontCustomPlatformData.h
@@ -24,8 +24,8 @@
 #include <CoreFoundation/CFBase.h>
 #include "core/platform/graphics/FontOrientation.h"
 #include "core/platform/graphics/FontWidthVariant.h"
-#include <wtf/Forward.h>
-#include <wtf/Noncopyable.h>
+#include "wtf/Forward.h"
+#include "wtf/Noncopyable.h"
 
 typedef struct CGFont* CGFontRef;
 typedef UInt32 ATSFontContainerRef;
diff --git a/Source/core/platform/graphics/opentype/OpenTypeSanitizer.cpp b/Source/core/platform/graphics/opentype/OpenTypeSanitizer.cpp
index 9415c88..20d4442 100644
--- a/Source/core/platform/graphics/opentype/OpenTypeSanitizer.cpp
+++ b/Source/core/platform/graphics/opentype/OpenTypeSanitizer.cpp
@@ -35,7 +35,7 @@
 #include "core/platform/SharedBuffer.h"
 #include "opentype-sanitiser.h"
 #include "ots-memory-stream.h"
-#include <wtf/OwnArrayPtr.h>
+#include "wtf/OwnArrayPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/opentype/OpenTypeSanitizer.h b/Source/core/platform/graphics/opentype/OpenTypeSanitizer.h
index 7d56997..90daf02 100644
--- a/Source/core/platform/graphics/opentype/OpenTypeSanitizer.h
+++ b/Source/core/platform/graphics/opentype/OpenTypeSanitizer.h
@@ -31,7 +31,7 @@
 #ifndef OpenTypeSanitizer_h
 #define OpenTypeSanitizer_h
 
-#include <wtf/Forward.h>
+#include "wtf/Forward.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/opentype/OpenTypeUtilities.h b/Source/core/platform/graphics/opentype/OpenTypeUtilities.h
index 5d63824..b725b78 100644
--- a/Source/core/platform/graphics/opentype/OpenTypeUtilities.h
+++ b/Source/core/platform/graphics/opentype/OpenTypeUtilities.h
@@ -28,8 +28,8 @@
 #define OpenTypeUtilities_h
 
 #include <windows.h>
-#include <wtf/Forward.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Forward.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/opentype/OpenTypeVerticalData.cpp b/Source/core/platform/graphics/opentype/OpenTypeVerticalData.cpp
index e005275..d60fbd7 100644
--- a/Source/core/platform/graphics/opentype/OpenTypeVerticalData.cpp
+++ b/Source/core/platform/graphics/opentype/OpenTypeVerticalData.cpp
@@ -31,7 +31,7 @@
 #include "core/platform/graphics/GlyphPage.h"
 #include "core/platform/graphics/SimpleFontData.h"
 #include "core/platform/graphics/opentype/OpenTypeTypes.h"
-#include <wtf/RefPtr.h>
+#include "wtf/RefPtr.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/graphics/opentype/OpenTypeVerticalData.h b/Source/core/platform/graphics/opentype/OpenTypeVerticalData.h
index 390242a..bad593e 100644
--- a/Source/core/platform/graphics/opentype/OpenTypeVerticalData.h
+++ b/Source/core/platform/graphics/opentype/OpenTypeVerticalData.h
@@ -28,10 +28,10 @@
 #if ENABLE(OPENTYPE_VERTICAL)
 
 #include "core/platform/graphics/Glyph.h"
-#include <wtf/HashMap.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
+#include "wtf/HashMap.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/skia/FontCacheSkia.cpp b/Source/core/platform/graphics/skia/FontCacheSkia.cpp
index 34e154f..0be6d56 100644
--- a/Source/core/platform/graphics/skia/FontCacheSkia.cpp
+++ b/Source/core/platform/graphics/skia/FontCacheSkia.cpp
@@ -36,9 +36,9 @@
 #include "core/platform/graphics/FontCache.h"
 #include "core/platform/graphics/FontDescription.h"
 #include "core/platform/graphics/SimpleFontData.h"
-#include <wtf/Assertions.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/CString.h>
+#include "wtf/Assertions.h"
+#include "wtf/text/AtomicString.h"
+#include "wtf/text/CString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/skia/FontCustomPlatformData.cpp b/Source/core/platform/graphics/skia/FontCustomPlatformData.cpp
index 325a80a..353a990 100644
--- a/Source/core/platform/graphics/skia/FontCustomPlatformData.cpp
+++ b/Source/core/platform/graphics/skia/FontCustomPlatformData.cpp
@@ -48,7 +48,7 @@
 
 #if OS(WINDOWS)
 #include <objbase.h>
-#include <wtf/text/Base64.h>
+#include "wtf/text/Base64.h"
 #endif
 
 namespace WebCore {
diff --git a/Source/core/platform/graphics/skia/FontCustomPlatformData.h b/Source/core/platform/graphics/skia/FontCustomPlatformData.h
index 7c2d298..4791d04 100644
--- a/Source/core/platform/graphics/skia/FontCustomPlatformData.h
+++ b/Source/core/platform/graphics/skia/FontCustomPlatformData.h
@@ -34,12 +34,12 @@
 
 #include "core/platform/graphics/FontOrientation.h"
 #include "core/platform/graphics/FontWidthVariant.h"
-#include <wtf/Forward.h>
-#include <wtf/Noncopyable.h>
+#include "wtf/Forward.h"
+#include "wtf/Noncopyable.h"
 
 #if OS(WINDOWS)
 #include <windows.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 #elif OS(UNIX)
 #include "SkTypeface.h"
 #endif
diff --git a/Source/core/platform/graphics/skia/ImageSkia.cpp b/Source/core/platform/graphics/skia/ImageSkia.cpp
index 8f25fa2..ebbe966 100644
--- a/Source/core/platform/graphics/skia/ImageSkia.cpp
+++ b/Source/core/platform/graphics/skia/ImageSkia.cpp
@@ -42,7 +42,7 @@
 #include "core/platform/graphics/skia/NativeImageSkia.h"
 #include "core/platform/graphics/skia/SkiaUtils.h"
 #include "core/platform/graphics/transforms/AffineTransform.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 #include <math.h>
 #include <limits>
@@ -326,7 +326,7 @@
     bool useBicubicFilter = resampling == RESAMPLE_AWESOME
         && DeferredImageDecoder::isLazyDecoded(bitmap.bitmap());
     if (useBicubicFilter)
-        paint.setFlags(paint.getFlags() | SkPaint::kBicubicFilterBitmap_Flag | SkPaint::kFilterBitmap_Flag);
+        paint.setFilterLevel(SkPaint::kHigh_FilterLevel);
 
     if (resampling == RESAMPLE_AWESOME && !useBicubicFilter) {
         // Resample the image and then draw the result to canvas with bilinear
@@ -450,7 +450,7 @@
 
     paint.setFilterBitmap(resampling == RESAMPLE_LINEAR);
     if (useBicubicFilter)
-        paint.setFlags(paint.getFlags() | SkPaint::kBicubicFilterBitmap_Flag);
+        paint.setFilterLevel(SkPaint::kHigh_FilterLevel);
 
     context->drawRect(destRect, paint);
 }
diff --git a/Source/core/platform/graphics/skia/NativeImageSkia.h b/Source/core/platform/graphics/skia/NativeImageSkia.h
index 756fce8..518b5f8 100644
--- a/Source/core/platform/graphics/skia/NativeImageSkia.h
+++ b/Source/core/platform/graphics/skia/NativeImageSkia.h
@@ -34,9 +34,9 @@
 #include "SkBitmap.h"
 #include "SkRect.h"
 #include "SkSize.h"
-#include <wtf/Forward.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
+#include "wtf/Forward.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/skia/SimpleFontDataSkia.cpp b/Source/core/platform/graphics/skia/SimpleFontDataSkia.cpp
index 81db97f..f92d81f 100644
--- a/Source/core/platform/graphics/skia/SimpleFontDataSkia.cpp
+++ b/Source/core/platform/graphics/skia/SimpleFontDataSkia.cpp
@@ -38,7 +38,7 @@
 #include "core/platform/graphics/FloatRect.h"
 #include "core/platform/graphics/FontDescription.h"
 #include "core/platform/graphics/chromium/VDMXParser.h"
-#include <wtf/unicode/Unicode.h>
+#include "wtf/unicode/Unicode.h"
 
 #if OS(WINDOWS)
 #include "core/platform/win/HWndDC.h"
diff --git a/Source/core/platform/graphics/skia/SkiaFontWin.cpp b/Source/core/platform/graphics/skia/SkiaFontWin.cpp
index d3511bf..5aca837 100644
--- a/Source/core/platform/graphics/skia/SkiaFontWin.cpp
+++ b/Source/core/platform/graphics/skia/SkiaFontWin.cpp
@@ -37,12 +37,12 @@
 #include "core/platform/graphics/SimpleFontData.h"
 #include "core/platform/graphics/chromium/FontPlatformDataChromiumWin.h"
 #include "core/platform/graphics/transforms/AffineTransform.h"
-
 #include "third_party/skia/include/core/SkCanvas.h"
 #include "third_party/skia/include/core/SkDevice.h"
 #include "third_party/skia/include/core/SkPaint.h"
 #include "third_party/skia/include/core/SkShader.h"
 #include "third_party/skia/include/core/SkTemplates.h"
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
@@ -193,10 +193,8 @@
 {
     int size;
     int paintTextFlags;
-    SkTypeface* face = CreateTypefaceFromHFont(hfont, &size, &paintTextFlags);
-    SkAutoUnref aur(face);
-
-    paintSkiaText(context, hfont, face, size, paintTextFlags, numGlyphs, glyphs, advances, offsets, origin, textRect);
+    RefPtr<SkTypeface> face = CreateTypefaceFromHFont(hfont, &size, &paintTextFlags);
+    paintSkiaText(context, hfont, face.get(), size, paintTextFlags, numGlyphs, glyphs, advances, offsets, origin, textRect);
 }
 
 }  // namespace WebCore
diff --git a/Source/core/platform/graphics/skia/SkiaUtils.h b/Source/core/platform/graphics/skia/SkiaUtils.h
index 3fa2264..757f4e2 100644
--- a/Source/core/platform/graphics/skia/SkiaUtils.h
+++ b/Source/core/platform/graphics/skia/SkiaUtils.h
@@ -36,7 +36,7 @@
 #include "SkPath.h"
 #include "SkXfermode.h"
 #include "core/platform/graphics/GraphicsContext.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 class SkCanvas;
 class SkRegion;
diff --git a/Source/core/platform/graphics/transforms/AffineTransform.cpp b/Source/core/platform/graphics/transforms/AffineTransform.cpp
index e1e8025..8b36b5d 100644
--- a/Source/core/platform/graphics/transforms/AffineTransform.cpp
+++ b/Source/core/platform/graphics/transforms/AffineTransform.cpp
@@ -34,7 +34,7 @@
 #include "core/platform/graphics/IntRect.h"
 #include "core/platform/graphics/skia/SkiaUtils.h"
 
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/transforms/AffineTransform.h b/Source/core/platform/graphics/transforms/AffineTransform.h
index 74d5702..dbddc5b 100644
--- a/Source/core/platform/graphics/transforms/AffineTransform.h
+++ b/Source/core/platform/graphics/transforms/AffineTransform.h
@@ -30,7 +30,7 @@
 #include "core/platform/graphics/transforms/TransformationMatrix.h"
 
 #include <string.h> // for memcpy
-#include <wtf/FastAllocBase.h>
+#include "wtf/FastAllocBase.h"
 
 #include <SkMatrix.h>
 
diff --git a/Source/core/platform/graphics/transforms/PerspectiveTransformOperation.cpp b/Source/core/platform/graphics/transforms/PerspectiveTransformOperation.cpp
index 2dd160e..07dbb1f 100644
--- a/Source/core/platform/graphics/transforms/PerspectiveTransformOperation.cpp
+++ b/Source/core/platform/graphics/transforms/PerspectiveTransformOperation.cpp
@@ -27,7 +27,7 @@
 #include "core/platform/graphics/transforms/PerspectiveTransformOperation.h"
 
 #include "core/platform/animation/AnimationUtilities.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/graphics/transforms/RotateTransformOperation.cpp b/Source/core/platform/graphics/transforms/RotateTransformOperation.cpp
index 97628fb..ba1ce1f 100644
--- a/Source/core/platform/graphics/transforms/RotateTransformOperation.cpp
+++ b/Source/core/platform/graphics/transforms/RotateTransformOperation.cpp
@@ -24,7 +24,7 @@
 
 #include <algorithm>
 #include "core/platform/animation/AnimationUtilities.h"
-#include <wtf/MathExtras.h>
+#include "wtf/MathExtras.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/graphics/transforms/TransformOperation.h b/Source/core/platform/graphics/transforms/TransformOperation.h
index 972d278..7a4c952 100644
--- a/Source/core/platform/graphics/transforms/TransformOperation.h
+++ b/Source/core/platform/graphics/transforms/TransformOperation.h
@@ -27,8 +27,8 @@
 
 #include "core/platform/graphics/FloatSize.h"
 #include "core/platform/graphics/transforms/TransformationMatrix.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/transforms/TransformOperations.h b/Source/core/platform/graphics/transforms/TransformOperations.h
index 991b729..39024bc 100644
--- a/Source/core/platform/graphics/transforms/TransformOperations.h
+++ b/Source/core/platform/graphics/transforms/TransformOperations.h
@@ -27,8 +27,8 @@
 
 #include "core/platform/graphics/LayoutSize.h"
 #include "core/platform/graphics/transforms/TransformOperation.h"
-#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/transforms/TransformState.cpp b/Source/core/platform/graphics/transforms/TransformState.cpp
index 760f6da..51db25d 100644
--- a/Source/core/platform/graphics/transforms/TransformState.cpp
+++ b/Source/core/platform/graphics/transforms/TransformState.cpp
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "core/platform/graphics/transforms/TransformState.h"
 
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/transforms/TransformState.h b/Source/core/platform/graphics/transforms/TransformState.h
index 51b8960..5020213 100644
--- a/Source/core/platform/graphics/transforms/TransformState.h
+++ b/Source/core/platform/graphics/transforms/TransformState.h
@@ -32,7 +32,7 @@
 #include "core/platform/graphics/LayoutSize.h"
 #include "core/platform/graphics/transforms/AffineTransform.h"
 #include "core/platform/graphics/transforms/TransformationMatrix.h"
-#include <wtf/OwnPtr.h>
+#include "wtf/OwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/graphics/transforms/TransformationMatrix.cpp b/Source/core/platform/graphics/transforms/TransformationMatrix.cpp
index 4ba5022..1f81208 100644
--- a/Source/core/platform/graphics/transforms/TransformationMatrix.cpp
+++ b/Source/core/platform/graphics/transforms/TransformationMatrix.cpp
@@ -35,8 +35,8 @@
 #include "core/platform/graphics/skia/SkiaUtils.h"
 #include "core/platform/graphics/transforms/AffineTransform.h"
 
-#include <wtf/Assertions.h>
-#include <wtf/MathExtras.h>
+#include "wtf/Assertions.h"
+#include "wtf/MathExtras.h"
 
 #if CPU(X86_64)
 #include <emmintrin.h>
diff --git a/Source/core/platform/image-decoders/ImageDecoder.h b/Source/core/platform/image-decoders/ImageDecoder.h
index 3249e5e..3c4cc2d 100644
--- a/Source/core/platform/image-decoders/ImageDecoder.h
+++ b/Source/core/platform/image-decoders/ImageDecoder.h
@@ -33,17 +33,17 @@
 #include "core/platform/graphics/ImageSource.h"
 #include "core/platform/graphics/IntRect.h"
 #include "core/platform/graphics/skia/NativeImageSkia.h"
-#include <wtf/Assertions.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "wtf/Assertions.h"
+#include "wtf/RefPtr.h"
+#include "wtf/text/WTFString.h"
+#include "wtf/Vector.h"
 
 #if USE(QCMSLIB)
 #include "qcms.h"
 #if OS(DARWIN)
 #include <ApplicationServices/ApplicationServices.h>
 #include "core/platform/graphics/cg/GraphicsContextCG.h"
-#include <wtf/RetainPtr.h>
+#include "wtf/RetainPtr.h"
 #endif
 #endif
 
diff --git a/Source/core/platform/image-decoders/bmp/BMPImageDecoder.cpp b/Source/core/platform/image-decoders/bmp/BMPImageDecoder.cpp
index 3d8ed0c..40a188c 100644
--- a/Source/core/platform/image-decoders/bmp/BMPImageDecoder.cpp
+++ b/Source/core/platform/image-decoders/bmp/BMPImageDecoder.cpp
@@ -33,7 +33,7 @@
 
 #include "core/platform/PlatformInstrumentation.h"
 #include "core/platform/image-decoders/bmp/BMPImageReader.h"
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/image-decoders/bmp/BMPImageDecoder.h b/Source/core/platform/image-decoders/bmp/BMPImageDecoder.h
index 294d87f..4cf7b4d 100644
--- a/Source/core/platform/image-decoders/bmp/BMPImageDecoder.h
+++ b/Source/core/platform/image-decoders/bmp/BMPImageDecoder.h
@@ -32,7 +32,7 @@
 #define BMPImageDecoder_h
 
 #include "core/platform/image-decoders/bmp/BMPImageReader.h"
-#include <wtf/OwnPtr.h>
+#include "wtf/OwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/image-decoders/gif/GIFImageDecoderTest.cpp b/Source/core/platform/image-decoders/gif/GIFImageDecoderTest.cpp
index 3be491e..ad04dfa 100644
--- a/Source/core/platform/image-decoders/gif/GIFImageDecoderTest.cpp
+++ b/Source/core/platform/image-decoders/gif/GIFImageDecoderTest.cpp
@@ -252,7 +252,7 @@
 {
     OwnPtr<GIFImageDecoder> decoder = createDecoder();
 
-    RefPtr<SharedBuffer> data = readFile("/Source/WebKit/chromium/tests/data/broken.gif");
+    RefPtr<SharedBuffer> data = readFile("/Source/web/tests/data/broken.gif");
     ASSERT_TRUE(data.get());
     decoder->setData(data.get(), true);
 
@@ -264,7 +264,7 @@
 
 TEST(GIFImageDecoderTest, progressiveDecode)
 {
-    RefPtr<SharedBuffer> fullData = readFile("/Source/WebKit/chromium/tests/data/radient.gif");
+    RefPtr<SharedBuffer> fullData = readFile("/Source/web/tests/data/radient.gif");
     ASSERT_TRUE(fullData.get());
     const size_t fullLength = fullData->size();
 
@@ -369,8 +369,8 @@
 
 TEST(GIFImageDecoderTest, badTerminator)
 {
-    RefPtr<SharedBuffer> referenceData = readFile("/Source/WebKit/chromium/tests/data/radient.gif");
-    RefPtr<SharedBuffer> testData = readFile("/Source/WebKit/chromium/tests/data/radient-bad-terminator.gif");
+    RefPtr<SharedBuffer> referenceData = readFile("/Source/web/tests/data/radient.gif");
+    RefPtr<SharedBuffer> testData = readFile("/Source/web/tests/data/radient-bad-terminator.gif");
     ASSERT_TRUE(referenceData.get());
     ASSERT_TRUE(testData.get());
 
@@ -418,7 +418,7 @@
 TEST(GIFImageDecoderTest, randomFrameDecode)
 {
     // Single frame image.
-    testRandomFrameDecode("/Source/WebKit/chromium/tests/data/radient.gif");
+    testRandomFrameDecode("/Source/web/tests/data/radient.gif");
     // Multiple frame images.
     testRandomFrameDecode("/LayoutTests/fast/images/resources/animated-gif-with-offsets.gif");
     testRandomFrameDecode("/LayoutTests/fast/images/resources/animated-10color.gif");
@@ -427,7 +427,7 @@
 TEST(GIFImageDecoderTest, randomDecodeAfterClearFrameBufferCache)
 {
     // Single frame image.
-    testRandomDecodeAfterClearFrameBufferCache("/Source/WebKit/chromium/tests/data/radient.gif");
+    testRandomDecodeAfterClearFrameBufferCache("/Source/web/tests/data/radient.gif");
     // Multiple frame images.
     testRandomDecodeAfterClearFrameBufferCache("/LayoutTests/fast/images/resources/animated-gif-with-offsets.gif");
     testRandomDecodeAfterClearFrameBufferCache("/LayoutTests/fast/images/resources/animated-10color.gif");
diff --git a/Source/core/platform/image-decoders/gif/GIFImageReader.h b/Source/core/platform/image-decoders/gif/GIFImageReader.h
index e5b9d7a..c66d017 100644
--- a/Source/core/platform/image-decoders/gif/GIFImageReader.h
+++ b/Source/core/platform/image-decoders/gif/GIFImageReader.h
@@ -42,9 +42,9 @@
 // so we will too.
 #include "core/platform/SharedBuffer.h"
 #include "core/platform/image-decoders/gif/GIFImageDecoder.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Vector.h"
 
 #define MAX_LZW_BITS          12
 #define MAX_BYTES           4097 /* 2^MAX_LZW_BITS+1 */
diff --git a/Source/core/platform/image-decoders/ico/ICOImageDecoder.cpp b/Source/core/platform/image-decoders/ico/ICOImageDecoder.cpp
index ded772c..bdc1b4f 100644
--- a/Source/core/platform/image-decoders/ico/ICOImageDecoder.cpp
+++ b/Source/core/platform/image-decoders/ico/ICOImageDecoder.cpp
@@ -36,7 +36,7 @@
 #include "core/platform/PlatformInstrumentation.h"
 #include "core/platform/image-decoders/bmp/BMPImageReader.h"
 #include "core/platform/image-decoders/png/PNGImageDecoder.h"
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/image-decoders/png/PNGImageDecoder.h b/Source/core/platform/image-decoders/png/PNGImageDecoder.h
index 78e6a5d..be40d95 100644
--- a/Source/core/platform/image-decoders/png/PNGImageDecoder.h
+++ b/Source/core/platform/image-decoders/png/PNGImageDecoder.h
@@ -27,7 +27,7 @@
 #define PNGImageDecoder_h
 
 #include "core/platform/image-decoders/ImageDecoder.h"
-#include <wtf/OwnPtr.h>
+#include "wtf/OwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/image-encoders/skia/JPEGImageEncoder.h b/Source/core/platform/image-encoders/skia/JPEGImageEncoder.h
index 122725d..f8013ee 100644
--- a/Source/core/platform/image-encoders/skia/JPEGImageEncoder.h
+++ b/Source/core/platform/image-encoders/skia/JPEGImageEncoder.h
@@ -31,7 +31,7 @@
 #ifndef JPEGImageEncoder_h
 #define JPEGImageEncoder_h
 
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 class SkBitmap;
 
diff --git a/Source/core/platform/image-encoders/skia/PNGImageEncoder.h b/Source/core/platform/image-encoders/skia/PNGImageEncoder.h
index 31edad3..83c9e6c 100644
--- a/Source/core/platform/image-encoders/skia/PNGImageEncoder.h
+++ b/Source/core/platform/image-encoders/skia/PNGImageEncoder.h
@@ -31,7 +31,7 @@
 #ifndef PNGImageEncoder_h
 #define PNGImageEncoder_h
 
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 class SkBitmap;
 
diff --git a/Source/core/platform/image-encoders/skia/WEBPImageEncoder.h b/Source/core/platform/image-encoders/skia/WEBPImageEncoder.h
index fbe1b28..e04c702 100644
--- a/Source/core/platform/image-encoders/skia/WEBPImageEncoder.h
+++ b/Source/core/platform/image-encoders/skia/WEBPImageEncoder.h
@@ -31,7 +31,7 @@
 #ifndef WEBPImageEncoder_h
 #define WEBPImageEncoder_h
 
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 class SkBitmap;
 
diff --git a/Source/core/platform/mac/LocalCurrentGraphicsContext.h b/Source/core/platform/mac/LocalCurrentGraphicsContext.h
index c4aa3f4..14ca45d 100644
--- a/Source/core/platform/mac/LocalCurrentGraphicsContext.h
+++ b/Source/core/platform/mac/LocalCurrentGraphicsContext.h
@@ -18,7 +18,7 @@
  */
 
 #include "core/platform/graphics/GraphicsContext.h"
-#include <wtf/Noncopyable.h>
+#include "wtf/Noncopyable.h"
 
 #include "skia/ext/skia_utils_mac.h"
 
diff --git a/Source/core/platform/mac/ScrollAnimatorMac.h b/Source/core/platform/mac/ScrollAnimatorMac.h
index 7df165f..c557196 100644
--- a/Source/core/platform/mac/ScrollAnimatorMac.h
+++ b/Source/core/platform/mac/ScrollAnimatorMac.h
@@ -32,7 +32,7 @@
 #include "core/platform/graphics/FloatSize.h"
 #include "core/platform/graphics/IntRect.h"
 #include "core/platform/mac/ScrollElasticityController.h"
-#include <wtf/RetainPtr.h>
+#include "wtf/RetainPtr.h"
 
 OBJC_CLASS WebScrollAnimationHelperDelegate;
 OBJC_CLASS WebScrollbarPainterControllerDelegate;
diff --git a/Source/core/platform/mac/ScrollAnimatorMac.mm b/Source/core/platform/mac/ScrollAnimatorMac.mm
index 00135e6..89d55f2 100644
--- a/Source/core/platform/mac/ScrollAnimatorMac.mm
+++ b/Source/core/platform/mac/ScrollAnimatorMac.mm
@@ -37,9 +37,9 @@
 #include "core/platform/mac/EmptyProtocolDefinitions.h"
 #include "core/platform/mac/NSScrollerImpDetails.h"
 #include "core/platform/mac/ScrollbarThemeMac.h"
-#include <wtf/MainThread.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/UnusedParam.h>
+#include "wtf/MainThread.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/UnusedParam.h"
 
 using namespace WebCore;
 using namespace std;
diff --git a/Source/core/platform/mac/ScrollElasticityController.h b/Source/core/platform/mac/ScrollElasticityController.h
index 1010799..70bb62a 100644
--- a/Source/core/platform/mac/ScrollElasticityController.h
+++ b/Source/core/platform/mac/ScrollElasticityController.h
@@ -31,7 +31,7 @@
 #include "core/platform/ScrollTypes.h"
 #include "core/platform/graphics/FloatPoint.h"
 #include "core/platform/graphics/FloatSize.h"
-#include <wtf/Noncopyable.h>
+#include "wtf/Noncopyable.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/mac/ScrollbarThemeMac.mm b/Source/core/platform/mac/ScrollbarThemeMac.mm
index 2463bfc..3461647 100644
--- a/Source/core/platform/mac/ScrollbarThemeMac.mm
+++ b/Source/core/platform/mac/ScrollbarThemeMac.mm
@@ -35,10 +35,10 @@
 #include "core/platform/mac/LocalCurrentGraphicsContext.h"
 #include "core/platform/mac/NSScrollerImpDetails.h"
 #include "core/platform/mac/ScrollAnimatorMac.h"
-#include <wtf/HashMap.h>
-#include <wtf/StdLibExtras.h>
-#include <wtf/TemporaryChange.h>
-#include <wtf/UnusedParam.h>
+#include "wtf/HashMap.h"
+#include "wtf/StdLibExtras.h"
+#include "wtf/TemporaryChange.h"
+#include "wtf/UnusedParam.h"
 
 // FIXME: There are repainting problems due to Aqua scroll bar buttons' visual overflow.
 
diff --git a/Source/core/platform/mac/ThemeMac.mm b/Source/core/platform/mac/ThemeMac.mm
index d77957e..152e4e6 100644
--- a/Source/core/platform/mac/ThemeMac.mm
+++ b/Source/core/platform/mac/ThemeMac.mm
@@ -32,7 +32,7 @@
 #import "core/platform/mac/BlockExceptions.h"
 #import "core/platform/mac/LocalCurrentGraphicsContext.h"
 #import "core/platform/mac/WebCoreNSCellExtras.h"
-#include <wtf/StdLibExtras.h>
+#include "wtf/StdLibExtras.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/mediastream/MediaConstraints.h b/Source/core/platform/mediastream/MediaConstraints.h
index 0676c52..cb4d264 100644
--- a/Source/core/platform/mediastream/MediaConstraints.h
+++ b/Source/core/platform/mediastream/MediaConstraints.h
@@ -31,8 +31,8 @@
 #ifndef MediaConstraints_h
 #define MediaConstraints_h
 
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/mediastream/MediaStreamComponent.h b/Source/core/platform/mediastream/MediaStreamComponent.h
index 24cd068..6a47c54 100644
--- a/Source/core/platform/mediastream/MediaStreamComponent.h
+++ b/Source/core/platform/mediastream/MediaStreamComponent.h
@@ -32,9 +32,9 @@
 #ifndef MediaStreamComponent_h
 #define MediaStreamComponent_h
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/mediastream/MediaStreamDescriptor.cpp b/Source/core/platform/mediastream/MediaStreamDescriptor.cpp
index 8d1d7b3..6d01fb2 100644
--- a/Source/core/platform/mediastream/MediaStreamDescriptor.cpp
+++ b/Source/core/platform/mediastream/MediaStreamDescriptor.cpp
@@ -36,8 +36,8 @@
 #include "core/platform/UUID.h"
 #include "core/platform/mediastream/MediaStreamComponent.h"
 #include "core/platform/mediastream/MediaStreamSource.h"
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/mediastream/MediaStreamDescriptor.h b/Source/core/platform/mediastream/MediaStreamDescriptor.h
index 1e254bf..0da128e 100644
--- a/Source/core/platform/mediastream/MediaStreamDescriptor.h
+++ b/Source/core/platform/mediastream/MediaStreamDescriptor.h
@@ -34,8 +34,8 @@
 
 #include "core/platform/mediastream/MediaStreamComponent.h"
 #include "core/platform/mediastream/MediaStreamSource.h"
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/mediastream/MediaStreamSource.cpp b/Source/core/platform/mediastream/MediaStreamSource.cpp
index b34e005..ffc3d9e 100644
--- a/Source/core/platform/mediastream/MediaStreamSource.cpp
+++ b/Source/core/platform/mediastream/MediaStreamSource.cpp
@@ -31,7 +31,7 @@
 #include "config.h"
 
 #include "core/platform/mediastream/MediaStreamSource.h"
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/mediastream/RTCPeerConnectionHandlerClient.h b/Source/core/platform/mediastream/RTCPeerConnectionHandlerClient.h
index 03b2ea6..e78e44c 100644
--- a/Source/core/platform/mediastream/RTCPeerConnectionHandlerClient.h
+++ b/Source/core/platform/mediastream/RTCPeerConnectionHandlerClient.h
@@ -31,7 +31,7 @@
 #ifndef RTCPeerConnectionHandlerClient_h
 #define RTCPeerConnectionHandlerClient_h
 
-#include <wtf/PassRefPtr.h>
+#include "wtf/PassRefPtr.h"
 
 namespace WebKit {
 class WebRTCICECandidate;
diff --git a/Source/core/platform/mediastream/RTCSessionDescriptionRequest.h b/Source/core/platform/mediastream/RTCSessionDescriptionRequest.h
index 506f860..0c7b7be 100644
--- a/Source/core/platform/mediastream/RTCSessionDescriptionRequest.h
+++ b/Source/core/platform/mediastream/RTCSessionDescriptionRequest.h
@@ -31,10 +31,10 @@
 #ifndef RTCSessionDescriptionRequest_h
 #define RTCSessionDescriptionRequest_h
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebKit {
 class WebRTCSessionDescription;
diff --git a/Source/core/platform/mediastream/RTCStatsRequest.h b/Source/core/platform/mediastream/RTCStatsRequest.h
index c727f54..5f93fe0 100644
--- a/Source/core/platform/mediastream/RTCStatsRequest.h
+++ b/Source/core/platform/mediastream/RTCStatsRequest.h
@@ -31,9 +31,9 @@
 #ifndef RTCStatsRequest_h
 #define RTCStatsRequest_h
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/mediastream/RTCStatsResponseBase.h b/Source/core/platform/mediastream/RTCStatsResponseBase.h
index cad8e90..dee70fb 100644
--- a/Source/core/platform/mediastream/RTCStatsResponseBase.h
+++ b/Source/core/platform/mediastream/RTCStatsResponseBase.h
@@ -25,9 +25,9 @@
 #ifndef RTCStatsResponseBase_h
 #define RTCStatsResponseBase_h
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/mediastream/RTCVoidRequest.h b/Source/core/platform/mediastream/RTCVoidRequest.h
index a34e30e..fe3b451 100644
--- a/Source/core/platform/mediastream/RTCVoidRequest.h
+++ b/Source/core/platform/mediastream/RTCVoidRequest.h
@@ -31,10 +31,10 @@
 #ifndef RTCVoidRequest_h
 #define RTCVoidRequest_h
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/mock/DeviceOrientationClientMock.h b/Source/core/platform/mock/DeviceOrientationClientMock.h
index 3320bdc..e532f17 100644
--- a/Source/core/platform/mock/DeviceOrientationClientMock.h
+++ b/Source/core/platform/mock/DeviceOrientationClientMock.h
@@ -27,11 +27,11 @@
 #define DeviceOrientationClientMock_h
 
 #include "core/dom/DeviceOrientationClient.h"
-#include "core/dom/DeviceOrientationData.h"
 #include "core/platform/Timer.h"
+#include "modules/device_orientation/DeviceOrientationData.h"
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/mock/GeolocationClientMock.h b/Source/core/platform/mock/GeolocationClientMock.h
index de35879..cfe9941 100644
--- a/Source/core/platform/mock/GeolocationClientMock.h
+++ b/Source/core/platform/mock/GeolocationClientMock.h
@@ -34,10 +34,10 @@
 
 #include "core/platform/Timer.h"
 #include "modules/geolocation/GeolocationClient.h"
-#include <wtf/HashSet.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/HashSet.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/mock/PlatformSpeechSynthesizerMock.h b/Source/core/platform/mock/PlatformSpeechSynthesizerMock.h
index f8c3435..0711653 100644
--- a/Source/core/platform/mock/PlatformSpeechSynthesizerMock.h
+++ b/Source/core/platform/mock/PlatformSpeechSynthesizerMock.h
@@ -28,7 +28,7 @@
 
 #include "core/platform/PlatformSpeechSynthesizer.h"
 #include "core/platform/Timer.h"
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
     
diff --git a/Source/core/platform/network/DNS.h b/Source/core/platform/network/DNS.h
index 90d832e..7d05e5c 100644
--- a/Source/core/platform/network/DNS.h
+++ b/Source/core/platform/network/DNS.h
@@ -27,7 +27,7 @@
 #ifndef DNS_h
 #define DNS_h
 
-#include <wtf/Forward.h>
+#include "wtf/Forward.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/FormDataBuilder.h b/Source/core/platform/network/FormDataBuilder.h
index ceecadf..ef9786e 100644
--- a/Source/core/platform/network/FormDataBuilder.h
+++ b/Source/core/platform/network/FormDataBuilder.h
@@ -22,7 +22,7 @@
 #define FormDataBuilder_h
 
 #include "core/platform/network/FormData.h"
-#include <wtf/Forward.h>
+#include "wtf/Forward.h"
 
 namespace WTF{
 class TextEncoding;
diff --git a/Source/core/platform/network/HTTPHeaderMap.h b/Source/core/platform/network/HTTPHeaderMap.h
index 677013e..6abb6e3 100644
--- a/Source/core/platform/network/HTTPHeaderMap.h
+++ b/Source/core/platform/network/HTTPHeaderMap.h
@@ -28,12 +28,12 @@
 #define HTTPHeaderMap_h
 
 #include <utility>
-#include <wtf/HashMap.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/Vector.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/AtomicStringHash.h>
-#include <wtf/text/StringHash.h>
+#include "wtf/HashMap.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Vector.h"
+#include "wtf/text/AtomicString.h"
+#include "wtf/text/AtomicStringHash.h"
+#include "wtf/text/StringHash.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/HTTPParsers.cpp b/Source/core/platform/network/HTTPParsers.cpp
index d78da99..5a6c653 100644
--- a/Source/core/platform/network/HTTPParsers.cpp
+++ b/Source/core/platform/network/HTTPParsers.cpp
@@ -34,11 +34,11 @@
 #include "core/platform/network/HTTPParsers.h"
 
 #include "core/page/ContentSecurityPolicy.h"
-#include <wtf/DateMath.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/unicode/CharacterNames.h>
+#include "wtf/DateMath.h"
+#include "wtf/text/CString.h"
+#include "wtf/text/StringBuilder.h"
+#include "wtf/text/WTFString.h"
+#include "wtf/unicode/CharacterNames.h"
 
 using namespace WTF;
 
diff --git a/Source/core/platform/network/HTTPParsers.h b/Source/core/platform/network/HTTPParsers.h
index 2774612..37ecd3e 100644
--- a/Source/core/platform/network/HTTPParsers.h
+++ b/Source/core/platform/network/HTTPParsers.h
@@ -32,8 +32,8 @@
 #define HTTPParsers_h
 
 #include "core/page/ContentSecurityPolicy.h"
-#include <wtf/Forward.h>
-#include <wtf/Vector.h>
+#include "wtf/Forward.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/HTTPRequest.cpp b/Source/core/platform/network/HTTPRequest.cpp
index 652d7b9..a61fa89 100644
--- a/Source/core/platform/network/HTTPRequest.cpp
+++ b/Source/core/platform/network/HTTPRequest.cpp
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "core/platform/network/HTTPRequest.h"
 
-#include <wtf/text/CString.h>
+#include "wtf/text/CString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/MIMEHeader.cpp b/Source/core/platform/network/MIMEHeader.cpp
index d674513..2c40a9b 100644
--- a/Source/core/platform/network/MIMEHeader.cpp
+++ b/Source/core/platform/network/MIMEHeader.cpp
@@ -33,11 +33,11 @@
 
 #include "core/platform/SharedBufferChunkReader.h"
 #include "core/platform/network/ParsedContentType.h"
-#include <wtf/HashMap.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/StringConcatenate.h>
-#include <wtf/text/StringHash.h>
+#include "wtf/HashMap.h"
+#include "wtf/text/CString.h"
+#include "wtf/text/StringBuilder.h"
+#include "wtf/text/StringConcatenate.h"
+#include "wtf/text/StringHash.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/MIMEHeader.h b/Source/core/platform/network/MIMEHeader.h
index d22d551..ffcd492 100644
--- a/Source/core/platform/network/MIMEHeader.h
+++ b/Source/core/platform/network/MIMEHeader.h
@@ -31,10 +31,10 @@
 #ifndef MIMEHeader_h
 #define MIMEHeader_h
 
-#include <wtf/HashMap.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/HashMap.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/NetworkStateNotifier.cpp b/Source/core/platform/network/NetworkStateNotifier.cpp
index c516da8..94cb9d0 100644
--- a/Source/core/platform/network/NetworkStateNotifier.cpp
+++ b/Source/core/platform/network/NetworkStateNotifier.cpp
@@ -26,9 +26,9 @@
 #include "config.h"
 #include "core/platform/network/NetworkStateNotifier.h"
 
-#include <wtf/Assertions.h>
-#include <wtf/StdLibExtras.h>
-#include <wtf/Threading.h>
+#include "wtf/Assertions.h"
+#include "wtf/StdLibExtras.h"
+#include "wtf/Threading.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/NetworkStateNotifier.h b/Source/core/platform/network/NetworkStateNotifier.h
index 0b147c2..f3e30ea 100644
--- a/Source/core/platform/network/NetworkStateNotifier.h
+++ b/Source/core/platform/network/NetworkStateNotifier.h
@@ -26,8 +26,8 @@
 #ifndef NetworkStateNotifier_h
 #define NetworkStateNotifier_h
 
-#include <wtf/FastAllocBase.h>
-#include <wtf/Noncopyable.h>
+#include "wtf/FastAllocBase.h"
+#include "wtf/Noncopyable.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/ParsedContentType.cpp b/Source/core/platform/network/ParsedContentType.cpp
index 00ebde8..d8db86a 100644
--- a/Source/core/platform/network/ParsedContentType.cpp
+++ b/Source/core/platform/network/ParsedContentType.cpp
@@ -32,8 +32,8 @@
 #include "config.h"
 #include "core/platform/network/ParsedContentType.h"
 
-#include <wtf/text/CString.h>
-#include <wtf/text/StringBuilder.h>
+#include "wtf/text/CString.h"
+#include "wtf/text/StringBuilder.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/ParsedContentType.h b/Source/core/platform/network/ParsedContentType.h
index 684c6c5..c463c19 100644
--- a/Source/core/platform/network/ParsedContentType.h
+++ b/Source/core/platform/network/ParsedContentType.h
@@ -32,8 +32,8 @@
 #ifndef ParsedContentType_h
 #define ParsedContentType_h
 
-#include <wtf/HashMap.h>
-#include <wtf/text/StringHash.h>
+#include "wtf/HashMap.h"
+#include "wtf/text/StringHash.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/ProxyServer.cpp b/Source/core/platform/network/ProxyServer.cpp
index 906754f..47e7462 100644
--- a/Source/core/platform/network/ProxyServer.cpp
+++ b/Source/core/platform/network/ProxyServer.cpp
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "core/platform/network/ProxyServer.h"
 
-#include <wtf/text/StringBuilder.h>
+#include "wtf/text/StringBuilder.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/ProxyServer.h b/Source/core/platform/network/ProxyServer.h
index 8f7612e..26e64f4 100644
--- a/Source/core/platform/network/ProxyServer.h
+++ b/Source/core/platform/network/ProxyServer.h
@@ -26,8 +26,8 @@
 #ifndef ProxyServer_h
 #define ProxyServer_h
 
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/ResourceError.cpp b/Source/core/platform/network/ResourceError.cpp
index 6d5c4ae..0ee01b3 100644
--- a/Source/core/platform/network/ResourceError.cpp
+++ b/Source/core/platform/network/ResourceError.cpp
@@ -27,10 +27,20 @@
 #include "config.h"
 #include "core/platform/network/ResourceError.h"
 
+#include "public/platform/Platform.h"
+#include "public/platform/WebURL.h"
+#include "public/platform/WebURLError.h"
+#include "weborigin/KURL.h"
+
 namespace WebCore {
 
 const char* const errorDomainWebKitInternal = "WebKitInternal";
 
+ResourceError ResourceError::cancelledError(const String& failingURL)
+{
+    return WebKit::Platform::current()->cancelledError(KURL(ParsedURLString, failingURL));
+}
+
 ResourceError ResourceError::copy() const
 {
     ResourceError errorCopy;
diff --git a/Source/core/platform/network/ResourceError.h b/Source/core/platform/network/ResourceError.h
index 47439ef..ec1d3a8 100644
--- a/Source/core/platform/network/ResourceError.h
+++ b/Source/core/platform/network/ResourceError.h
@@ -27,7 +27,7 @@
 #ifndef ResourceError_h
 #define ResourceError_h
 
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
@@ -35,6 +35,8 @@
 
 class ResourceError {
 public:
+    static ResourceError cancelledError(const String& failingURL);
+
     ResourceError()
         : m_errorCode(0)
         , m_isNull(true)
diff --git a/Source/core/platform/network/ResourceHandle.h b/Source/core/platform/network/ResourceHandle.h
index 712dd1c..d05eab5 100644
--- a/Source/core/platform/network/ResourceHandle.h
+++ b/Source/core/platform/network/ResourceHandle.h
@@ -28,10 +28,10 @@
 
 #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>
+#include "wtf/Forward.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 class KURL;
diff --git a/Source/core/platform/network/ResourceHandleClient.h b/Source/core/platform/network/ResourceHandleClient.h
index 2fe8d90..38de7a2 100644
--- a/Source/core/platform/network/ResourceHandleClient.h
+++ b/Source/core/platform/network/ResourceHandleClient.h
@@ -27,7 +27,7 @@
 #ifndef ResourceHandleClient_h
 #define ResourceHandleClient_h
 
-#include <wtf/PassRefPtr.h>
+#include "wtf/PassRefPtr.h"
 
 namespace WebCore {
     class ResourceHandle;
diff --git a/Source/core/platform/network/ResourceLoadInfo.h b/Source/core/platform/network/ResourceLoadInfo.h
index 4ea815f..adcc2d8 100644
--- a/Source/core/platform/network/ResourceLoadInfo.h
+++ b/Source/core/platform/network/ResourceLoadInfo.h
@@ -28,7 +28,7 @@
 #define ResourceLoadInfo_h
 
 #include "core/platform/network/HTTPHeaderMap.h"
-#include <wtf/RefCounted.h>
+#include "wtf/RefCounted.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/ResourceLoadTiming.h b/Source/core/platform/network/ResourceLoadTiming.h
index 983a1dc..c09e81e 100644
--- a/Source/core/platform/network/ResourceLoadTiming.h
+++ b/Source/core/platform/network/ResourceLoadTiming.h
@@ -26,9 +26,9 @@
 #ifndef ResourceLoadTiming_h
 #define ResourceLoadTiming_h
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/ResourceResponse.cpp b/Source/core/platform/network/ResourceResponse.cpp
index 08fc0b1..4210a5f 100644
--- a/Source/core/platform/network/ResourceResponse.cpp
+++ b/Source/core/platform/network/ResourceResponse.cpp
@@ -29,9 +29,9 @@
 
 #include "core/platform/network/HTTPParsers.h"
 #include "core/platform/network/ResourceResponse.h"
-#include <wtf/CurrentTime.h>
-#include <wtf/MathExtras.h>
-#include <wtf/StdLibExtras.h>
+#include "wtf/CurrentTime.h"
+#include "wtf/MathExtras.h"
+#include "wtf/StdLibExtras.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/SocketStreamError.h b/Source/core/platform/network/SocketStreamError.h
index 440d038..d4554c6 100644
--- a/Source/core/platform/network/SocketStreamError.h
+++ b/Source/core/platform/network/SocketStreamError.h
@@ -32,9 +32,9 @@
 #ifndef SocketStreamError_h
 #define SocketStreamError_h
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/SocketStreamHandle.cpp b/Source/core/platform/network/SocketStreamHandle.cpp
index c6d57a4..47b3eae 100644
--- a/Source/core/platform/network/SocketStreamHandle.cpp
+++ b/Source/core/platform/network/SocketStreamHandle.cpp
@@ -40,7 +40,7 @@
 #include "public/platform/WebData.h"
 #include "public/platform/WebSocketStreamError.h"
 #include "public/platform/WebSocketStreamHandle.h"
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/network/SocketStreamHandleInternal.h b/Source/core/platform/network/SocketStreamHandleInternal.h
index fd6fadc..55f5de0 100644
--- a/Source/core/platform/network/SocketStreamHandleInternal.h
+++ b/Source/core/platform/network/SocketStreamHandleInternal.h
@@ -34,7 +34,7 @@
 #include "core/platform/network/SocketStreamHandle.h"
 #include "public/platform/WebSocketStreamHandleClient.h"
 #include "public/platform/WebURL.h"
-#include <wtf/PassOwnPtr.h>
+#include "wtf/PassOwnPtr.h"
 
 namespace WebKit {
 
diff --git a/Source/core/platform/sql/SQLValue.h b/Source/core/platform/sql/SQLValue.h
index 86ff887..e0069d0 100644
--- a/Source/core/platform/sql/SQLValue.h
+++ b/Source/core/platform/sql/SQLValue.h
@@ -29,8 +29,8 @@
 #ifndef SQLValue_h
 #define SQLValue_h
 
-#include <wtf/Threading.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Threading.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/sql/SQLiteDatabase.cpp b/Source/core/platform/sql/SQLiteDatabase.cpp
index b021999..b519cdb 100644
--- a/Source/core/platform/sql/SQLiteDatabase.cpp
+++ b/Source/core/platform/sql/SQLiteDatabase.cpp
@@ -32,9 +32,9 @@
 #include "core/platform/sql/SQLiteFileSystem.h"
 #include "core/platform/sql/SQLiteStatement.h"
 #include "modules/webdatabase/DatabaseAuthorizer.h"
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/Threading.h>
+#include "wtf/text/CString.h"
+#include "wtf/text/WTFString.h"
+#include "wtf/Threading.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/sql/SQLiteDatabase.h b/Source/core/platform/sql/SQLiteDatabase.h
index f15508c..3ea8bd2 100644
--- a/Source/core/platform/sql/SQLiteDatabase.h
+++ b/Source/core/platform/sql/SQLiteDatabase.h
@@ -27,9 +27,9 @@
 #ifndef SQLiteDatabase_h
 #define SQLiteDatabase_h
 
-#include <wtf/Threading.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Threading.h"
+#include "wtf/text/CString.h"
+#include "wtf/text/WTFString.h"
 
 #if COMPILER(MSVC)
 #pragma warning(disable: 4800)
diff --git a/Source/core/platform/sql/SQLiteFileSystem.h b/Source/core/platform/sql/SQLiteFileSystem.h
index 8864c2d..f3b1b59 100644
--- a/Source/core/platform/sql/SQLiteFileSystem.h
+++ b/Source/core/platform/sql/SQLiteFileSystem.h
@@ -31,8 +31,8 @@
 #ifndef SQLiteFileSystem_h
 #define SQLiteFileSystem_h
 
-#include <wtf/Threading.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Threading.h"
+#include "wtf/text/WTFString.h"
 
 struct sqlite3;
 
diff --git a/Source/core/platform/sql/SQLiteStatement.cpp b/Source/core/platform/sql/SQLiteStatement.cpp
index d4ef7ab..137d8a4 100644
--- a/Source/core/platform/sql/SQLiteStatement.cpp
+++ b/Source/core/platform/sql/SQLiteStatement.cpp
@@ -29,8 +29,8 @@
 #include <sqlite3.h>
 #include "core/platform/Logging.h"
 #include "core/platform/sql/SQLValue.h"
-#include <wtf/Assertions.h>
-#include <wtf/text/CString.h>
+#include "wtf/Assertions.h"
+#include "wtf/text/CString.h"
 
 // SQLite 3.6.16 makes sqlite3_prepare_v2 automatically retry preparing the statement
 // once if the database scheme has changed. We rely on this behavior.
diff --git a/Source/core/platform/sql/SQLiteTransaction.h b/Source/core/platform/sql/SQLiteTransaction.h
index ba686ba..80f9ae4 100644
--- a/Source/core/platform/sql/SQLiteTransaction.h
+++ b/Source/core/platform/sql/SQLiteTransaction.h
@@ -26,8 +26,8 @@
 #ifndef SQLiteTransaction_h
 #define SQLiteTransaction_h
 
-#include <wtf/FastAllocBase.h>
-#include <wtf/Noncopyable.h>
+#include "wtf/FastAllocBase.h"
+#include "wtf/Noncopyable.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/sql/chromium/SQLiteFileSystemChromium.cpp b/Source/core/platform/sql/chromium/SQLiteFileSystemChromium.cpp
index d97ba0b..0673127 100644
--- a/Source/core/platform/sql/chromium/SQLiteFileSystemChromium.cpp
+++ b/Source/core/platform/sql/chromium/SQLiteFileSystemChromium.cpp
@@ -33,7 +33,7 @@
 
 #include <sqlite3.h>
 #include "public/platform/Platform.h"
-#include <wtf/text/CString.h>
+#include "wtf/text/CString.h"
 
 // SQLiteFileSystem::registerSQLiteVFS() is implemented in the
 // platform-specific files SQLiteFileSystemChromium{Win|Posix}.cpp
diff --git a/Source/core/platform/text/AtomicStringKeyedMRUCache.h b/Source/core/platform/text/AtomicStringKeyedMRUCache.h
index b3004f7..5b734e9 100644
--- a/Source/core/platform/text/AtomicStringKeyedMRUCache.h
+++ b/Source/core/platform/text/AtomicStringKeyedMRUCache.h
@@ -26,7 +26,7 @@
 #ifndef AtomicStringKeyedMRUCache_h
 #define AtomicStringKeyedMRUCache_h
 
-#include <wtf/text/AtomicString.h>
+#include "wtf/text/AtomicString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/BidiContext.cpp b/Source/core/platform/text/BidiContext.cpp
index 92b1bb0..2f1031a 100644
--- a/Source/core/platform/text/BidiContext.cpp
+++ b/Source/core/platform/text/BidiContext.cpp
@@ -21,7 +21,7 @@
 
 #include "config.h"
 #include "core/platform/text/BidiContext.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/BidiContext.h b/Source/core/platform/text/BidiContext.h
index 1d48d36..c701e88 100644
--- a/Source/core/platform/text/BidiContext.h
+++ b/Source/core/platform/text/BidiContext.h
@@ -22,11 +22,11 @@
 #ifndef BidiContext_h
 #define BidiContext_h
 
-#include <wtf/Assertions.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/unicode/Unicode.h>
+#include "wtf/Assertions.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/unicode/Unicode.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/BidiResolver.h b/Source/core/platform/text/BidiResolver.h
index ccfb85a..17432cc 100644
--- a/Source/core/platform/text/BidiResolver.h
+++ b/Source/core/platform/text/BidiResolver.h
@@ -25,9 +25,9 @@
 #include "core/platform/text/BidiContext.h"
 #include "core/platform/text/BidiRunList.h"
 #include "core/platform/text/TextDirection.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/Noncopyable.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/BidiRunList.h b/Source/core/platform/text/BidiRunList.h
index d6db7ee..269b7fc 100644
--- a/Source/core/platform/text/BidiRunList.h
+++ b/Source/core/platform/text/BidiRunList.h
@@ -23,7 +23,7 @@
 #ifndef BidiRunList_h
 #define BidiRunList_h
 
-#include <wtf/Noncopyable.h>
+#include "wtf/Noncopyable.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/DateTimeFormat.cpp b/Source/core/platform/text/DateTimeFormat.cpp
index afd20cc..9ea7afc 100644
--- a/Source/core/platform/text/DateTimeFormat.cpp
+++ b/Source/core/platform/text/DateTimeFormat.cpp
@@ -26,8 +26,8 @@
 #include "config.h"
 #include "core/platform/text/DateTimeFormat.h"
 
-#include <wtf/ASCIICType.h>
-#include <wtf/text/StringBuilder.h>
+#include "wtf/ASCIICType.h"
+#include "wtf/text/StringBuilder.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/DateTimeFormat.h b/Source/core/platform/text/DateTimeFormat.h
index 3e06b36..729212a 100644
--- a/Source/core/platform/text/DateTimeFormat.h
+++ b/Source/core/platform/text/DateTimeFormat.h
@@ -26,7 +26,7 @@
 #ifndef DateTimeFormat_h
 #define DateTimeFormat_h
 
-#include <wtf/Forward.h>
+#include "wtf/Forward.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/Hyphenation.cpp b/Source/core/platform/text/Hyphenation.cpp
index 740fd58..45ab3ea 100644
--- a/Source/core/platform/text/Hyphenation.cpp
+++ b/Source/core/platform/text/Hyphenation.cpp
@@ -36,9 +36,9 @@
     return WebKit::Platform::current()->hyphenator()->canHyphenate(localeIdentifier);
 }
 
-size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex, const AtomicString& localeIdentifier)
+size_t lastHyphenLocation(const String& word, size_t beforeIndex, const AtomicString& localeIdentifier)
 {
-    return WebKit::Platform::current()->hyphenator()->computeLastHyphenLocation(characters, length, beforeIndex, localeIdentifier);
+    return WebKit::Platform::current()->hyphenator()->computeLastHyphenLocation(word, beforeIndex, localeIdentifier);
 }
 
 } // namespace WebCore
diff --git a/Source/core/platform/text/Hyphenation.h b/Source/core/platform/text/Hyphenation.h
index a99bff0..0f8aeaf 100644
--- a/Source/core/platform/text/Hyphenation.h
+++ b/Source/core/platform/text/Hyphenation.h
@@ -26,13 +26,13 @@
 #ifndef Hyphenation_h
 #define Hyphenation_h
 
-#include <wtf/Forward.h>
-#include <wtf/unicode/Unicode.h>
+#include "wtf/Forward.h"
+#include "wtf/unicode/Unicode.h"
 
 namespace WebCore {
 
 bool canHyphenate(const AtomicString& localeIdentifier);
-size_t lastHyphenLocation(const UChar*, size_t length, size_t beforeIndex, const AtomicString& localeIdentifier);
+size_t lastHyphenLocation(const String& word, size_t beforeIndex, const AtomicString& localeIdentifier);
 
 } // namespace WebCore
 
diff --git a/Source/core/platform/text/LineBreakIteratorPoolICU.h b/Source/core/platform/text/LineBreakIteratorPoolICU.h
index c23b3db..de7e3a2 100644
--- a/Source/core/platform/text/LineBreakIteratorPoolICU.h
+++ b/Source/core/platform/text/LineBreakIteratorPoolICU.h
@@ -28,12 +28,12 @@
 
 #include <unicode/ubrk.h>
 #include "core/platform/text/TextBreakIteratorInternalICU.h"
-#include <wtf/Assertions.h>
-#include <wtf/HashMap.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/CString.h>
-#include <wtf/ThreadSpecific.h>
+#include "wtf/Assertions.h"
+#include "wtf/HashMap.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/AtomicString.h"
+#include "wtf/text/CString.h"
+#include "wtf/ThreadSpecific.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/LineEnding.cpp b/Source/core/platform/text/LineEnding.cpp
index 7ffde59..9cf7ffa 100644
--- a/Source/core/platform/text/LineEnding.cpp
+++ b/Source/core/platform/text/LineEnding.cpp
@@ -32,8 +32,8 @@
 #include "config.h"
 #include "core/platform/text/LineEnding.h"
 
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/text/CString.h"
+#include "wtf/text/WTFString.h"
 
 namespace {
 
diff --git a/Source/core/platform/text/LineEnding.h b/Source/core/platform/text/LineEnding.h
index 4306ce8..e49912d 100644
--- a/Source/core/platform/text/LineEnding.h
+++ b/Source/core/platform/text/LineEnding.h
@@ -32,8 +32,8 @@
 #ifndef LineEnding_h
 #define LineEnding_h
 
-#include <wtf/Forward.h>
-#include <wtf/Vector.h>
+#include "wtf/Forward.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/LocaleICU.cpp b/Source/core/platform/text/LocaleICU.cpp
index 34245ac..a0f05dd 100644
--- a/Source/core/platform/text/LocaleICU.cpp
+++ b/Source/core/platform/text/LocaleICU.cpp
@@ -34,9 +34,9 @@
 #include <unicode/udatpg.h>
 #include <unicode/uloc.h>
 #include <limits>
-#include <wtf/DateMath.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/text/StringBuilder.h>
+#include "wtf/DateMath.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/StringBuilder.h"
 
 using namespace icu;
 using namespace std;
diff --git a/Source/core/platform/text/LocaleICU.h b/Source/core/platform/text/LocaleICU.h
index 41b1552..772992c 100644
--- a/Source/core/platform/text/LocaleICU.h
+++ b/Source/core/platform/text/LocaleICU.h
@@ -35,10 +35,10 @@
 #include <unicode/unum.h>
 #include "core/platform/DateComponents.h"
 #include "core/platform/text/PlatformLocale.h"
-#include <wtf/Forward.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Forward.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/text/CString.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/LocaleToScriptMapping.h b/Source/core/platform/text/LocaleToScriptMapping.h
index d5c8c76..2d270ec 100644
--- a/Source/core/platform/text/LocaleToScriptMapping.h
+++ b/Source/core/platform/text/LocaleToScriptMapping.h
@@ -31,8 +31,8 @@
 #ifndef LocaleToScriptMapping_h
 #define LocaleToScriptMapping_h
 
-#include <wtf/Forward.h>
-#include <wtf/unicode/Unicode.h>
+#include "wtf/Forward.h"
+#include "wtf/unicode/Unicode.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/LocaleToScriptMappingDefault.cpp b/Source/core/platform/text/LocaleToScriptMappingDefault.cpp
index be3e5ff..6a410f3 100644
--- a/Source/core/platform/text/LocaleToScriptMappingDefault.cpp
+++ b/Source/core/platform/text/LocaleToScriptMappingDefault.cpp
@@ -31,9 +31,9 @@
 #include "config.h"
 #include "core/platform/text/LocaleToScriptMapping.h"
 
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/text/StringHash.h>
+#include "wtf/HashMap.h"
+#include "wtf/HashSet.h"
+#include "wtf/text/StringHash.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/ParserUtilities.h b/Source/core/platform/text/ParserUtilities.h
index eeff3a9..6548759 100644
--- a/Source/core/platform/text/ParserUtilities.h
+++ b/Source/core/platform/text/ParserUtilities.h
@@ -22,7 +22,7 @@
 #ifndef ParserUtilities_h
 #define ParserUtilities_h
 
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/PlatformLocale.cpp b/Source/core/platform/text/PlatformLocale.cpp
index dcac28e..65dadcc 100644
--- a/Source/core/platform/text/PlatformLocale.cpp
+++ b/Source/core/platform/text/PlatformLocale.cpp
@@ -33,7 +33,7 @@
 
 #include "core/platform/LocalizedStrings.h"
 #include "core/platform/text/DateTimeFormat.h"
-#include <wtf/text/StringBuilder.h>
+#include "wtf/text/StringBuilder.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/PlatformLocale.h b/Source/core/platform/text/PlatformLocale.h
index c7db13b..c02a646 100644
--- a/Source/core/platform/text/PlatformLocale.h
+++ b/Source/core/platform/text/PlatformLocale.h
@@ -28,8 +28,8 @@
 
 #include "core/platform/DateComponents.h"
 #include "core/platform/Language.h"
-#include <wtf/PassOwnPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/QuotedPrintable.cpp b/Source/core/platform/text/QuotedPrintable.cpp
index a54d0b2..547a77c 100644
--- a/Source/core/platform/text/QuotedPrintable.cpp
+++ b/Source/core/platform/text/QuotedPrintable.cpp
@@ -31,7 +31,7 @@
 #include "config.h"
 #include "core/platform/text/QuotedPrintable.h"
 
-#include <wtf/ASCIICType.h>
+#include "wtf/ASCIICType.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/QuotedPrintable.h b/Source/core/platform/text/QuotedPrintable.h
index c3cc337..5cbd85b 100644
--- a/Source/core/platform/text/QuotedPrintable.h
+++ b/Source/core/platform/text/QuotedPrintable.h
@@ -31,7 +31,7 @@
 #ifndef QuotedPrintable_h
 #define QuotedPrintable_h
 
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/RegularExpression.cpp b/Source/core/platform/text/RegularExpression.cpp
index 59a8cd6..dcff018 100644
--- a/Source/core/platform/text/RegularExpression.cpp
+++ b/Source/core/platform/text/RegularExpression.cpp
@@ -83,7 +83,7 @@
     v8::Local<v8::RegExp> regex = m_regex.newLocal(isolate);
     v8::Local<v8::Function> exec = regex->Get(v8::String::NewSymbol("exec")).As<v8::Function>();
 
-    v8::Handle<v8::Value> argv[] = { v8String(string.substringSharingImpl(startFrom), context->GetIsolate()) };
+    v8::Handle<v8::Value> argv[] = { v8String(string.substring(startFrom), context->GetIsolate()) };
     v8::Local<v8::Value> returnValue = exec->Call(regex, 1, argv);
 
     // RegExp#exec returns null if there's no match, otherwise it returns an
diff --git a/Source/core/platform/text/RegularExpression.h b/Source/core/platform/text/RegularExpression.h
index 9f77987..8116af1 100644
--- a/Source/core/platform/text/RegularExpression.h
+++ b/Source/core/platform/text/RegularExpression.h
@@ -29,8 +29,8 @@
 
 #include <v8.h>
 #include "bindings/v8/ScopedPersistent.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Noncopyable.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/SegmentedString.h b/Source/core/platform/text/SegmentedString.h
index abd798a..946ff24 100644
--- a/Source/core/platform/text/SegmentedString.h
+++ b/Source/core/platform/text/SegmentedString.h
@@ -20,10 +20,10 @@
 #ifndef SegmentedString_h
 #define SegmentedString_h
 
-#include <wtf/Deque.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/TextPosition.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Deque.h"
+#include "wtf/text/StringBuilder.h"
+#include "wtf/text/TextPosition.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/StringWithDirection.h b/Source/core/platform/text/StringWithDirection.h
index 66ea238..d8f1946 100644
--- a/Source/core/platform/text/StringWithDirection.h
+++ b/Source/core/platform/text/StringWithDirection.h
@@ -32,7 +32,7 @@
 #define StringWithDirection_h
 
 #include "core/platform/text/TextDirection.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/SuffixTree.h b/Source/core/platform/text/SuffixTree.h
index 1f05c36..cad0a9f 100644
--- a/Source/core/platform/text/SuffixTree.h
+++ b/Source/core/platform/text/SuffixTree.h
@@ -26,8 +26,8 @@
 #ifndef SuffixTree_h
 #define SuffixTree_h
 
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/TextBoundaries.cpp b/Source/core/platform/text/TextBoundaries.cpp
index b7ddbce..197e4f5 100644
--- a/Source/core/platform/text/TextBoundaries.cpp
+++ b/Source/core/platform/text/TextBoundaries.cpp
@@ -28,8 +28,8 @@
 #include "core/platform/text/TextBoundaries.h"
 
 #include "core/platform/text/TextBreakIterator.h"
-#include <wtf/text/StringImpl.h>
-#include <wtf/unicode/Unicode.h>
+#include "wtf/text/StringImpl.h"
+#include "wtf/unicode/Unicode.h"
 
 using namespace WTF;
 using namespace Unicode;
diff --git a/Source/core/platform/text/TextBoundaries.h b/Source/core/platform/text/TextBoundaries.h
index 870ab62..c9e8d91 100644
--- a/Source/core/platform/text/TextBoundaries.h
+++ b/Source/core/platform/text/TextBoundaries.h
@@ -26,7 +26,7 @@
 #ifndef TextBoundaries_h
 #define TextBoundaries_h
 
-#include <wtf/unicode/Unicode.h>
+#include "wtf/unicode/Unicode.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/TextBreakIterator.h b/Source/core/platform/text/TextBreakIterator.h
index 738637d..d6de559 100644
--- a/Source/core/platform/text/TextBreakIterator.h
+++ b/Source/core/platform/text/TextBreakIterator.h
@@ -22,8 +22,8 @@
 #ifndef TextBreakIterator_h
 #define TextBreakIterator_h
 
-#include <wtf/text/AtomicString.h>
-#include <wtf/unicode/Unicode.h>
+#include "wtf/text/AtomicString.h"
+#include "wtf/unicode/Unicode.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/TextBreakIteratorICU.cpp b/Source/core/platform/text/TextBreakIteratorICU.cpp
index 36bd871..6407b72 100644
--- a/Source/core/platform/text/TextBreakIteratorICU.cpp
+++ b/Source/core/platform/text/TextBreakIteratorICU.cpp
@@ -23,7 +23,7 @@
 #include "core/platform/text/TextBreakIterator.h"
 
 #include "core/platform/text/LineBreakIteratorPoolICU.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 using namespace WTF;
 using namespace std;
diff --git a/Source/core/platform/text/TextChecking.h b/Source/core/platform/text/TextChecking.h
index 919515e..5b3bff9 100644
--- a/Source/core/platform/text/TextChecking.h
+++ b/Source/core/platform/text/TextChecking.h
@@ -31,9 +31,9 @@
 #ifndef TextChecking_h
 #define TextChecking_h
 
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/TextStream.cpp b/Source/core/platform/text/TextStream.cpp
index 99a4aa0..5d4816e 100644
--- a/Source/core/platform/text/TextStream.cpp
+++ b/Source/core/platform/text/TextStream.cpp
@@ -26,9 +26,9 @@
 #include "config.h"
 #include "core/platform/text/TextStream.h"
 
-#include <wtf/MathExtras.h>
-#include <wtf/StringExtras.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/MathExtras.h"
+#include "wtf/StringExtras.h"
+#include "wtf/text/WTFString.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/text/TextStream.h b/Source/core/platform/text/TextStream.h
index 9ff7d97..6a0f85a 100644
--- a/Source/core/platform/text/TextStream.h
+++ b/Source/core/platform/text/TextStream.h
@@ -26,9 +26,9 @@
 #ifndef TextStream_h
 #define TextStream_h
 
-#include <wtf/Forward.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/unicode/Unicode.h>
+#include "wtf/Forward.h"
+#include "wtf/text/StringBuilder.h"
+#include "wtf/unicode/Unicode.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/UnicodeRange.h b/Source/core/platform/text/UnicodeRange.h
index 7ecf03f..fe0afbf 100644
--- a/Source/core/platform/text/UnicodeRange.h
+++ b/Source/core/platform/text/UnicodeRange.h
@@ -35,7 +35,7 @@
 #ifndef UnicodeRange_H
 #define UnicodeRange_H
 
-#include <wtf/unicode/Unicode.h>
+#include "wtf/unicode/Unicode.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/text/cf/AtomicStringCF.cpp b/Source/core/platform/text/cf/AtomicStringCF.cpp
index b173737..2ba3853 100644
--- a/Source/core/platform/text/cf/AtomicStringCF.cpp
+++ b/Source/core/platform/text/cf/AtomicStringCF.cpp
@@ -24,12 +24,12 @@
  */
 
 #include "config.h"
-#include <wtf/text/AtomicString.h>
+#include "wtf/text/AtomicString.h"
 
 #if USE(CF)
 
 #include <CoreFoundation/CoreFoundation.h>
-#include <wtf/text/CString.h>
+#include "wtf/text/CString.h"
 
 namespace WTF {
 
diff --git a/Source/core/platform/text/cf/HyphenationCF.cpp b/Source/core/platform/text/cf/HyphenationCF.cpp
deleted file mode 100644
index 821dbc8..0000000
--- a/Source/core/platform/text/cf/HyphenationCF.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2010 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/text/Hyphenation.h"
-#include <AvailabilityMacros.h>
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
-
-#include "core/platform/text/AtomicStringKeyedMRUCache.h"
-#include "core/platform/text/TextBreakIteratorInternalICU.h"
-#include <wtf/ListHashSet.h>
-#include <wtf/RetainPtr.h>
-
-namespace WebCore {
-
-template<>
-RetainPtr<CFLocaleRef> AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >::createValueForNullKey()
-{
-    RetainPtr<CFLocaleRef> locale(AdoptCF, CFLocaleCopyCurrent());
-
-    return CFStringIsHyphenationAvailableForLocale(locale.get()) ? locale : 0;
-}
-
-template<>
-RetainPtr<CFLocaleRef> AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >::createValueForKey(const AtomicString& localeIdentifier)
-{
-    RetainPtr<CFLocaleRef> locale = adoptCF(CFLocaleCreate(kCFAllocatorDefault, localeIdentifier.string().createCFString().get()));
-
-    return CFStringIsHyphenationAvailableForLocale(locale.get()) ? locale : 0;
-}
-
-static AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >& cfLocaleCache()
-{
-    DEFINE_STATIC_LOCAL(AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >, cache, ());
-    return cache;
-}
-
-bool canHyphenate(const AtomicString& localeIdentifier)
-{
-    return cfLocaleCache().get(localeIdentifier);
-}
-
-size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex, const AtomicString& localeIdentifier)
-{
-    RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(characters), length, kCFAllocatorNull));
-
-    RetainPtr<CFLocaleRef> locale = cfLocaleCache().get(localeIdentifier);
-    ASSERT(locale);
-
-    CFOptionFlags searchAcrossWordBoundaries = 1;
-    CFIndex result = CFStringGetHyphenationLocationBeforeIndex(string.get(), beforeIndex, CFRangeMake(0, length), searchAcrossWordBoundaries, locale.get(), 0);
-    return result == kCFNotFound ? 0 : result;
-}
-
-} // namespace WebCore
-
-#endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
diff --git a/Source/core/platform/text/cf/StringCF.cpp b/Source/core/platform/text/cf/StringCF.cpp
index 2697e76..2cb4ce7 100644
--- a/Source/core/platform/text/cf/StringCF.cpp
+++ b/Source/core/platform/text/cf/StringCF.cpp
@@ -20,11 +20,11 @@
 
 #include "config.h"
 
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 #if USE(CF)
 #include <CoreFoundation/CoreFoundation.h>
-#include <wtf/RetainPtr.h>
+#include "wtf/RetainPtr.h"
 
 namespace WTF {
 
diff --git a/Source/core/platform/text/cf/StringImplCF.cpp b/Source/core/platform/text/cf/StringImplCF.cpp
index 55f10d2..2c2ed14 100644
--- a/Source/core/platform/text/cf/StringImplCF.cpp
+++ b/Source/core/platform/text/cf/StringImplCF.cpp
@@ -19,15 +19,15 @@
  */
 
 #include "config.h"
-#include <wtf/text/StringImpl.h>
+#include "wtf/text/StringImpl.h"
 
 #if USE(CF)
 
 #include <CoreFoundation/CoreFoundation.h>
-#include <wtf/MainThread.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/Threading.h>
+#include "wtf/MainThread.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RetainPtr.h"
+#include "wtf/Threading.h"
 
 namespace WTF {
 
diff --git a/Source/core/platform/text/mac/LocaleMac.h b/Source/core/platform/text/mac/LocaleMac.h
index 3d8cd75..3d6055c 100644
--- a/Source/core/platform/text/mac/LocaleMac.h
+++ b/Source/core/platform/text/mac/LocaleMac.h
@@ -32,10 +32,10 @@
 #define LocaleMac_h
 
 #include "core/platform/text/PlatformLocale.h"
-#include <wtf/Forward.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "wtf/Forward.h"
+#include "wtf/RetainPtr.h"
+#include "wtf/text/WTFString.h"
+#include "wtf/Vector.h"
 
 OBJC_CLASS NSCalendar;
 OBJC_CLASS NSDateFormatter;
diff --git a/Source/core/platform/text/mac/LocaleMac.mm b/Source/core/platform/text/mac/LocaleMac.mm
index 0922261..1dbcf4d 100644
--- a/Source/core/platform/text/mac/LocaleMac.mm
+++ b/Source/core/platform/text/mac/LocaleMac.mm
@@ -35,10 +35,10 @@
 #import <Foundation/NSLocale.h>
 #include "core/platform/Language.h"
 #include "core/platform/LocalizedStrings.h"
-#include <wtf/DateMath.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/text/StringBuilder.h>
+#include "wtf/DateMath.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/RetainPtr.h"
+#include "wtf/text/StringBuilder.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/text/mac/StringImplMac.mm b/Source/core/platform/text/mac/StringImplMac.mm
index d0523c8..d563103 100644
--- a/Source/core/platform/text/mac/StringImplMac.mm
+++ b/Source/core/platform/text/mac/StringImplMac.mm
@@ -19,10 +19,10 @@
  */
 
 #include "config.h"
-#include <wtf/text/StringImpl.h>
+#include "wtf/text/StringImpl.h"
 
 #include "core/platform/mac/FoundationExtras.h"
-#include <wtf/RetainPtr.h>
+#include "wtf/RetainPtr.h"
 
 namespace WTF {
 
diff --git a/Source/core/platform/text/mac/StringMac.mm b/Source/core/platform/text/mac/StringMac.mm
index 4e9b2c6..046767d 100644
--- a/Source/core/platform/text/mac/StringMac.mm
+++ b/Source/core/platform/text/mac/StringMac.mm
@@ -19,7 +19,7 @@
  */
 
 #include "config.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 #include <CoreFoundation/CFString.h>
 
diff --git a/Source/core/platform/text/transcoder/FontTranscoder.h b/Source/core/platform/text/transcoder/FontTranscoder.h
index b34f989..8016336 100644
--- a/Source/core/platform/text/transcoder/FontTranscoder.h
+++ b/Source/core/platform/text/transcoder/FontTranscoder.h
@@ -31,9 +31,9 @@
 #ifndef FontTranscoder_h
 #define FontTranscoder_h
 
-#include <wtf/HashMap.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/text/AtomicStringHash.h>
+#include "wtf/HashMap.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/text/AtomicStringHash.h"
 
 namespace WTF{
 class TextEncoding;
diff --git a/Source/core/platform/text/win/LocaleWin.cpp b/Source/core/platform/text/win/LocaleWin.cpp
index 575741c..2d565de 100644
--- a/Source/core/platform/text/win/LocaleWin.cpp
+++ b/Source/core/platform/text/win/LocaleWin.cpp
@@ -37,13 +37,13 @@
 #include "core/platform/Language.h"
 #include "core/platform/LocalizedStrings.h"
 #include "core/platform/text/DateTimeFormat.h"
-#include <wtf/CurrentTime.h>
-#include <wtf/DateMath.h>
-#include <wtf/HashMap.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/StringHash.h>
+#include "wtf/CurrentTime.h"
+#include "wtf/DateMath.h"
+#include "wtf/HashMap.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/StringBuilder.h"
+#include "wtf/text/StringHash.h"
 
 using namespace std;
 
diff --git a/Source/core/platform/text/win/LocaleWin.h b/Source/core/platform/text/win/LocaleWin.h
index 14f8391..9bd92c7 100644
--- a/Source/core/platform/text/win/LocaleWin.h
+++ b/Source/core/platform/text/win/LocaleWin.h
@@ -33,9 +33,9 @@
 
 #include <windows.h>
 #include "core/platform/text/PlatformLocale.h"
-#include <wtf/Forward.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "wtf/Forward.h"
+#include "wtf/text/WTFString.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/win/HWndDC.h b/Source/core/platform/win/HWndDC.h
index 2eaecad..53cb538 100644
--- a/Source/core/platform/win/HWndDC.h
+++ b/Source/core/platform/win/HWndDC.h
@@ -27,7 +27,7 @@
 #define HWndDC_h
 
 #include <windows.h>
-#include <wtf/NonCopyable.h>
+#include "wtf/NonCopyable.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/win/SystemInfo.cpp b/Source/core/platform/win/SystemInfo.cpp
index 0755f8f..b746c81 100644
--- a/Source/core/platform/win/SystemInfo.cpp
+++ b/Source/core/platform/win/SystemInfo.cpp
@@ -27,7 +27,7 @@
 #include "core/platform/win/SystemInfo.h"
 
 #include <windows.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/platform/win/SystemInfo.h b/Source/core/platform/win/SystemInfo.h
index 2631ace..f9e79e2 100644
--- a/Source/core/platform/win/SystemInfo.h
+++ b/Source/core/platform/win/SystemInfo.h
@@ -26,7 +26,7 @@
 #ifndef SystemInfo_h
 #define SystemInfo_h
 
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/plugins/DOMMimeType.cpp b/Source/core/plugins/DOMMimeType.cpp
index ca0c75c..41aace1 100644
--- a/Source/core/plugins/DOMMimeType.cpp
+++ b/Source/core/plugins/DOMMimeType.cpp
@@ -24,7 +24,7 @@
 #include "core/page/Page.h"
 #include "core/plugins/DOMPlugin.h"
 #include "core/plugins/PluginData.h"
-#include <wtf/text/StringBuilder.h>
+#include "wtf/text/StringBuilder.h"
 
 namespace WebCore {
 
diff --git a/Source/core/plugins/DOMMimeTypeArray.cpp b/Source/core/plugins/DOMMimeTypeArray.cpp
index 9d5411b..87f9a86 100644
--- a/Source/core/plugins/DOMMimeTypeArray.cpp
+++ b/Source/core/plugins/DOMMimeTypeArray.cpp
@@ -23,7 +23,7 @@
 #include "core/page/Frame.h"
 #include "core/page/Page.h"
 #include "core/plugins/PluginData.h"
-#include <wtf/text/AtomicString.h>
+#include "wtf/text/AtomicString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/plugins/DOMMimeTypeArray.h b/Source/core/plugins/DOMMimeTypeArray.h
index 9ba55f0..d9acd83 100644
--- a/Source/core/plugins/DOMMimeTypeArray.h
+++ b/Source/core/plugins/DOMMimeTypeArray.h
@@ -24,10 +24,10 @@
 #include "bindings/v8/ScriptWrappable.h"
 #include "core/page/DOMWindowProperty.h"
 #include "core/plugins/DOMMimeType.h"
-#include <wtf/Forward.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
+#include "wtf/Forward.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/plugins/DOMPlugin.cpp b/Source/core/plugins/DOMPlugin.cpp
index ac6b631..534e04d 100644
--- a/Source/core/plugins/DOMPlugin.cpp
+++ b/Source/core/plugins/DOMPlugin.cpp
@@ -20,7 +20,7 @@
 #include "core/plugins/DOMPlugin.h"
 
 #include "core/plugins/PluginData.h"
-#include <wtf/text/AtomicString.h>
+#include "wtf/text/AtomicString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/plugins/DOMPlugin.h b/Source/core/plugins/DOMPlugin.h
index 7911688..7e20be1 100644
--- a/Source/core/plugins/DOMPlugin.h
+++ b/Source/core/plugins/DOMPlugin.h
@@ -23,9 +23,9 @@
 #include "bindings/v8/ScriptWrappable.h"
 #include "core/page/FrameDestructionObserver.h"
 #include "core/plugins/DOMMimeType.h"
-#include <wtf/Forward.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
+#include "wtf/Forward.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
 
 namespace WebCore {
 
diff --git a/Source/core/plugins/DOMPluginArray.cpp b/Source/core/plugins/DOMPluginArray.cpp
index a90a49b..11032e3 100644
--- a/Source/core/plugins/DOMPluginArray.cpp
+++ b/Source/core/plugins/DOMPluginArray.cpp
@@ -24,7 +24,7 @@
 #include "core/page/Page.h"
 #include "core/plugins/DOMPlugin.h"
 #include "core/plugins/PluginData.h"
-#include <wtf/text/AtomicString.h>
+#include "wtf/text/AtomicString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/plugins/DOMPluginArray.h b/Source/core/plugins/DOMPluginArray.h
index 0f7fc83..51eff45 100644
--- a/Source/core/plugins/DOMPluginArray.h
+++ b/Source/core/plugins/DOMPluginArray.h
@@ -24,10 +24,10 @@
 #include "bindings/v8/ScriptWrappable.h"
 #include "core/page/DOMWindowProperty.h"
 #include "core/plugins/DOMPlugin.h"
-#include <wtf/Forward.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
+#include "wtf/Forward.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/plugins/IFrameShimSupport.cpp b/Source/core/plugins/IFrameShimSupport.cpp
index 018143c..b5f67cb 100644
--- a/Source/core/plugins/IFrameShimSupport.cpp
+++ b/Source/core/plugins/IFrameShimSupport.cpp
@@ -40,8 +40,7 @@
 #include "core/platform/Widget.h"
 #include "core/rendering/RenderBox.h"
 #include "core/rendering/RenderObject.h"
-
-#include <wtf/HashSet.h>
+#include "wtf/HashSet.h"
 
 // This file provides plugin-related utility functions for iframe shims and is shared by platforms that inherit
 // from PluginView (e.g. Qt) and those that do not (e.g. Chromium).
diff --git a/Source/core/plugins/IFrameShimSupport.h b/Source/core/plugins/IFrameShimSupport.h
index 6e55126..a9d7221 100644
--- a/Source/core/plugins/IFrameShimSupport.h
+++ b/Source/core/plugins/IFrameShimSupport.h
@@ -20,7 +20,7 @@
 #ifndef IFrameShimSupport_h
 #define IFrameShimSupport_h
 
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 class Element;
diff --git a/Source/core/plugins/PluginData.h b/Source/core/plugins/PluginData.h
index 93db50f..96317ca 100644
--- a/Source/core/plugins/PluginData.h
+++ b/Source/core/plugins/PluginData.h
@@ -20,9 +20,9 @@
 #ifndef PluginData_h
 #define PluginData_h
 
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
diff --git a/Source/core/plugins/PluginListBuilder.cpp b/Source/core/plugins/PluginListBuilder.cpp
index c791ecd..98482fb 100644
--- a/Source/core/plugins/PluginListBuilder.cpp
+++ b/Source/core/plugins/PluginListBuilder.cpp
@@ -33,7 +33,7 @@
 
 #include "core/plugins/PluginData.h"
 #include "public/platform/WebString.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/plugins/PluginListBuilder.h b/Source/core/plugins/PluginListBuilder.h
index fd0c99e..4ff0b4e 100644
--- a/Source/core/plugins/PluginListBuilder.h
+++ b/Source/core/plugins/PluginListBuilder.h
@@ -33,7 +33,7 @@
 
 #include "core/plugins/PluginData.h"
 #include "public/platform/WebPluginListBuilder.h"
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
 
 namespace WebCore {
 
diff --git a/Source/core/plugins/PluginView.h b/Source/core/plugins/PluginView.h
index fabcb04..c25d2b1 100644
--- a/Source/core/plugins/PluginView.h
+++ b/Source/core/plugins/PluginView.h
@@ -28,7 +28,7 @@
 
 #include "core/platform/ScrollTypes.h"
 #include "core/platform/Widget.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
 
 struct NPObject;
 
diff --git a/Source/core/rendering/EllipsisBox.cpp b/Source/core/rendering/EllipsisBox.cpp
index a0d570c..c5cb7cf 100644
--- a/Source/core/rendering/EllipsisBox.cpp
+++ b/Source/core/rendering/EllipsisBox.cpp
@@ -37,7 +37,7 @@
 {
     GraphicsContext* context = paintInfo.context;
     RenderStyle* style = m_renderer->style(isFirstLineStyle());
-    Color styleTextColor = style->visitedDependentColor(CSSPropertyWebkitTextFillColor);
+    Color styleTextColor = m_renderer->resolveColor(style, CSSPropertyWebkitTextFillColor);
     if (styleTextColor != context->fillColor())
         context->setFillColor(styleTextColor);
 
@@ -52,7 +52,8 @@
             context->setFillColor(foreground);
     }
 
-    const ShadowData* shadow = style->textShadow();
+    // Text shadows are disabled when printing. http://crbug.com/258321
+    const ShadowData* shadow = context->printing() ? 0 : style->textShadow();
     bool hasShadow = shadow;
     if (hasShadow) {
         DrawLooper drawLooper;
@@ -60,7 +61,7 @@
             int shadowX = isHorizontal() ? shadow->x() : shadow->y();
             int shadowY = isHorizontal() ? shadow->y() : -shadow->x();
             FloatSize offset(shadowX, shadowY);
-            drawLooper.addShadow(offset, shadow->blur(), shadow->color(),
+            drawLooper.addShadow(offset, shadow->blur(), m_renderer->resolveColor(shadow->color()),
                 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha);
         } while ((shadow = shadow->next()));
         drawLooper.addUnmodifiedContent();
@@ -128,7 +129,7 @@
 
 void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& paintOffset, RenderStyle* style, const Font& font)
 {
-    Color textColor = style->visitedDependentColor(CSSPropertyColor);
+    Color textColor = m_renderer->resolveColor(style, CSSPropertyColor);
     Color c = m_renderer->selectionBackgroundColor();
     if (!c.isValid() || !c.alpha())
         return;
diff --git a/Source/core/rendering/InlineFlowBox.cpp b/Source/core/rendering/InlineFlowBox.cpp
index 1d187f5..cb1134e 100644
--- a/Source/core/rendering/InlineFlowBox.cpp
+++ b/Source/core/rendering/InlineFlowBox.cpp
@@ -1278,7 +1278,7 @@
         if (!boxModelObject()->boxShadowShouldBeAppliedToBackground(BackgroundBleedNone, this))
             paintBoxShadow(paintInfo, styleToUse, Normal, paintRect);
 
-        Color c = styleToUse->visitedDependentColor(CSSPropertyBackgroundColor);
+        Color c = renderer()->resolveColor(styleToUse, CSSPropertyBackgroundColor);
         paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), paintRect);
         paintBoxShadow(paintInfo, styleToUse, Inset, paintRect);
 
diff --git a/Source/core/rendering/InlineTextBox.cpp b/Source/core/rendering/InlineTextBox.cpp
index 8a8c594..5b36f6d 100644
--- a/Source/core/rendering/InlineTextBox.cpp
+++ b/Source/core/rendering/InlineTextBox.cpp
@@ -186,13 +186,13 @@
     return state;
 }
 
-static void adjustCharactersAndLengthForHyphen(BufferForAppendingHyphen& charactersWithHyphen, RenderStyle* style, String& string, int& length)
+static void adjustCharactersAndLengthForHyphen(BufferForAppendingHyphen& charactersWithHyphen, RenderStyle* style, StringView& string, int& length)
 {
     const AtomicString& hyphenString = style->hyphenString();
     charactersWithHyphen.reserveCapacity(length + hyphenString.length());
     charactersWithHyphen.append(string);
     charactersWithHyphen.append(hyphenString);
-    string = charactersWithHyphen.toString();
+    string = charactersWithHyphen.toString().createView();
     length += hyphenString.length();
 }
 
@@ -392,13 +392,15 @@
     return false;
 }
 
-static void paintTextWithShadows(GraphicsContext* context, const Font& font, const TextRun& textRun,
-                                 const AtomicString& emphasisMark, int emphasisMarkOffset,
-                                 int startOffset, int endOffset, int truncationPoint,
-                                 const FloatPoint& textOrigin, const FloatRect& boxRect,
-                                 const ShadowData* shadow, bool stroked, bool horizontal)
+static void paintTextWithShadows(GraphicsContext* context,
+    const RenderObject* renderer, const Font& font, const TextRun& textRun,
+    const AtomicString& emphasisMark, int emphasisMarkOffset,
+    int startOffset, int endOffset, int truncationPoint,
+    const FloatPoint& textOrigin, const FloatRect& boxRect,
+    const ShadowData* shadow, bool stroked, bool horizontal)
 {
-    bool hasShadow = shadow;
+    // Text shadows are disabled when printing. http://crbug.com/258321
+    bool hasShadow = shadow && !context->printing();
     Color fillColor = context->fillColor();
 
     if (hasShadow) {
@@ -407,7 +409,7 @@
             int shadowX = horizontal ? shadow->x() : shadow->y();
             int shadowY = horizontal ? shadow->y() : -shadow->x();
             FloatSize offset(shadowX, shadowY);
-            drawLooper.addShadow(offset, shadow->blur(), shadow->color(),
+            drawLooper.addShadow(offset, shadow->blur(), renderer->resolveColor(shadow->color()),
                 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha);
         } while ((shadow = shadow->next()));
         drawLooper.addUnmodifiedContent();
@@ -526,7 +528,8 @@
 
     GraphicsContext* context = paintInfo.context;
 
-    RenderStyle* styleToUse = renderer()->style(isFirstLineStyle());
+    RenderObject* rendererToUse = renderer();
+    RenderStyle* styleToUse = rendererToUse->style(isFirstLineStyle());
     
     adjustedPaintOffset.move(0, styleToUse->isHorizontalWritingMode() ? 0 : -logicalHeight());
 
@@ -549,14 +552,16 @@
     Color textStrokeColor;
     Color emphasisMarkColor;
     float textStrokeWidth = styleToUse->textStrokeWidth();
-    const ShadowData* textShadow = paintInfo.forceBlackText() ? 0 : styleToUse->textShadow();
+
+    // Text shadows are disabled when printing. http://crbug.com/258321
+    const ShadowData* textShadow = (context->printing() || paintInfo.forceBlackText()) ? 0 : styleToUse->textShadow();
 
     if (paintInfo.forceBlackText()) {
         textFillColor = Color::black;
         textStrokeColor = Color::black;
         emphasisMarkColor = Color::black;
     } else {
-        textFillColor = styleToUse->visitedDependentColor(CSSPropertyWebkitTextFillColor);
+        textFillColor = rendererToUse->resolveColor(styleToUse, CSSPropertyWebkitTextFillColor);
         
         bool forceBackgroundToWhite = false;
         if (isPrinting) {
@@ -570,13 +575,13 @@
         if (forceBackgroundToWhite)
             textFillColor = correctedTextColor(textFillColor, Color::white);
 
-        textStrokeColor = styleToUse->visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
+        textStrokeColor = rendererToUse->resolveColor(styleToUse, CSSPropertyWebkitTextStrokeColor);
         
         // Make the text stroke color legible against a white background
         if (forceBackgroundToWhite)
             textStrokeColor = correctedTextColor(textStrokeColor, Color::white);
 
-        emphasisMarkColor = styleToUse->visitedDependentColor(CSSPropertyWebkitTextEmphasisColor);
+        emphasisMarkColor = rendererToUse->resolveColor(styleToUse, CSSPropertyWebkitTextEmphasisColor);
         
         // Make the text stroke color legible against a white background
         if (forceBackgroundToWhite)
@@ -608,7 +613,8 @@
         }
 
         if (RenderStyle* pseudoStyle = renderer()->getCachedPseudoStyle(SELECTION)) {
-            const ShadowData* shadow = paintInfo.forceBlackText() ? 0 : pseudoStyle->textShadow();
+            // Text shadows are disabled when printing. http://crbug.com/258321
+            const ShadowData* shadow = (context->printing() || paintInfo.forceBlackText()) ? 0 : pseudoStyle->textShadow();
             if (shadow != selectionShadow) {
                 if (!paintSelectedTextOnly)
                     paintSelectedTextSeparately = true;
@@ -622,7 +628,7 @@
                 selectionStrokeWidth = strokeWidth;
             }
 
-            Color stroke = paintInfo.forceBlackText() ? Color::black : pseudoStyle->visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
+            Color stroke = paintInfo.forceBlackText() ? Color::black : rendererToUse->resolveColor(pseudoStyle, CSSPropertyWebkitTextStrokeColor);
             if (stroke != selectionStrokeColor) {
                 if (!paintSelectedTextOnly)
                     paintSelectedTextSeparately = true;
@@ -668,13 +674,11 @@
     // 2. Now paint the foreground, including text and decorations like underline/overline (in quirks mode only).
     int length = m_len;
     int maximumLength;
-    String string;
+    StringView string;
     if (!combinedText) {
-        string = textRenderer()->text();
-        if (static_cast<unsigned>(length) != string.length() || m_start) {
-            ASSERT_WITH_SECURITY_IMPLICATION(static_cast<unsigned>(m_start + length) <= string.length());
-            string = string.substringSharingImpl(m_start, length);
-        }
+        string = textRenderer()->text().createView();
+        if (static_cast<unsigned>(length) != string.length() || m_start)
+            string.narrow(m_start, length);
         maximumLength = textRenderer()->textLength() - m_start;
     } else {
         combinedText->getStringToRender(m_start, string, length);
@@ -712,9 +716,10 @@
         updateGraphicsContext(context, textFillColor, textStrokeColor, textStrokeWidth);
         if (!paintSelectedTextSeparately || ePos <= sPos) {
             // FIXME: Truncate right-to-left text correctly.
-            paintTextWithShadows(context, font, textRun, nullAtom, 0, 0, length, length, textOrigin, boxRect, textShadow, textStrokeWidth > 0, isHorizontal());
-        } else
-            paintTextWithShadows(context, font, textRun, nullAtom, 0, ePos, sPos, length, textOrigin, boxRect, textShadow, textStrokeWidth > 0, isHorizontal());
+            paintTextWithShadows(context, rendererToUse, font, textRun, nullAtom, 0, 0, length, length, textOrigin, boxRect, textShadow, textStrokeWidth > 0, isHorizontal());
+        } else {
+            paintTextWithShadows(context, rendererToUse, font, textRun, nullAtom, 0, ePos, sPos, length, textOrigin, boxRect, textShadow, textStrokeWidth > 0, isHorizontal());
+        }
 
         if (!emphasisMark.isEmpty()) {
             updateGraphicsContext(context, emphasisMarkColor, textStrokeColor, textStrokeWidth);
@@ -727,9 +732,10 @@
 
             if (!paintSelectedTextSeparately || ePos <= sPos) {
                 // FIXME: Truncate right-to-left text correctly.
-                paintTextWithShadows(context, combinedText ? combinedText->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffset, 0, length, length, emphasisMarkTextOrigin, boxRect, textShadow, textStrokeWidth > 0, isHorizontal());
-            } else
-                paintTextWithShadows(context, combinedText ? combinedText->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffset, ePos, sPos, length, emphasisMarkTextOrigin, boxRect, textShadow, textStrokeWidth > 0, isHorizontal());
+                paintTextWithShadows(context, rendererToUse, combinedText ? combinedText->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffset, 0, length, length, emphasisMarkTextOrigin, boxRect, textShadow, textStrokeWidth > 0, isHorizontal());
+            } else {
+                paintTextWithShadows(context, rendererToUse, combinedText ? combinedText->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffset, ePos, sPos, length, emphasisMarkTextOrigin, boxRect, textShadow, textStrokeWidth > 0, isHorizontal());
+            }
 
             if (combinedText)
                 context->concatCTM(rotation(boxRect, Counterclockwise));
@@ -741,7 +747,7 @@
         GraphicsContextStateSaver stateSaver(*context, selectionStrokeWidth > 0);
 
         updateGraphicsContext(context, selectionFillColor, selectionStrokeColor, selectionStrokeWidth);
-        paintTextWithShadows(context, font, textRun, nullAtom, 0, sPos, ePos, length, textOrigin, boxRect, selectionShadow, selectionStrokeWidth > 0, isHorizontal());
+        paintTextWithShadows(context, rendererToUse, font, textRun, nullAtom, 0, sPos, ePos, length, textOrigin, boxRect, selectionShadow, selectionStrokeWidth > 0, isHorizontal());
         if (!emphasisMark.isEmpty()) {
             updateGraphicsContext(context, selectionEmphasisMarkColor, textStrokeColor, textStrokeWidth);
 
@@ -751,7 +757,7 @@
             if (combinedText)
                 context->concatCTM(rotation(boxRect, Clockwise));
 
-            paintTextWithShadows(context, combinedText ? combinedText->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffset, sPos, ePos, length, emphasisMarkTextOrigin, boxRect, selectionShadow, selectionStrokeWidth > 0, isHorizontal());
+            paintTextWithShadows(context, rendererToUse, combinedText ? combinedText->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffset, sPos, ePos, length, emphasisMarkTextOrigin, boxRect, selectionShadow, selectionStrokeWidth > 0, isHorizontal());
 
             if (combinedText)
                 context->concatCTM(rotation(boxRect, Counterclockwise));
@@ -853,12 +859,10 @@
     // If the text is truncated, let the thing being painted in the truncation
     // draw its own highlight.
     int length = m_truncation != cNoTruncation ? m_truncation : m_len;
-    String string = textRenderer()->text();
+    StringView string = textRenderer()->text().createView();
 
-    if (string.length() != static_cast<unsigned>(length) || m_start) {
-        ASSERT_WITH_SECURITY_IMPLICATION(static_cast<unsigned>(m_start + length) <= string.length());
-        string = string.substringSharingImpl(m_start, length);
-    }
+    if (string.length() != static_cast<unsigned>(length) || m_start)
+        string.narrow(m_start, length);
 
     BufferForAppendingHyphen charactersWithHyphen;
     bool respectHyphen = ePos == length && hasHyphen();
@@ -1496,17 +1500,17 @@
     ASSERT(textRenderer);
     ASSERT(textRenderer->text());
 
-    String string = textRenderer->text();
+    StringView string = textRenderer->text().createView();
     unsigned startPos = start();
     unsigned length = len();
 
     if (string.length() != length || startPos)
-        string = string.substringSharingImpl(startPos, length);
+        string.narrow(startPos, length);
 
     return constructTextRun(style, font, string, textRenderer->textLength() - startPos, charactersWithHyphen);
 }
 
-TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, String string, int maximumLength, BufferForAppendingHyphen* charactersWithHyphen) const
+TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, StringView string, int maximumLength, BufferForAppendingHyphen* charactersWithHyphen) const
 {
     ASSERT(style);
 
diff --git a/Source/core/rendering/InlineTextBox.h b/Source/core/rendering/InlineTextBox.h
index 78b5038..cdfa3b0 100644
--- a/Source/core/rendering/InlineTextBox.h
+++ b/Source/core/rendering/InlineTextBox.h
@@ -108,7 +108,7 @@
     LayoutUnit selectionHeight();
 
     TextRun constructTextRun(RenderStyle*, const Font&, BufferForAppendingHyphen* = 0) const;
-    TextRun constructTextRun(RenderStyle*, const Font&, String, int maximumLength, BufferForAppendingHyphen* = 0) const;
+    TextRun constructTextRun(RenderStyle*, const Font&, StringView, int maximumLength, BufferForAppendingHyphen* = 0) const;
 
 public:
     virtual FloatRect calculateBoundaries() const { return FloatRect(x(), y(), width(), height()); }
diff --git a/Source/core/rendering/OrderIterator.cpp b/Source/core/rendering/OrderIterator.cpp
index d55779c..4d19918 100644
--- a/Source/core/rendering/OrderIterator.cpp
+++ b/Source/core/rendering/OrderIterator.cpp
@@ -38,7 +38,8 @@
 OrderIterator::OrderIterator(const RenderBox* containerBox)
     : m_containerBox(containerBox)
     , m_currentChild(0)
-    , m_orderValuesIterator(0)
+    , m_currentOrderIndex(0)
+    , m_currentChildIndex(0)
 {
 }
 
@@ -50,73 +51,60 @@
 
 RenderBox* OrderIterator::next()
 {
-    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();
+    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;
         }
-    } 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;
-    m_orderValuesIterator = 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();
 }
 
 OrderIteratorPopulator::~OrderIteratorPopulator()
 {
     m_iterator.reset();
 
-    if (m_anyChildHasDefaultOrderValue)
-        m_iterator.m_orderValues.append(0);
-
-    if (m_iterator.m_orderValues.size() > 1)
-        removeDuplicatedOrderValues();
+    std::sort(m_iterator.m_orderValues.begin(), m_iterator.m_orderValues.end());
 
     // Ensure that we release any extra memory we hold onto.
     m_iterator.m_orderValues.shrinkToFit();
 }
 
-void OrderIteratorPopulator::removeDuplicatedOrderValues()
+void OrderIteratorPopulator::collectChild(RenderBox* child)
 {
-    OrderIterator::OrderValues& orderValues = m_iterator.m_orderValues;
+    int order = child->style()->order();
 
-    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())
+    // 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)
         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 8639bdc..ad1f795 100644
--- a/Source/core/rendering/OrderIterator.h
+++ b/Source/core/rendering/OrderIterator.h
@@ -31,6 +31,7 @@
 #ifndef OrderIterator_h
 #define OrderIterator_h
 
+#include "wtf/HashMap.h"
 #include "wtf/Noncopyable.h"
 #include "wtf/Vector.h"
 
@@ -38,6 +39,16 @@
 
 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:
@@ -50,36 +61,39 @@
     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;
-    Vector<int>::const_iterator m_orderValuesIterator;
+
+    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;
 };
 
 class OrderIteratorPopulator {
 public:
     OrderIteratorPopulator(OrderIterator& iterator)
         : m_iterator(iterator)
-        , m_anyChildHasDefaultOrderValue(false)
     {
-        // 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);
+        m_iterator.invalidate();
     }
 
     ~OrderIteratorPopulator();
 
-    void collectChild(const RenderBox*);
+    void collectChild(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 f535ada..3304856 100644
--- a/Source/core/rendering/RenderBlock.cpp
+++ b/Source/core/rendering/RenderBlock.cpp
@@ -2961,7 +2961,7 @@
     if (paintInfo.context->paintingDisabled())
         return;
 
-    const Color& ruleColor = style()->visitedDependentColor(CSSPropertyWebkitColumnRuleColor);
+    const Color& ruleColor = resolveColor(CSSPropertyWebkitColumnRuleColor);
     bool ruleTransparent = style()->columnRuleIsTransparent();
     EBorderStyle ruleStyle = style()->columnRuleStyle();
     LayoutUnit ruleThickness = style()->columnRuleWidth();
@@ -7340,6 +7340,22 @@
         inlineElementContinuation()->addFocusRingRects(rects, flooredLayoutPoint(additionalOffset + inlineElementContinuation()->containingBlock()->location() - location()), paintContainer);
 }
 
+void RenderBlock::computeSelfHitTestRects(Vector<LayoutRect>& rects, const LayoutPoint& layerOffset) const
+{
+    RenderBox::computeSelfHitTestRects(rects, layerOffset);
+
+    if (hasHorizontalLayoutOverflow() || hasVerticalLayoutOverflow()) {
+        for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) {
+            LayoutUnit top = max<LayoutUnit>(curr->lineTop(), curr->top());
+            LayoutUnit bottom = min<LayoutUnit>(curr->lineBottom(), curr->top() + curr->height());
+            LayoutRect rect(layerOffset.x() + curr->x(), layerOffset.y() + top, curr->width(), bottom - top);
+            // It's common for this rect to be entirely contained in our box, so exclude that simple case.
+            if (!rect.isEmpty() && (rects.isEmpty() || !rects[0].contains(rect)))
+                rects.append(rect);
+        }
+    }
+}
+
 RenderBox* RenderBlock::createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const
 {
     if (isAnonymousColumnsBlock())
diff --git a/Source/core/rendering/RenderBlock.h b/Source/core/rendering/RenderBlock.h
index 52fcaf6..c9d5442 100644
--- a/Source/core/rendering/RenderBlock.h
+++ b/Source/core/rendering/RenderBlock.h
@@ -568,6 +568,8 @@
 
     virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) OVERRIDE;
 
+    virtual void computeSelfHitTestRects(Vector<LayoutRect>&, const LayoutPoint& layerOffset) const OVERRIDE;
+
     // Only used by RenderSVGText, which explicitly overrides RenderBlock::layoutBlock(), do NOT use for anything else.
     void forceLayoutInlineChildren()
     {
diff --git a/Source/core/rendering/RenderBlockLineLayout.cpp b/Source/core/rendering/RenderBlockLineLayout.cpp
index b3bf851..22231b7 100644
--- a/Source/core/rendering/RenderBlockLineLayout.cpp
+++ b/Source/core/rendering/RenderBlockLineLayout.cpp
@@ -2478,7 +2478,7 @@
     if (prefixLength < minimumPrefixLength)
         return;
 
-    prefixLength = lastHyphenLocation(text->bloatedCharacters() + lastSpace, pos - lastSpace, min(prefixLength, pos - lastSpace - minimumSuffixLength) + 1, localeIdentifier);
+    prefixLength = lastHyphenLocation(text->substring(lastSpace, pos - lastSpace), min(prefixLength, pos - lastSpace - minimumSuffixLength) + 1, localeIdentifier);
     if (!prefixLength || prefixLength < minimumPrefixLength)
         return;
 
diff --git a/Source/core/rendering/RenderBox.cpp b/Source/core/rendering/RenderBox.cpp
index 30e8eb9..f631c5c 100644
--- a/Source/core/rendering/RenderBox.cpp
+++ b/Source/core/rendering/RenderBox.cpp
@@ -580,6 +580,18 @@
         rects.append(pixelSnappedIntRect(additionalOffset, size()));
 }
 
+void RenderBox::addLayerHitTestRects(LayerHitTestRects& layerRects, const RenderLayer* currentLayer, const LayoutPoint& layerOffset) const
+{
+    LayoutPoint adjustedLayerOffset = layerOffset + locationOffset();
+    RenderBoxModelObject::addLayerHitTestRects(layerRects, currentLayer, adjustedLayerOffset);
+}
+
+void RenderBox::computeSelfHitTestRects(Vector<LayoutRect>& rects, const LayoutPoint& layerOffset) const
+{
+    if (!size().isEmpty())
+        rects.append(LayoutRect(layerOffset, size()));
+}
+
 LayoutRect RenderBox::reflectionBox() const
 {
     LayoutRect result;
@@ -1052,7 +1064,7 @@
     RenderObject* rootBackgroundRenderer = rendererForRootBackground();
     
     const FillLayer* bgLayer = rootBackgroundRenderer->style()->backgroundLayers();
-    Color bgColor = rootBackgroundRenderer->style()->visitedDependentColor(CSSPropertyBackgroundColor);
+    Color bgColor = rootBackgroundRenderer->resolveColor(CSSPropertyBackgroundColor);
 
     paintFillLayers(paintInfo, bgColor, bgLayer, view()->backgroundRect(this), BackgroundBleedNone, CompositeSourceOver, rootBackgroundRenderer);
 }
@@ -1151,7 +1163,7 @@
         return;
     if (backgroundIsKnownToBeObscured())
         return;
-    paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), paintRect, bleedAvoidance);
+    paintFillLayers(paintInfo, resolveColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), paintRect, bleedAvoidance);
 }
 
 LayoutRect RenderBox::backgroundPaintedExtent() const
@@ -1159,7 +1171,7 @@
     ASSERT(hasBackground());
     LayoutRect backgroundRect = pixelSnappedIntRect(borderBoxRect());
 
-    Color backgroundColor = style()->visitedDependentColor(CSSPropertyBackgroundColor);
+    Color backgroundColor = resolveColor(CSSPropertyBackgroundColor);
     if (backgroundColor.isValid() && backgroundColor.alpha())
         return backgroundRect;
     if (!style()->backgroundLayers()->image() || style()->backgroundLayers()->next())
@@ -1174,7 +1186,7 @@
     if (isBody() && skipBodyBackground(this))
         return false;
 
-    Color backgroundColor = style()->visitedDependentColor(CSSPropertyBackgroundColor);
+    Color backgroundColor = resolveColor(CSSPropertyBackgroundColor);
     if (!backgroundColor.isValid() || backgroundColor.hasAlpha())
         return false;
 
@@ -1292,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 = style()->visitedDependentColor(CSSPropertyBackgroundColor);
+        Color bgColor = resolveColor(CSSPropertyBackgroundColor);
         if (bgColor.isValid() && bgColor.alpha() == 255)
             return true;
     }
@@ -2744,7 +2756,7 @@
             return adjustContentBoxLogicalWidthForBoxSizing(valueForLength(logicalWidth, 0, view()));
         case FitContent:
         case FillAvailable:
-        case Percent: 
+        case Percent:
         case Calculated: {
             // FIXME: containingBlockLogicalWidthForContent() is wrong if the replaced element's block-flow is perpendicular to the
             // containing block's block-flow.
@@ -2763,6 +2775,7 @@
         case MinIntrinsic:
         case Auto:
         case Relative:
+        case ExtendToZoom:
         case Undefined:
             return intrinsicLogicalWidth();
     }
diff --git a/Source/core/rendering/RenderBox.h b/Source/core/rendering/RenderBox.h
index bc62793..ad38279 100644
--- a/Source/core/rendering/RenderBox.h
+++ b/Source/core/rendering/RenderBox.h
@@ -615,7 +615,10 @@
     void paintRootBoxFillLayers(const PaintInfo&);
 
     RenderObject* splitAnonymousBoxesAroundChild(RenderObject* beforeChild);
- 
+
+    virtual void addLayerHitTestRects(LayerHitTestRects&, const RenderLayer* currentCompositedLayer, const LayoutPoint& layerOffset) const OVERRIDE;
+    virtual void computeSelfHitTestRects(Vector<LayoutRect>&, const LayoutPoint& layerOffset) const OVERRIDE;
+
 private:
     void updateShapeOutsideInfoAfterStyleChange(const ShapeValue* shapeOutside, const ShapeValue* oldShapeOutside);
 
diff --git a/Source/core/rendering/RenderBoxModelObject.cpp b/Source/core/rendering/RenderBoxModelObject.cpp
index 809d44c..ff4cf63 100644
--- a/Source/core/rendering/RenderBoxModelObject.cpp
+++ b/Source/core/rendering/RenderBoxModelObject.cpp
@@ -509,14 +509,14 @@
     return getBackgroundRoundedRect(borderRect, box, boxSize.width(), boxSize.height(), includeLogicalLeftEdge, includeLogicalRightEdge);
 }
 
-static void applyBoxShadowForBackground(GraphicsContext* context, RenderStyle* style)
+static void applyBoxShadowForBackground(GraphicsContext* context, const RenderObject* renderer)
 {
-    const ShadowData* boxShadow = style->boxShadow();
+    const ShadowData* boxShadow = renderer->style()->boxShadow();
     while (boxShadow->style() != Normal)
         boxShadow = boxShadow->next();
 
     FloatSize shadowOffset(boxShadow->x(), boxShadow->y());
-    context->setShadow(shadowOffset, boxShadow->blur(), boxShadow->color(),
+    context->setShadow(shadowOffset, boxShadow->blur(), renderer->resolveColor(boxShadow->color()),
         DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha);
 }
 
@@ -573,7 +573,7 @@
         bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppliedToBackground(bleedAvoidance, box);
         GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShouldBeAppliedToBackground);
         if (boxShadowShouldBeAppliedToBackground)
-            applyBoxShadowForBackground(context, style());
+            applyBoxShadowForBackground(context, this);
 
         if (hasRoundedBorder && bleedAvoidance != BackgroundBleedUseTransparencyLayer) {
             RoundedRect border = backgroundRoundedRectAdjustedForBleedAvoidance(context, rect, bleedAvoidance, box, boxSize, includeLeftEdge, includeRightEdge);
@@ -717,7 +717,7 @@
 
             GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShouldBeAppliedToBackground);
             if (boxShadowShouldBeAppliedToBackground)
-                applyBoxShadowForBackground(context, style());
+                applyBoxShadowForBackground(context, this);
 
             if (baseColor.alpha()) {
                 if (bgColor.alpha())
@@ -1784,7 +1784,7 @@
                 path.addRoundedRect(innerBorder);
             else
                 path.addRect(innerBorder.rect());
-            
+
             graphicsContext->setFillRule(RULE_EVENODD);
             graphicsContext->setFillColor(edges[firstVisibleEdge].color);
             graphicsContext->fillPath(path);
@@ -2289,25 +2289,25 @@
     bool horizontal = style->isHorizontalWritingMode();
 
     edges[BSTop] = BorderEdge(style->borderTopWidth(),
-        style->visitedDependentColor(CSSPropertyBorderTopColor),
+        resolveColor(style, CSSPropertyBorderTopColor),
         style->borderTopStyle(),
         style->borderTopIsTransparent(),
         horizontal || includeLogicalLeftEdge);
 
     edges[BSRight] = BorderEdge(style->borderRightWidth(),
-        style->visitedDependentColor(CSSPropertyBorderRightColor),
+        resolveColor(style, CSSPropertyBorderRightColor),
         style->borderRightStyle(),
         style->borderRightIsTransparent(),
         !horizontal || includeLogicalRightEdge);
 
     edges[BSBottom] = BorderEdge(style->borderBottomWidth(),
-        style->visitedDependentColor(CSSPropertyBorderBottomColor),
+        resolveColor(style, CSSPropertyBorderBottomColor),
         style->borderBottomStyle(),
         style->borderBottomIsTransparent(),
         horizontal || includeLogicalRightEdge);
 
     edges[BSLeft] = BorderEdge(style->borderLeftWidth(),
-        style->visitedDependentColor(CSSPropertyBorderLeftColor),
+        resolveColor(style, CSSPropertyBorderLeftColor),
         style->borderLeftStyle(),
         style->borderLeftIsTransparent(),
         !horizontal || includeLogicalLeftEdge);
@@ -2374,7 +2374,7 @@
     if (!hasOneNormalBoxShadow)
         return false;
 
-    Color backgroundColor = style()->visitedDependentColor(CSSPropertyBackgroundColor);
+    Color backgroundColor = resolveColor(CSSPropertyBackgroundColor);
     if (!backgroundColor.isValid() || backgroundColor.hasAlpha())
         return false;
 
@@ -2436,7 +2436,7 @@
         if (shadowOffset.isZero() && !shadowBlur && !shadowSpread)
             continue;
         
-        const Color& shadowColor = shadow->color();
+        const Color& shadowColor = resolveColor(shadow->color());
 
         if (shadow->style() == Normal) {
             RoundedRect fillRect = border;
@@ -2543,6 +2543,18 @@
     }
 }
 
+void RenderBoxModelObject::computeLayerHitTestRects(LayerHitTestRects& rects) const
+{
+    RenderLayerModelObject::computeLayerHitTestRects(rects);
+
+    // If there is a continuation then we need to consult it here, since this is
+    // the root of the tree walk and it wouldn't otherwise get picked up.
+    // Continuations should always be siblings in the tree, so any others should
+    // get picked up already by the tree walk.
+    if (continuation())
+        continuation()->computeLayerHitTestRects(rects);
+}
+
 RenderObject* RenderBoxModelObject::firstLetterRemainingText() const
 {
     if (!firstLetterRemainingTextMap)
diff --git a/Source/core/rendering/RenderBoxModelObject.h b/Source/core/rendering/RenderBoxModelObject.h
index 1cdeee1..21b6ab9 100644
--- a/Source/core/rendering/RenderBoxModelObject.h
+++ b/Source/core/rendering/RenderBoxModelObject.h
@@ -187,6 +187,8 @@
 
     void suspendAnimations(double time = 0);
 
+    virtual void computeLayerHitTestRects(LayerHitTestRects&) const OVERRIDE;
+
 protected:
     virtual void willBeDestroyed();
 
diff --git a/Source/core/rendering/RenderCombineText.cpp b/Source/core/rendering/RenderCombineText.cpp
index 8392d0a..b8f1cf1 100644
--- a/Source/core/rendering/RenderCombineText.cpp
+++ b/Source/core/rendering/RenderCombineText.cpp
@@ -72,17 +72,16 @@
         textOrigin.move(boxRect.height() / 2 - ceilf(m_combinedTextWidth) / 2, style()->font().pixelSize());
 }
 
-void RenderCombineText::getStringToRender(int start, String& string, int& length) const
+void RenderCombineText::getStringToRender(int start, StringView& string, int& length) const
 {
     ASSERT(start >= 0);
     if (m_isCombined) {
-        string = originalText();
+        string = StringView(originalText());
         length = string.length();
         return;
     }
- 
-    string = text();
-    string = string.substringSharingImpl(static_cast<unsigned>(start), length);
+
+    string = text().createView(start, length);
 }
 
 void RenderCombineText::combineText()
diff --git a/Source/core/rendering/RenderCombineText.h b/Source/core/rendering/RenderCombineText.h
index c53d6df..1850708 100644
--- a/Source/core/rendering/RenderCombineText.h
+++ b/Source/core/rendering/RenderCombineText.h
@@ -32,7 +32,7 @@
 
     void combineText();
     void adjustTextOrigin(FloatPoint& textOrigin, const FloatRect& boxRect) const;
-    void getStringToRender(int, String& string, int& length) const;
+    void getStringToRender(int, StringView&, int& length) const;
     bool isCombined() const { return m_isCombined; }
     float combinedTextWidth(const Font& font) const { return font.size(); }
     const Font& originalFont() const { return parent()->style()->font(); }
diff --git a/Source/core/rendering/RenderDetailsMarker.cpp b/Source/core/rendering/RenderDetailsMarker.cpp
index 308defb..b6ab9a2 100644
--- a/Source/core/rendering/RenderDetailsMarker.cpp
+++ b/Source/core/rendering/RenderDetailsMarker.cpp
@@ -126,7 +126,7 @@
     if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect)))
         return;
 
-    const Color color(style()->visitedDependentColor(CSSPropertyColor));
+    const Color color(resolveColor(CSSPropertyColor));
     paintInfo.context->setStrokeColor(color);
     paintInfo.context->setStrokeStyle(SolidStroke);
     paintInfo.context->setStrokeThickness(1.0f);
diff --git a/Source/core/rendering/RenderFieldset.cpp b/Source/core/rendering/RenderFieldset.cpp
index 17fd5dc..7c01b0e 100644
--- a/Source/core/rendering/RenderFieldset.cpp
+++ b/Source/core/rendering/RenderFieldset.cpp
@@ -160,7 +160,7 @@
 
     if (!boxShadowShouldBeAppliedToBackground(determineBackgroundBleedAvoidance(paintInfo.context)))
         paintBoxShadow(paintInfo, paintRect, style(), Normal);
-    paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), paintRect);
+    paintFillLayers(paintInfo, resolveColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), paintRect);
     paintBoxShadow(paintInfo, paintRect, style(), Inset);
 
     if (!style()->hasBorder())
diff --git a/Source/core/rendering/RenderFileUploadControl.cpp b/Source/core/rendering/RenderFileUploadControl.cpp
index 09fdd9c..ff4e5f1 100644
--- a/Source/core/rendering/RenderFileUploadControl.cpp
+++ b/Source/core/rendering/RenderFileUploadControl.cpp
@@ -149,7 +149,7 @@
                                             textWidth,
                                             style()->fontMetrics().height());
 
-        paintInfo.context->setFillColor(style()->visitedDependentColor(CSSPropertyColor));
+        paintInfo.context->setFillColor(resolveColor(CSSPropertyColor));
 
         // Draw the filename
         paintInfo.context->drawBidiText(font, textRunPaintInfo, IntPoint(roundToInt(textX), roundToInt(textY)));
diff --git a/Source/core/rendering/RenderFlexibleBox.cpp b/Source/core/rendering/RenderFlexibleBox.cpp
index d1c9cfc..62f6d97 100644
--- a/Source/core/rendering/RenderFlexibleBox.cpp
+++ b/Source/core/rendering/RenderFlexibleBox.cpp
@@ -265,6 +265,13 @@
     }
 }
 
+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 3d5fc26..a1c21be 100644
--- a/Source/core/rendering/RenderFlexibleBox.h
+++ b/Source/core/rendering/RenderFlexibleBox.h
@@ -64,6 +64,8 @@
 
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
 
+    virtual void removeChild(RenderObject* child) OVERRIDE;
+
 private:
     enum FlexSign {
         PositiveFlexibility,
diff --git a/Source/core/rendering/RenderFrameSet.cpp b/Source/core/rendering/RenderFrameSet.cpp
index 7de277c..eeedd85 100644
--- a/Source/core/rendering/RenderFrameSet.cpp
+++ b/Source/core/rendering/RenderFrameSet.cpp
@@ -27,6 +27,7 @@
 #include "core/dom/Document.h"
 #include "core/dom/EventNames.h"
 #include "core/dom/MouseEvent.h"
+#include "core/html/HTMLDimension.h"
 #include "core/html/HTMLFrameSetElement.h"
 #include "core/page/EventHandler.h"
 #include "core/page/Frame.h"
@@ -84,7 +85,7 @@
 
     // Fill first.
     GraphicsContext* context = paintInfo.context;
-    context->fillRect(borderRect, frameSet()->hasBorderColor() ? style()->visitedDependentColor(CSSPropertyBorderLeftColor) : borderFillColor());
+    context->fillRect(borderRect, frameSet()->hasBorderColor() ? resolveColor(CSSPropertyBorderLeftColor) : borderFillColor());
 
     // Now stroke the edges but only if we have enough room to paint both edges with a little
     // bit of the fill color showing through.
@@ -103,7 +104,7 @@
 
     // Fill first.
     GraphicsContext* context = paintInfo.context;
-    context->fillRect(borderRect, frameSet()->hasBorderColor() ? style()->visitedDependentColor(CSSPropertyBorderLeftColor) : borderFillColor());
+    context->fillRect(borderRect, frameSet()->hasBorderColor() ? resolveColor(CSSPropertyBorderLeftColor) : borderFillColor());
 
     // Now stroke the edges but only if we have enough room to paint both edges with a little
     // bit of the fill color showing through.
@@ -165,7 +166,7 @@
     m_allowBorder.resize(size + 1);
 }
 
-void RenderFrameSet::layOutAxis(GridAxis& axis, const Vector<Length>& grid, int availableLen)
+void RenderFrameSet::layOutAxis(GridAxis& axis, const Vector<HTMLDimension>& grid, int availableLen)
 {
     availableLen = max(availableLen, 0);
 
@@ -191,16 +192,16 @@
     for (int i = 0; i < gridLen; ++i) {
         // Count the total length of all of the fixed columns/rows -> totalFixed
         // Count the number of columns/rows which are fixed -> countFixed
-        if (grid[i].isFixed()) {
-            gridLayout[i] = max(grid[i].intValue(), 0);
+        if (grid[i].isAbsolute()) {
+            gridLayout[i] = max<int>(grid[i].value(), 0);
             totalFixed += gridLayout[i];
             countFixed++;
         }
         
         // Count the total percentage of all of the percentage columns/rows -> totalPercent
         // Count the number of columns/rows which are percentages -> countPercent
-        if (grid[i].isPercent()) {
-            gridLayout[i] = max(intValueForLength(grid[i], availableLen), 0);
+        if (grid[i].isPercentage()) {
+            gridLayout[i] = max<int>(grid[i].value() * availableLen / 100., 0);
             totalPercent += gridLayout[i];
             countPercent++;
         }
@@ -208,7 +209,7 @@
         // Count the total relative of all the relative columns/rows -> totalRelative
         // Count the number of columns/rows which are relative -> countRelative
         if (grid[i].isRelative()) {
-            totalRelative += max(grid[i].intValue(), 1);
+            totalRelative += max<int>(grid[i].value(), 1);
             countRelative++;
         }            
     }
@@ -221,7 +222,7 @@
         int remainingFixed = remainingLen;
 
         for (int i = 0; i < gridLen; ++i) {
-            if (grid[i].isFixed()) {
+            if (grid[i].isAbsolute()) {
                 gridLayout[i] = (gridLayout[i] * remainingFixed) / totalFixed;
                 remainingLen -= gridLayout[i];
             }
@@ -237,7 +238,7 @@
         int remainingPercent = remainingLen;
 
         for (int i = 0; i < gridLen; ++i) {
-            if (grid[i].isPercent()) {
+            if (grid[i].isPercentage()) {
                 gridLayout[i] = (gridLayout[i] * remainingPercent) / totalPercent;
                 remainingLen -= gridLayout[i];
             }
@@ -253,7 +254,7 @@
 
         for (int i = 0; i < gridLen; ++i) {
             if (grid[i].isRelative()) {
-                gridLayout[i] = (max(grid[i].intValue(), 1) * remainingRelative) / totalRelative;
+                gridLayout[i] = (max(grid[i].value(), 1.) * remainingRelative) / totalRelative;
                 remainingLen -= gridLayout[i];
                 lastRelative = i;
             }
@@ -281,7 +282,7 @@
             int changePercent = 0;
 
             for (int i = 0; i < gridLen; ++i) {
-                if (grid[i].isPercent()) {
+                if (grid[i].isPercentage()) {
                     changePercent = (remainingPercent * gridLayout[i]) / totalPercent;
                     gridLayout[i] += changePercent;
                     remainingLen -= changePercent;
@@ -295,7 +296,7 @@
             int changeFixed = 0;
 
             for (int i = 0; i < gridLen; ++i) {
-                if (grid[i].isFixed()) {
+                if (grid[i].isAbsolute()) {
                     changeFixed = (remainingFixed * gridLayout[i]) / totalFixed;
                     gridLayout[i] += changeFixed;
                     remainingLen -= changeFixed;
@@ -313,7 +314,7 @@
         int changePercent = 0;
 
         for (int i = 0; i < gridLen; ++i) {
-            if (grid[i].isPercent()) {
+            if (grid[i].isPercentage()) {
                 changePercent = remainingPercent / countPercent;
                 gridLayout[i] += changePercent;
                 remainingLen -= changePercent;
@@ -327,7 +328,7 @@
         int changeFixed = 0;
         
         for (int i = 0; i < gridLen; ++i) {
-            if (grid[i].isFixed()) {
+            if (grid[i].isAbsolute()) {
                 changeFixed = remainingFixed / countFixed;
                 gridLayout[i] += changeFixed;
                 remainingLen -= changeFixed;
diff --git a/Source/core/rendering/RenderFrameSet.h b/Source/core/rendering/RenderFrameSet.h
index 42c487f..b4a9a51 100644
--- a/Source/core/rendering/RenderFrameSet.h
+++ b/Source/core/rendering/RenderFrameSet.h
@@ -27,6 +27,7 @@
 
 namespace WebCore {
 
+class HTMLDimension;
 class HTMLFrameSetElement;
 class MouseEvent;
 class RenderFrame;
@@ -108,7 +109,7 @@
 
     void setIsResizing(bool);
 
-    void layOutAxis(GridAxis&, const Vector<Length>&, int availableSpace);
+    void layOutAxis(GridAxis&, const Vector<HTMLDimension>&, int availableSpace);
     void computeEdgeInfo();
     void fillFromEdgeInfo(const FrameEdgeInfo& edgeInfo, int r, int c);
     void positionFrames();
diff --git a/Source/core/rendering/RenderGrid.cpp b/Source/core/rendering/RenderGrid.cpp
index b1e8312..a93d2f8 100644
--- a/Source/core/rendering/RenderGrid.cpp
+++ b/Source/core/rendering/RenderGrid.cpp
@@ -252,6 +252,13 @@
     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())
diff --git a/Source/core/rendering/RenderGrid.h b/Source/core/rendering/RenderGrid.h
index eddf270..894f4f5 100644
--- a/Source/core/rendering/RenderGrid.h
+++ b/Source/core/rendering/RenderGrid.h
@@ -59,6 +59,8 @@
     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/RenderImage.cpp b/Source/core/rendering/RenderImage.cpp
index 25f505f..ef689ce 100644
--- a/Source/core/rendering/RenderImage.cpp
+++ b/Source/core/rendering/RenderImage.cpp
@@ -346,7 +346,7 @@
                 LayoutUnit textWidth = font.width(textRun);
                 TextRunPaintInfo textRunPaintInfo(textRun);
                 textRunPaintInfo.bounds = FloatRect(textRectOrigin, FloatSize(textWidth, fontMetrics.height()));
-                context->setFillColor(style()->visitedDependentColor(CSSPropertyColor));
+                context->setFillColor(resolveColor(CSSPropertyColor));
                 if (errorPictureDrawn) {
                     if (usableWidth >= textWidth && fontMetrics.height() <= imageOffset.height())
                         context->drawText(font, textRunPaintInfo, textOrigin);
@@ -396,11 +396,11 @@
     if (paintInfo.context->paintingDisabled() && !paintInfo.context->updatingControlTints())
         return;
 
-    Node* focusedNode = document->focusedNode();
-    if (!focusedNode || !isHTMLAreaElement(focusedNode))
+    Element* focusedElement = document->focusedElement();
+    if (!focusedElement || !isHTMLAreaElement(focusedElement))
         return;
 
-    HTMLAreaElement* areaElement = toHTMLAreaElement(focusedNode);
+    HTMLAreaElement* areaElement = toHTMLAreaElement(focusedElement);
     if (areaElement->imageElement() != node())
         return;
 
@@ -421,7 +421,7 @@
     paintInfo.context->clip(absoluteContentBox());
     paintInfo.context->drawFocusRing(path, outlineWidth,
         areaElementStyle->outlineOffset(),
-        areaElementStyle->visitedDependentColor(CSSPropertyOutlineColor));
+        resolveColor(areaElementStyle, CSSPropertyOutlineColor));
 }
 
 void RenderImage::areaElementFocusChanged(HTMLAreaElement* areaElement)
diff --git a/Source/core/rendering/RenderInline.cpp b/Source/core/rendering/RenderInline.cpp
index 81a8bdc..a852eb0 100644
--- a/Source/core/rendering/RenderInline.cpp
+++ b/Source/core/rendering/RenderInline.cpp
@@ -1383,6 +1383,33 @@
     }
 }
 
+namespace {
+
+class AbsoluteLayoutRectsGeneratorContext {
+public:
+    AbsoluteLayoutRectsGeneratorContext(Vector<LayoutRect>& rects, const LayoutPoint& accumulatedOffset)
+        : m_rects(rects)
+        , m_accumulatedOffset(accumulatedOffset) { }
+
+    void operator()(const FloatRect& rect)
+    {
+        LayoutRect layoutRect(rect);
+        layoutRect.move(m_accumulatedOffset.x(), m_accumulatedOffset.y());
+        m_rects.append(layoutRect);
+    }
+private:
+    Vector<LayoutRect>& m_rects;
+    const LayoutPoint& m_accumulatedOffset;
+};
+
+}
+
+void RenderInline::computeSelfHitTestRects(Vector<LayoutRect>& rects, const LayoutPoint& layerOffset) const
+{
+    AbsoluteLayoutRectsGeneratorContext context(rects, layerOffset);
+    generateLineBoxRects(context);
+}
+
 void RenderInline::paintOutline(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
     if (!hasOutline())
@@ -1414,7 +1441,7 @@
     }
     rects.append(LayoutRect());
 
-    Color outlineColor = styleToUse->visitedDependentColor(CSSPropertyOutlineColor);
+    Color outlineColor = resolveColor(styleToUse, CSSPropertyOutlineColor);
     bool useTransparencyLayer = outlineColor.hasAlpha();
     if (useTransparencyLayer) {
         graphicsContext->beginTransparencyLayer(static_cast<float>(outlineColor.alpha()) / 255);
diff --git a/Source/core/rendering/RenderInline.h b/Source/core/rendering/RenderInline.h
index 95f52ef..49ab4ca 100644
--- a/Source/core/rendering/RenderInline.h
+++ b/Source/core/rendering/RenderInline.h
@@ -100,6 +100,8 @@
 
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
 
+    virtual void computeSelfHitTestRects(Vector<LayoutRect>& rects, const LayoutPoint& layerOffset) const OVERRIDE;
+
 private:
     virtual RenderObjectChildList* virtualChildren() OVERRIDE FINAL { return children(); }
     virtual const RenderObjectChildList* virtualChildren() const OVERRIDE FINAL { return children(); }
diff --git a/Source/core/rendering/RenderLayer.cpp b/Source/core/rendering/RenderLayer.cpp
index e5efa4b..04e4a26 100644
--- a/Source/core/rendering/RenderLayer.cpp
+++ b/Source/core/rendering/RenderLayer.cpp
@@ -2128,7 +2128,7 @@
     m_scrollOffset = toIntSize(newScrollOffset);
 
     Frame* frame = renderer()->frame();
-    InspectorInstrumentation::willScrollLayer(frame);
+    InspectorInstrumentation::willScrollLayer(renderer());
 
     RenderView* view = renderer()->view();
     
@@ -2177,13 +2177,13 @@
     if (renderer()->node())
         renderer()->node()->document()->eventQueue()->enqueueOrDispatchScrollEvent(renderer()->node(), DocumentEventQueue::ScrollEventElementTarget);
 
-    InspectorInstrumentation::didScrollLayer(frame);
+    InspectorInstrumentation::didScrollLayer(renderer());
 }
 
-static inline bool frameElementAndViewPermitScroll(HTMLFrameElement* frameElement, FrameView* frameView) 
+static inline bool frameElementAndViewPermitScroll(HTMLFrameElementBase* frameElementBase, FrameView* frameView)
 {
     // If scrollbars aren't explicitly forbidden, permit scrolling.
-    if (frameElement && frameElement->scrollingMode() != ScrollbarAlwaysOff)
+    if (frameElementBase && frameElementBase->scrollingMode() != ScrollbarAlwaysOff)
         return true;
 
     // If scrollbars are forbidden, user initiated scrolls should obviously be ignored.
@@ -2239,12 +2239,12 @@
                 ownerElement = renderer()->document()->ownerElement();
 
             if (ownerElement && ownerElement->renderer()) {
-                HTMLFrameElement* frameElement = 0;
+                HTMLFrameElementBase* frameElementBase = 0;
 
                 if (ownerElement->hasTagName(frameTag) || ownerElement->hasTagName(iframeTag))
-                    frameElement = static_cast<HTMLFrameElement*>(ownerElement);
+                    frameElementBase = static_cast<HTMLFrameElementBase*>(ownerElement);
 
-                if (frameElementAndViewPermitScroll(frameElement, frameView)) {
+                if (frameElementAndViewPermitScroll(frameElementBase, frameView)) {
                     LayoutRect viewRect = frameView->visibleContentRect();
                     LayoutRect exposeRect = getRectToExpose(viewRect, rect, alignX, alignY);
 
@@ -2531,34 +2531,34 @@
     return page && page->focusController()->isActive();
 }
 
-static int cornerStart(const RenderLayer* layer, int minX, int maxX, int thickness)
+static int cornerStart(const RenderStyle* style, int minX, int maxX, int thickness)
 {
-    if (layer->renderer()->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
-        return minX + layer->renderer()->style()->borderLeftWidth();
-    return maxX - thickness - layer->renderer()->style()->borderRightWidth();
+    if (style->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
+        return minX + style->borderLeftWidth();
+    return maxX - thickness - style->borderRightWidth();
 }
 
-static IntRect cornerRect(const RenderLayer* layer, const IntRect& bounds)
+static IntRect cornerRect(const RenderStyle* style, const Scrollbar* horizontalScrollbar, const Scrollbar* verticalScrollbar, const IntRect& bounds)
 {
     int horizontalThickness;
     int verticalThickness;
-    if (!layer->verticalScrollbar() && !layer->horizontalScrollbar()) {
+    if (!verticalScrollbar && !horizontalScrollbar) {
         // FIXME: This isn't right.  We need to know the thickness of custom scrollbars
         // even when they don't exist in order to set the resizer square size properly.
         horizontalThickness = ScrollbarTheme::theme()->scrollbarThickness();
         verticalThickness = horizontalThickness;
-    } else if (layer->verticalScrollbar() && !layer->horizontalScrollbar()) {
-        horizontalThickness = layer->verticalScrollbar()->width();
+    } else if (verticalScrollbar && !horizontalScrollbar) {
+        horizontalThickness = verticalScrollbar->width();
         verticalThickness = horizontalThickness;
-    } else if (layer->horizontalScrollbar() && !layer->verticalScrollbar()) {
-        verticalThickness = layer->horizontalScrollbar()->height();
+    } else if (horizontalScrollbar && !verticalScrollbar) {
+        verticalThickness = horizontalScrollbar->height();
         horizontalThickness = verticalThickness;
     } else {
-        horizontalThickness = layer->verticalScrollbar()->width();
-        verticalThickness = layer->horizontalScrollbar()->height();
+        horizontalThickness = verticalScrollbar->width();
+        verticalThickness = horizontalScrollbar->height();
     }
-    return IntRect(cornerStart(layer, bounds.x(), bounds.maxX(), horizontalThickness),
-                   bounds.maxY() - verticalThickness - layer->renderer()->style()->borderBottomWidth(),
+    return IntRect(cornerStart(style, bounds.x(), bounds.maxX(), horizontalThickness),
+                   bounds.maxY() - verticalThickness - style->borderBottomWidth(),
                    horizontalThickness, verticalThickness);
 }
 
@@ -2572,7 +2572,7 @@
     bool hasVerticalBar = verticalScrollbar();
     bool hasResizer = renderer()->style()->resize() != RESIZE_NONE;
     if ((hasHorizontalBar && hasVerticalBar) || (hasResizer && (hasHorizontalBar || hasVerticalBar)))
-        return cornerRect(this, renderBox()->pixelSnappedBorderBoxRect());
+        return cornerRect(renderer()->style(), horizontalScrollbar(), verticalScrollbar(), renderBox()->pixelSnappedBorderBoxRect());
     return IntRect();
 }
 
@@ -2581,7 +2581,7 @@
     ASSERT(renderer()->isBox());
     if (renderer()->style()->resize() == RESIZE_NONE)
         return IntRect();
-    IntRect corner = cornerRect(this, bounds);
+    IntRect corner = cornerRect(renderer()->style(), horizontalScrollbar(), verticalScrollbar(), bounds);
 
     if (resizerHitTestType == ResizerForTouch) {
         // We make the resizer virtually larger for touch hit testing. With the
@@ -3618,6 +3618,9 @@
         || (!isPaintingScrollingContent && isPaintingCompositedForeground));
     bool shouldPaintContent = m_hasVisibleContent && isSelfPaintingLayer && !isPaintingOverlayScrollbars;
 
+    float deviceScaleFactor = WebCore::deviceScaleFactor(renderer()->frame());
+    context->setUseHighResMarkers(deviceScaleFactor > 1.5f);
+
     GraphicsContext* transparencyLayerContext = context;
     
     if (localPaintFlags & PaintLayerPaintingRootBackgroundOnly && !renderer()->isRenderView() && !renderer()->isRoot())
diff --git a/Source/core/rendering/RenderLayer.h b/Source/core/rendering/RenderLayer.h
index fd9ee61..1d11d8e 100644
--- a/Source/core/rendering/RenderLayer.h
+++ b/Source/core/rendering/RenderLayer.h
@@ -1100,7 +1100,7 @@
     friend class RenderLayerCompositor;
     friend class RenderLayerModelObject;
 
-    // Only safe to call from RenderBoxModelObject::destroyLayer(RenderArena*)
+    // Only safe to call from RenderLayerModelObject::destroyLayer(RenderArena*)
     void destroy(RenderArena*);
 
     LayoutUnit overflowTop() const;
@@ -1120,68 +1120,69 @@
     // 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.
-    bool m_inResizeMode : 1;
+    unsigned m_inResizeMode : 1;
 
-    bool m_scrollDimensionsDirty : 1;
-    bool m_zOrderListsDirty : 1;
-    bool m_normalFlowListDirty: 1;
-    bool m_isNormalFlowOnly : 1;
+    unsigned m_scrollDimensionsDirty : 1;
+    unsigned m_zOrderListsDirty : 1;
+    unsigned m_normalFlowListDirty: 1;
+    unsigned m_isNormalFlowOnly : 1;
 
-    bool m_isSelfPaintingLayer : 1;
+    unsigned m_isSelfPaintingLayer : 1;
 
     // If have no self-painting descendants, we don't have to walk our children during painting. This can lead to
     // significant savings, especially if the tree has lots of non-self-painting layers grouped together (e.g. table cells).
-    bool m_hasSelfPaintingLayerDescendant : 1;
-    bool m_hasSelfPaintingLayerDescendantDirty : 1;
+    unsigned m_hasSelfPaintingLayerDescendant : 1;
+    unsigned m_hasSelfPaintingLayerDescendantDirty : 1;
 
-    bool m_hasOutOfFlowPositionedDescendant : 1;
-    bool m_hasOutOfFlowPositionedDescendantDirty : 1;
+    unsigned m_hasOutOfFlowPositionedDescendant : 1;
+    unsigned m_hasOutOfFlowPositionedDescendantDirty : 1;
 
     // This is true if we have an out-of-flow positioned descendant whose
     // containing block is our ancestor. If this is the case, the descendant
     // may fall outside of our clip preventing things like opting into
     // composited scrolling (which causes clipping of all descendants).
-    bool m_hasUnclippedDescendant : 1;
+    unsigned m_hasUnclippedDescendant : 1;
 
-    bool m_needsCompositedScrolling : 1;
+    unsigned m_needsCompositedScrolling : 1;
 
     // If this is true, then no non-descendant appears between any of our
     // descendants in stacking order. This is one of the requirements of being
     // able to safely become a stacking context.
-    bool m_canBePromotedToStackingContainer : 1;
-    bool m_canBePromotedToStackingContainerDirty : 1;
+    unsigned m_canBePromotedToStackingContainer : 1;
+    unsigned m_canBePromotedToStackingContainerDirty : 1;
 
-    const bool m_isRootLayer : 1;
+    const unsigned m_isRootLayer : 1;
 
-    bool m_usedTransparency : 1; // Tracks whether we need to close a transparent layer, i.e., whether
+    unsigned m_usedTransparency : 1; // Tracks whether we need to close a transparent layer, i.e., whether
                                  // we ended up painting this layer or any descendants (and therefore need to
                                  // blend).
-    bool m_paintingInsideReflection : 1;  // A state bit tracking if we are painting inside a replica.
-    bool m_inOverflowRelayout : 1;
+    unsigned m_paintingInsideReflection : 1; // A state bit tracking if we are painting inside a replica.
+    unsigned m_inOverflowRelayout : 1;
     unsigned m_repaintStatus : 2; // RepaintStatus
 
-    bool m_visibleContentStatusDirty : 1;
-    bool m_hasVisibleContent : 1;
-    bool m_visibleDescendantStatusDirty : 1;
-    bool m_hasVisibleDescendant : 1;
+    unsigned m_visibleContentStatusDirty : 1;
+    unsigned m_hasVisibleContent : 1;
+    unsigned m_visibleDescendantStatusDirty : 1;
+    unsigned m_hasVisibleDescendant : 1;
 
-    bool m_isPaginated : 1; // If we think this layer is split by a multi-column ancestor, then this bit will be set.
+    unsigned m_isPaginated : 1; // If we think this layer is split by a multi-column ancestor, then this bit will be set.
 
-    bool m_3DTransformedDescendantStatusDirty : 1;
-    bool m_has3DTransformedDescendant : 1;  // Set on a stacking context layer that has 3D descendants anywhere
-                                            // in a preserves3D hierarchy. Hint to do 3D-aware hit testing.
+    unsigned m_3DTransformedDescendantStatusDirty : 1;
+    // Set on a stacking context layer that has 3D descendants anywhere
+    // in a preserves3D hierarchy. Hint to do 3D-aware hit testing.
+    unsigned m_has3DTransformedDescendant : 1;
 
-    bool m_containsDirtyOverlayScrollbars : 1;
+    unsigned m_containsDirtyOverlayScrollbars : 1;
 
 #if !ASSERT_DISABLED
-    bool m_layerListMutationAllowed : 1;
+    unsigned m_layerListMutationAllowed : 1;
 #endif
     // This is an optimization added for <table>.
     // Currently cells do not need to update their repaint rectangles when scrolling. This also
     // saves a lot of time when scrolling on a table.
-    const bool m_canSkipRepaintRectsUpdateOnScroll : 1;
+    const unsigned m_canSkipRepaintRectsUpdateOnScroll : 1;
 
-    bool m_hasFilterInfo : 1;
+    unsigned m_hasFilterInfo : 1;
 
     BlendMode m_blendMode;
 
diff --git a/Source/core/rendering/RenderLayerBacking.cpp b/Source/core/rendering/RenderLayerBacking.cpp
index 7442e45..1843f66 100644
--- a/Source/core/rendering/RenderLayerBacking.cpp
+++ b/Source/core/rendering/RenderLayerBacking.cpp
@@ -1092,7 +1092,7 @@
     if (backgroundRenderer->isRoot())
         backgroundRenderer = backgroundRenderer->rendererForRootBackground();
 
-    return backgroundRenderer->style()->visitedDependentColor(CSSPropertyBackgroundColor);
+    return backgroundRenderer->resolveColor(CSSPropertyBackgroundColor);
 }
 
 void RenderLayerBacking::updateBackgroundColor(bool isSimpleContainer)
diff --git a/Source/core/rendering/RenderLayerModelObject.cpp b/Source/core/rendering/RenderLayerModelObject.cpp
index 7ec48cc..d5a20c6 100644
--- a/Source/core/rendering/RenderLayerModelObject.cpp
+++ b/Source/core/rendering/RenderLayerModelObject.cpp
@@ -182,5 +182,17 @@
     }
 }
 
+void RenderLayerModelObject::addLayerHitTestRects(LayerHitTestRects& rects, const RenderLayer* currentLayer, const LayoutPoint& layerOffset) const
+{
+    // If we have a new layer then our current layer/offset is irrelevant.
+    LayoutPoint adjustedLayerOffset = layerOffset;
+    if (hasLayer()) {
+        currentLayer = layer();
+        adjustedLayerOffset = LayoutPoint();
+    }
+
+    RenderObject::addLayerHitTestRects(rects, currentLayer, adjustedLayerOffset);
+}
+
 } // namespace WebCore
 
diff --git a/Source/core/rendering/RenderLayerModelObject.h b/Source/core/rendering/RenderLayerModelObject.h
index 6233e36..034c052 100644
--- a/Source/core/rendering/RenderLayerModelObject.h
+++ b/Source/core/rendering/RenderLayerModelObject.h
@@ -58,6 +58,8 @@
 
     virtual void willBeDestroyed() OVERRIDE;
 
+    virtual void addLayerHitTestRects(LayerHitTestRects&, const RenderLayer* = 0, const LayoutPoint& = LayoutPoint()) const OVERRIDE;
+
 private:
     virtual bool isLayerModelObject() const OVERRIDE FINAL { return true; }
 
diff --git a/Source/core/rendering/RenderListBox.cpp b/Source/core/rendering/RenderListBox.cpp
index 3841675..9ce0587 100644
--- a/Source/core/rendering/RenderListBox.cpp
+++ b/Source/core/rendering/RenderListBox.cpp
@@ -407,9 +407,9 @@
         itemText = toHTMLOptGroupElement(element)->groupLabelText();
     applyTextTransform(style(), itemText, ' ');
 
-    Color textColor = element->renderStyle() ? element->renderStyle()->visitedDependentColor(CSSPropertyColor) : style()->visitedDependentColor(CSSPropertyColor);
+    Color textColor = element->renderStyle() ? resolveColor(element->renderStyle(), CSSPropertyColor) : resolveColor(CSSPropertyColor);
     if (isOptionElement && toHTMLOptionElement(element)->selected()) {
-        if (frame()->selection()->isFocusedAndActive() && document()->focusedNode() == node())
+        if (frame()->selection()->isFocusedAndActive() && document()->focusedElement() == node())
             textColor = theme()->activeListBoxSelectionForegroundColor();
         // Honor the foreground color for disabled items
         else if (!element->isDisabledFormControl() && !select->isDisabledFormControl())
@@ -443,12 +443,13 @@
 
     Color backColor;
     if (element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected()) {
-        if (frame()->selection()->isFocusedAndActive() && document()->focusedNode() == node())
+        if (frame()->selection()->isFocusedAndActive() && document()->focusedElement() == node())
             backColor = theme()->activeListBoxSelectionBackgroundColor();
         else
             backColor = theme()->inactiveListBoxSelectionBackgroundColor();
-    } else
-        backColor = element->renderStyle() ? element->renderStyle()->visitedDependentColor(CSSPropertyBackgroundColor) : style()->visitedDependentColor(CSSPropertyBackgroundColor);
+    } else {
+        backColor = element->renderStyle() ? resolveColor(element->renderStyle(), CSSPropertyBackgroundColor) : resolveColor(CSSPropertyBackgroundColor);
+    }
 
     // Draw the background for this list box item
     if (!element->renderStyle() || element->renderStyle()->visibility() != HIDDEN) {
diff --git a/Source/core/rendering/RenderListMarker.cpp b/Source/core/rendering/RenderListMarker.cpp
index 326eaa8..2d08cbf 100644
--- a/Source/core/rendering/RenderListMarker.cpp
+++ b/Source/core/rendering/RenderListMarker.cpp
@@ -1162,7 +1162,7 @@
         context->fillRect(pixelSnappedIntRect(selRect), selectionBackgroundColor());
     }
 
-    const Color color(style()->visitedDependentColor(CSSPropertyColor));
+    const Color color(resolveColor(CSSPropertyColor));
     context->setStrokeColor(color);
     context->setStrokeStyle(SolidStroke);
     context->setStrokeThickness(1.0f);
diff --git a/Source/core/rendering/RenderMenuList.cpp b/Source/core/rendering/RenderMenuList.cpp
index 2071418..b984d7e 100644
--- a/Source/core/rendering/RenderMenuList.cpp
+++ b/Source/core/rendering/RenderMenuList.cpp
@@ -475,7 +475,7 @@
     getItemBackgroundColor(listIndex, itemBackgroundColor, itemHasCustomBackgroundColor);
 
     RenderStyle* style = element->renderStyle() ? element->renderStyle() : element->computedStyle();
-    return style ? PopupMenuStyle(style->visitedDependentColor(CSSPropertyColor), itemBackgroundColor, style->font(), style->visibility() == VISIBLE,
+    return style ? PopupMenuStyle(resolveColor(style, CSSPropertyColor), itemBackgroundColor, style->font(), style->visibility() == VISIBLE,
         style->display() == NONE, style->textIndent(), style->direction(), isOverride(style->unicodeBidi()),
         itemHasCustomBackgroundColor ? PopupMenuStyle::CustomBackgroundColor : PopupMenuStyle::DefaultBackgroundColor) : menuStyle();
 }
@@ -484,7 +484,7 @@
 {
     const Vector<HTMLElement*>& listItems = selectElement()->listItems();
     if (listIndex >= listItems.size()) {
-        itemBackgroundColor = style()->visitedDependentColor(CSSPropertyBackgroundColor);
+        itemBackgroundColor = resolveColor(CSSPropertyBackgroundColor);
         itemHasCustomBackgroundColor = false;
         return;
     }
@@ -492,7 +492,7 @@
 
     Color backgroundColor;
     if (element->renderStyle())
-        backgroundColor = element->renderStyle()->visitedDependentColor(CSSPropertyBackgroundColor);
+        backgroundColor = resolveColor(element->renderStyle(), CSSPropertyBackgroundColor);
     itemHasCustomBackgroundColor = backgroundColor.isValid() && backgroundColor.alpha();
     // If the item has an opaque background color, return that.
     if (!backgroundColor.hasAlpha()) {
@@ -501,7 +501,7 @@
     }
 
     // Otherwise, the item's background is overlayed on top of the menu background.
-    backgroundColor = style()->visitedDependentColor(CSSPropertyBackgroundColor).blend(backgroundColor);
+    backgroundColor = resolveColor(CSSPropertyBackgroundColor).blend(backgroundColor);
     if (!backgroundColor.hasAlpha()) {
         itemBackgroundColor = backgroundColor;
         return;
@@ -513,8 +513,9 @@
 
 PopupMenuStyle RenderMenuList::menuStyle() const
 {
-    RenderStyle* s = m_innerBlock ? m_innerBlock->style() : style();
-    return PopupMenuStyle(s->visitedDependentColor(CSSPropertyColor), s->visitedDependentColor(CSSPropertyBackgroundColor), s->font(), s->visibility() == VISIBLE,
+    const RenderObject* o = m_innerBlock ? m_innerBlock : this;
+    const RenderStyle* s = o->style();
+    return PopupMenuStyle(o->resolveColor(CSSPropertyColor), o->resolveColor(CSSPropertyBackgroundColor), s->font(), s->visibility() == VISIBLE,
         s->display() == NONE, s->textIndent(), style()->direction(), isOverride(style()->unicodeBidi()));
 }
 
diff --git a/Source/core/rendering/RenderMultiColumnSet.cpp b/Source/core/rendering/RenderMultiColumnSet.cpp
index 78413e4..ee87b12 100644
--- a/Source/core/rendering/RenderMultiColumnSet.cpp
+++ b/Source/core/rendering/RenderMultiColumnSet.cpp
@@ -341,7 +341,7 @@
         return;
 
     RenderStyle* blockStyle = toRenderMultiColumnBlock(parent())->style();
-    const Color& ruleColor = blockStyle->visitedDependentColor(CSSPropertyWebkitColumnRuleColor);
+    const Color& ruleColor = resolveColor(blockStyle, CSSPropertyWebkitColumnRuleColor);
     bool ruleTransparent = blockStyle->columnRuleIsTransparent();
     EBorderStyle ruleStyle = blockStyle->columnRuleStyle();
     LayoutUnit ruleThickness = blockStyle->columnRuleWidth();
diff --git a/Source/core/rendering/RenderObject.cpp b/Source/core/rendering/RenderObject.cpp
index 31a02d6..28e058a 100644
--- a/Source/core/rendering/RenderObject.cpp
+++ b/Source/core/rendering/RenderObject.cpp
@@ -28,6 +28,7 @@
 #include "core/rendering/RenderObject.h"
 
 #include "HTMLNames.h"
+#include "RuntimeEnabledFeatures.h"
 #include "core/accessibility/AXObjectCache.h"
 #include "core/css/resolver/StyleResolver.h"
 #include "core/editing/EditingBoundary.h"
@@ -1115,7 +1116,7 @@
     Vector<IntRect> focusRingRects;
     addFocusRingRects(focusRingRects, paintOffset, paintInfo.paintContainer);
     if (style->outlineStyleIsAuto())
-        paintInfo.context->drawFocusRing(focusRingRects, style->outlineWidth(), style->outlineOffset(), style->visitedDependentColor(CSSPropertyOutlineColor));
+        paintInfo.context->drawFocusRing(focusRingRects, style->outlineWidth(), style->outlineOffset(), resolveColor(style, CSSPropertyOutlineColor));
     else
         addPDFURLRect(paintInfo.context, unionRect(focusRingRects));
 }
@@ -1173,7 +1174,7 @@
         return;
 
     EBorderStyle outlineStyle = styleToUse->outlineStyle();
-    Color outlineColor = styleToUse->visitedDependentColor(CSSPropertyOutlineColor);
+    Color outlineColor = resolveColor(styleToUse, CSSPropertyOutlineColor);
 
     GraphicsContext* graphicsContext = paintInfo.context;
     bool useTransparencyLayer = outlineColor.hasAlpha();
@@ -1656,8 +1657,8 @@
     Color color;
     if (shouldUseSelectionColor(*style())) {
         RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
-        if (pseudoStyle && pseudoStyle->visitedDependentColor(CSSPropertyBackgroundColor).isValid())
-            color = pseudoStyle->visitedDependentColor(CSSPropertyBackgroundColor).blendWithWhite();
+        if (pseudoStyle && resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColor).isValid())
+            color = resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColor).blendWithWhite();
         else
             color = frame()->selection()->isFocusedAndActive() ?
                     theme()->activeSelectionBackgroundColor() :
@@ -1677,9 +1678,8 @@
         return color;
 
     if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequest(SELECTION))) {
-        color = pseudoStyle->visitedDependentColor(colorProperty);
-        if (!color.isValid())
-            color = pseudoStyle->visitedDependentColor(CSSPropertyColor);
+        Color selectionColor = resolveColor(pseudoStyle.get(), colorProperty);
+        color = selectionColor.isValid() ? selectionColor : resolveColor(pseudoStyle.get(), CSSPropertyColor);
     } else
         color = frame()->selection()->isFocusedAndActive() ?
                 theme()->activeSelectionForegroundColor() :
@@ -2270,6 +2270,60 @@
     return LayoutRect();
 }
 
+void RenderObject::computeLayerHitTestRects(LayerHitTestRects& layerRects) const
+{
+    // Figure out what layer our container is in. Any offset (or new layer) for this
+    // renderer within it's container will be applied in addLayerHitTestRects.
+    LayoutPoint layerOffset;
+    const RenderLayer* currentLayer = 0;
+
+    if (!hasLayer()) {
+        RenderObject* container = this->container();
+        if (container) {
+            currentLayer = container->enclosingLayer();
+            if (currentLayer && currentLayer->renderer() != container)
+                layerOffset.move(container->offsetFromAncestorContainer(currentLayer->renderer()));
+        } else {
+            currentLayer = enclosingLayer();
+        }
+        if (!currentLayer)
+            return;
+    }
+
+    this->addLayerHitTestRects(layerRects, currentLayer, layerOffset);
+}
+
+void RenderObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const RenderLayer* currentLayer, const LayoutPoint& layerOffset) const
+{
+    ASSERT(currentLayer);
+    ASSERT(currentLayer == this->enclosingLayer());
+
+    // If it's possible for children to have rects outside our bounds, then we need to descend into
+    // the children and compute them.
+    // Ideally there would be other cases where we could detect that children couldn't have rects
+    // outside our bounds and prune the tree walk.
+    // Note that we don't use Region here because Union is O(N) - better to just keep a list of
+    // partially redundant rectangles. If we find examples where this is expensive, then we could
+    // rewrite Region to be more efficient. See https://bugs.webkit.org/show_bug.cgi?id=100814.
+    if (!isRenderView()) {
+        for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) {
+            curr->addLayerHitTestRects(layerRects, currentLayer,  layerOffset);
+        }
+    }
+
+    // Compute the rects for this renderer only and add them to the results.
+    // Note that we could avoid passing the offset and instead adjust each result, but this
+    // seems slightly simpler.
+    Vector<LayoutRect> ownRects;
+    computeSelfHitTestRects(ownRects, layerOffset);
+
+    LayerHitTestRects::iterator iter = layerRects.find(currentLayer);
+    if (iter == layerRects.end())
+        layerRects.add(currentLayer, ownRects);
+    else
+        iter->value.append(ownRects);
+}
+
 bool RenderObject::isRooted(RenderView** view) const
 {
     const RenderObject* o = this;
@@ -2814,21 +2868,21 @@
     return RuntimeEnabledFeatures::cssCompositingEnabled() && style() && style()->hasBlendMode();
 }
 
-static Color decorationColor(RenderStyle* style)
+static Color decorationColor(const RenderObject* object, RenderStyle* style)
 {
     Color result;
     // Check for text decoration color first.
-    result = style->visitedDependentColor(CSSPropertyTextDecorationColor);
+    result = object->resolveColor(style, CSSPropertyTextDecorationColor);
     if (result.isValid())
         return result;
     if (style->textStrokeWidth() > 0) {
         // Prefer stroke color if possible but not if it's fully transparent.
-        result = style->visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
+        result = object->resolveColor(style, CSSPropertyWebkitTextStrokeColor);
         if (result.alpha())
             return result;
     }
     
-    result = style->visitedDependentColor(CSSPropertyWebkitTextFillColor);
+    result = object->resolveColor(style, CSSPropertyWebkitTextFillColor);
     return result;
 }
 
@@ -2842,7 +2896,7 @@
     do {
         styleToUse = curr->style(firstlineStyle);
         currDecs = styleToUse->textDecoration();
-        resultColor = decorationColor(styleToUse);
+        resultColor = decorationColor(this, styleToUse);
         // Parameter 'decorations' is cast as an int to enable the bitwise operations below.
         if (currDecs) {
             if (currDecs & TextDecorationUnderline) {
@@ -2868,7 +2922,7 @@
     // If we bailed out, use the element we bailed out at (typically a <font> or <a> element).
     if (decorations && curr) {
         styleToUse = curr->style(firstlineStyle);
-        resultColor = decorationColor(styleToUse);
+        resultColor = decorationColor(this, styleToUse);
         if (decorations & TextDecorationUnderline)
             underline = resultColor;
         if (decorations & TextDecorationOverline)
@@ -2998,10 +3052,9 @@
     // See https://code.google.com/p/chromium/issues/detail?id=243278
     RenderObject* hoverAncestor = parent();
 
-    // Skip anonymous blocks. There's no point in treating them as hover ancestors
-    // and it would also prevent us from continuing the search on the DOM tree
-    // when reaching the named flow thread.
-    if (hoverAncestor && hoverAncestor->isAnonymousBlock())
+    // Skip anonymous blocks directly flowed into flow threads as it would
+    // prevent us from continuing the search on the DOM tree when reaching the named flow thread.
+    if (hoverAncestor && hoverAncestor->isAnonymousBlock() && hoverAncestor->parent() && hoverAncestor->parent()->isRenderNamedFlowThread())
         hoverAncestor = hoverAncestor->parent();
 
     if (hoverAncestor && hoverAncestor->isRenderNamedFlowThread()) {
diff --git a/Source/core/rendering/RenderObject.h b/Source/core/rendering/RenderObject.h
index 9a22cf1..4555529 100644
--- a/Source/core/rendering/RenderObject.h
+++ b/Source/core/rendering/RenderObject.h
@@ -108,7 +108,8 @@
 enum MapCoordinatesMode {
     IsFixed = 1 << 0,
     UseTransforms = 1 << 1,
-    ApplyContainerFlip = 1 << 2
+    ApplyContainerFlip = 1 << 2,
+    TraverseDocumentBoundaries = 1 << 3,
 };
 typedef unsigned MapCoordinatesFlags;
 
@@ -129,6 +130,7 @@
 };
 
 typedef WTF::HashSet<const RenderObject*> RenderObjectAncestorLineboxDirtySet;
+typedef WTF::HashMap<const RenderLayer*, Vector<LayoutRect> > LayerHitTestRects;
 
 #ifndef NDEBUG
 const int showTreeCharacterOffset = 39;
@@ -243,7 +245,7 @@
     // again.  We have to make sure the render tree updates as needed to accommodate the new
     // normal flow object.
     void handleDynamicFloatPositionChange();
-    
+
     // RenderObject tree manipulation
     //////////////////////////////////////////
     virtual bool canHaveChildren() const { return virtualChildren(); }
@@ -263,7 +265,7 @@
     void setParent(RenderObject* parent)
     {
         m_parent = parent;
-        
+
         // Only update if our flow thread state is different from our new parent and if we're not a RenderFlowThread.
         // A RenderFlowThread is always considered to be inside itself, so it never has to change its state
         // in response to parent changes.
@@ -499,7 +501,7 @@
         // This function is kept in sync with anonymous block creation conditions in
         // RenderBlock::createAnonymousBlock(). This includes creating an anonymous
         // RenderBlock having a BLOCK or BOX display. Other classes such as RenderTextFragment
-        // are not RenderBlocks and will return false. See https://bugs.webkit.org/show_bug.cgi?id=56709. 
+        // are not RenderBlocks and will return false. See https://bugs.webkit.org/show_bug.cgi?id=56709.
         return isAnonymous() && (style()->display() == BLOCK || style()->display() == BOX) && style()->styleType() == NOPSEUDO && isRenderBlock() && !isListMarker() && !isRenderFlowThread()
             && !isRenderFullScreen()
             && !isRenderFullScreenPlaceholder();
@@ -559,7 +561,7 @@
     bool posChildNeedsLayout() const { return m_bitfields.posChildNeedsLayout(); }
     bool needsSimplifiedNormalFlowLayout() const { return m_bitfields.needsSimplifiedNormalFlowLayout(); }
     bool normalChildNeedsLayout() const { return m_bitfields.normalChildNeedsLayout(); }
-    
+
     bool preferredLogicalWidthsDirty() const { return m_bitfields.preferredLogicalWidthsDirty(); }
 
     bool isSelectionBorder() const;
@@ -583,7 +585,7 @@
     // any pseudo classes (and therefore has no concept of changing state).
     RenderStyle* getCachedPseudoStyle(PseudoId, RenderStyle* parentStyle = 0) const;
     PassRefPtr<RenderStyle> getUncachedPseudoStyle(const PseudoStyleRequest&, RenderStyle* parentStyle = 0, RenderStyle* ownStyle = 0) const;
-    
+
     virtual void updateDragState(bool dragOn);
 
     RenderView* view() const { return document()->renderView(); };
@@ -624,7 +626,7 @@
     void setNeedsSimplifiedNormalFlowLayout();
     void setPreferredLogicalWidthsDirty(bool, MarkingBehavior = MarkContainingBlockChain);
     void invalidateContainerPreferredLogicalWidths();
-    
+
     void setNeedsLayoutAndPrefWidthsRecalc()
     {
         setNeedsLayout(true);
@@ -666,7 +668,7 @@
 
     /* This function performs a layout only if one is needed. */
     void layoutIfNeeded() { if (needsLayout()) layout(); }
-    
+
     // used for element state updates that cannot be fixed with a
     // repaint and do not need a relayout
     virtual void updateFromElement() { }
@@ -731,7 +733,7 @@
     virtual LayoutSize offsetFromContainer(RenderObject*, const LayoutPoint&, bool* offsetDependsOnPoint = 0) const;
     // Return the offset from an object up the container() chain. Asserts that none of the intermediate objects have transforms.
     LayoutSize offsetFromAncestorContainer(RenderObject*) const;
-    
+
     virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint&) const { }
 
     // FIXME: useTransforms should go away eventually
@@ -755,6 +757,27 @@
     RenderStyle* firstLineStyle() const { return document()->styleSheetCollection()->usesFirstLineRules() ? cachedFirstLineStyle() : style(); }
     RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle() : style(); }
 
+    inline Color resolveColor(const RenderStyle* styleToUse, int colorProperty) const
+    {
+        return styleToUse->visitedDependentColor(colorProperty);
+    }
+
+    inline Color resolveColor(int colorProperty) const
+    {
+        return style()->visitedDependentColor(colorProperty);
+    }
+
+    inline Color resolveColor(int colorProperty, Color fallback) const
+    {
+        Color color = resolveColor(colorProperty);
+        return color.isValid() ? color : fallback;
+    }
+
+    inline Color resolveColor(Color color) const
+    {
+        return color;
+    }
+
     // Used only by Element::pseudoStyleCacheIsInvalid to get a first line style based off of a
     // given new style, without accessing the cache.
     PassRefPtr<RenderStyle> uncachedFirstLineStyle(RenderStyle*) const;
@@ -762,7 +785,7 @@
     // Anonymous blocks that are part of of a continuation chain will return their inline continuation's outline style instead.
     // This is typically only relevant when repainting.
     virtual RenderStyle* outlineStyleForRepaint() const { return style(); }
-    
+
     virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
 
     void getTextDecorationColors(int decorations, Color& underline, Color& overline, Color& linethrough, bool quirksMode = false, bool firstlineStyle = false);
@@ -774,7 +797,7 @@
     // Actually do the repaint of rect r for this object which has been computed in the coordinate space
     // of repaintContainer. If repaintContainer is 0, repaint via the view.
     void repaintUsingContainer(const RenderLayerModelObject* repaintContainer, const IntRect&) const;
-    
+
     // Repaint the entire object.  Called when, e.g., the color of a border changes, or when a border
     // style changes.
     void repaint() const;
@@ -904,7 +927,7 @@
     virtual bool willRenderImage(CachedImage*);
 
     void selectionStartEnd(int& spos, int& epos) const;
-    
+
     void remove() { if (parent()) parent()->removeChild(this); }
 
     AnimationController* animation() const;
@@ -921,15 +944,18 @@
     // Pushes state onto RenderGeometryMap about how to map coordinates from this renderer to its container, or ancestorToStopAt (whichever is encountered first).
     // Returns the renderer which was mapped to (container or ancestorToStopAt).
     virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const;
-    
+
     bool shouldUseTransformFromContainer(const RenderObject* container) const;
     void getTransformFromContainer(const RenderObject* container, const LayoutSize& offsetInContainer, TransformationMatrix&) const;
-    
+
     // return true if this object requires a new stacking context
-    bool createsGroup() const { return isTransparent() || hasMask() || hasFilter() || hasBlendMode(); } 
-    
+    bool createsGroup() const { return isTransparent() || hasMask() || hasFilter() || hasBlendMode(); }
+
     virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint& /* additionalOffset */, const RenderLayerModelObject* /* paintContainer */ = 0) { };
 
+    // Compute a list of hit-test rectangles per layer rooted at this renderer.
+    virtual void computeLayerHitTestRects(LayerHitTestRects&) const;
+
     LayoutRect absoluteOutlineBounds() const
     {
         return outlineBoundsForRepaint(0);
@@ -955,7 +981,7 @@
     void paintFocusRing(PaintInfo&, const LayoutPoint&, RenderStyle*);
     void paintOutline(PaintInfo&, const LayoutRect&);
     void addPDFURLRect(GraphicsContext*, const LayoutRect&);
-    
+
     virtual LayoutRect viewRect() const;
 
     void adjustRectForOutlineAndShadow(LayoutRect&) const;
@@ -971,6 +997,17 @@
 
     void setDocumentForAnonymous(Document* document) { ASSERT(isAnonymous()); m_node = document; }
 
+    // Add hit-test rects for the render tree rooted at this node to the provided collection on a
+    // per-RenderLayer basis. CurrentLayer must be the enclosing layer,
+    // and layerOffset is the current offset within this layer. Subclass implementations will add
+    // any offset for this renderer within it's container, so callers should provide only the
+    // offset of the container within it's layer.
+    virtual void addLayerHitTestRects(LayerHitTestRects&, const RenderLayer* currentLayer, const LayoutPoint& layerOffset) const;
+
+    // Add hit-test rects for this renderer only to the provided list. layerOffset is the offset
+    // of this renderer within the current layer that should be used for each result.
+    virtual void computeSelfHitTestRects(Vector<LayoutRect>&, const LayoutPoint& layerOffset) const { };
+
 private:
     RenderFlowThread* locateFlowThreadContainingBlock() const;
     void removeFromRenderFlowThread();
@@ -1048,7 +1085,7 @@
             , m_boxDecorationState(NoBoxDecorations)
         {
         }
-        
+
         // 31 bits have been used here. There is one bit available.
         ADD_BOOLEAN_BITFIELD(needsLayout, NeedsLayout);
         ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovementLayout);
@@ -1099,7 +1136,7 @@
 
         ALWAYS_INLINE SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState); }
         ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_selectionState = selectionState; }
-        
+
         ALWAYS_INLINE FlowThreadState flowThreadState() const { return static_cast<FlowThreadState>(m_flowThreadState); }
         ALWAYS_INLINE void setFlowThreadState(FlowThreadState flowThreadState) { m_flowThreadState = flowThreadState; }
 
diff --git a/Source/core/rendering/RenderTable.h b/Source/core/rendering/RenderTable.h
index 6f4e72a..0d48432 100644
--- a/Source/core/rendering/RenderTable.h
+++ b/Source/core/rendering/RenderTable.h
@@ -85,7 +85,7 @@
         return style()->isLeftToRightDirection() ? borderEnd() : borderStart();
     }
 
-    Color bgColor() const { return style()->visitedDependentColor(CSSPropertyBackgroundColor); }
+    Color bgColor() const { return resolveColor(CSSPropertyBackgroundColor); }
 
     int outerBorderBefore() const;
     int outerBorderAfter() const;
diff --git a/Source/core/rendering/RenderTableCell.cpp b/Source/core/rendering/RenderTableCell.cpp
index d1bc177..f13dc0a 100644
--- a/Source/core/rendering/RenderTableCell.cpp
+++ b/Source/core/rendering/RenderTableCell.cpp
@@ -500,12 +500,12 @@
     // (1) Our start border.
     int startColorProperty = includeColor ? CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderStartColor, styleForCellFlow()->direction(), styleForCellFlow()->writingMode()) : 0;
     int endColorProperty = includeColor ? CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderEndColor, styleForCellFlow()->direction(), styleForCellFlow()->writingMode()) : 0;
-    CollapsedBorderValue result(style()->borderStart(), includeColor ? style()->visitedDependentColor(startColorProperty) : Color(), BCELL);
+    CollapsedBorderValue result(style()->borderStart(), includeColor ? resolveColor(startColorProperty) : Color(), BCELL);
 
     // (2) The end border of the preceding cell.
     RenderTableCell* cellBefore = table->cellBefore(this);
     if (cellBefore) {
-        CollapsedBorderValue cellBeforeAdjoiningBorder = CollapsedBorderValue(cellBefore->borderAdjoiningCellAfter(this), includeColor ? cellBefore->style()->visitedDependentColor(endColorProperty) : Color(), BCELL);
+        CollapsedBorderValue cellBeforeAdjoiningBorder = CollapsedBorderValue(cellBefore->borderAdjoiningCellAfter(this), includeColor ? cellBefore->resolveColor(endColorProperty) : Color(), BCELL);
         // |result| should be the 2nd argument as |cellBefore| should win in case of equality per CSS 2.1 (Border conflict resolution, point 4).
         result = chooseBorder(cellBeforeAdjoiningBorder, result);
         if (!result.exists())
@@ -515,12 +515,12 @@
     bool startBorderAdjoinsTable = hasStartBorderAdjoiningTable();
     if (startBorderAdjoinsTable) {
         // (3) Our row's start border.
-        result = chooseBorder(result, CollapsedBorderValue(row()->borderAdjoiningStartCell(this), includeColor ? parent()->style()->visitedDependentColor(startColorProperty) : Color(), BROW));
+        result = chooseBorder(result, CollapsedBorderValue(row()->borderAdjoiningStartCell(this), includeColor ? parent()->resolveColor(startColorProperty) : Color(), BROW));
         if (!result.exists())
             return result;
 
         // (4) Our row group's start border.
-        result = chooseBorder(result, CollapsedBorderValue(section()->borderAdjoiningStartCell(this), includeColor ? section()->style()->visitedDependentColor(startColorProperty) : Color(), BROWGROUP));
+        result = chooseBorder(result, CollapsedBorderValue(section()->borderAdjoiningStartCell(this), includeColor ? section()->resolveColor(startColorProperty) : Color(), BROWGROUP));
         if (!result.exists())
             return result;
     }
@@ -531,19 +531,19 @@
     if (RenderTableCol* colElt = table->colElement(col(), &startColEdge, &endColEdge)) {
         if (colElt->isTableColumnGroup() && startColEdge) {
             // The |colElt| is a column group and is also the first colgroup (in case of spanned colgroups).
-            result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellStartBorder(this), includeColor ? colElt->style()->visitedDependentColor(startColorProperty) : Color(), BCOLGROUP));
+            result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellStartBorder(this), includeColor ? colElt->resolveColor(startColorProperty) : Color(), BCOLGROUP));
             if (!result.exists())
                 return result;
         } else if (!colElt->isTableColumnGroup()) {
             // We first consider the |colElt| and irrespective of whether it is a spanned col or not, we apply
             // its start border. This is as per HTML5 which states that: "For the purposes of the CSS table model,
             // the col element is expected to be treated as if it was present as many times as its span attribute specifies".
-            result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellStartBorder(this), includeColor ? colElt->style()->visitedDependentColor(startColorProperty) : Color(), BCOL));
+            result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellStartBorder(this), includeColor ? colElt->resolveColor(startColorProperty) : Color(), BCOL));
             if (!result.exists())
                 return result;
             // Next, apply the start border of the enclosing colgroup but only if it is adjacent to the cell's edge.
             if (RenderTableCol* enclosingColumnGroup = colElt->enclosingColumnGroupIfAdjacentBefore()) {
-                result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellStartBorder(this), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(startColorProperty) : Color(), BCOLGROUP));
+                result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellStartBorder(this), includeColor ? enclosingColumnGroup->resolveColor(startColorProperty) : Color(), BCOLGROUP));
                 if (!result.exists())
                     return result;
             }
@@ -555,18 +555,18 @@
         if (RenderTableCol* colElt = table->colElement(col() - 1, &startColEdge, &endColEdge)) {
             if (colElt->isTableColumnGroup() && endColEdge) {
                 // The element is a colgroup and is also the last colgroup (in case of spanned colgroups).
-                result = chooseBorder(CollapsedBorderValue(colElt->borderAdjoiningCellAfter(this), includeColor ? colElt->style()->visitedDependentColor(endColorProperty) : Color(), BCOLGROUP), result);
+                result = chooseBorder(CollapsedBorderValue(colElt->borderAdjoiningCellAfter(this), includeColor ? colElt->resolveColor(endColorProperty) : Color(), BCOLGROUP), result);
                 if (!result.exists())
                     return result;
             } else if (colElt->isTableColumn()) {
                 // Resolve the collapsing border against the col's border ignoring any 'span' as per HTML5.
-                result = chooseBorder(CollapsedBorderValue(colElt->borderAdjoiningCellAfter(this), includeColor ? colElt->style()->visitedDependentColor(endColorProperty) : Color(), BCOL), result);
+                result = chooseBorder(CollapsedBorderValue(colElt->borderAdjoiningCellAfter(this), includeColor ? colElt->resolveColor(endColorProperty) : Color(), BCOL), result);
                 if (!result.exists())
                     return result;
                 // Next, if the previous col has a parent colgroup then its end border should be applied
                 // but only if it is adjacent to the cell's edge.
                 if (RenderTableCol* enclosingColumnGroup = colElt->enclosingColumnGroupIfAdjacentAfter()) {
-                    result = chooseBorder(CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellEndBorder(this), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(endColorProperty) : Color(), BCOLGROUP), result);
+                    result = chooseBorder(CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellEndBorder(this), includeColor ? enclosingColumnGroup->resolveColor(endColorProperty) : Color(), BCOLGROUP), result);
                     if (!result.exists())
                         return result;
                 }
@@ -576,7 +576,7 @@
 
     if (startBorderAdjoinsTable) {
         // (7) The table's start border.
-        result = chooseBorder(result, CollapsedBorderValue(table->tableStartBorderAdjoiningCell(this), includeColor ? table->style()->visitedDependentColor(startColorProperty) : Color(), BTABLE));
+        result = chooseBorder(result, CollapsedBorderValue(table->tableStartBorderAdjoiningCell(this), includeColor ? table->resolveColor(startColorProperty) : Color(), BTABLE));
         if (!result.exists())
             return result;
     }
@@ -603,12 +603,12 @@
     // (1) Our end border.
     int startColorProperty = includeColor ? CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderStartColor, styleForCellFlow()->direction(), styleForCellFlow()->writingMode()) : 0;
     int endColorProperty = includeColor ? CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderEndColor, styleForCellFlow()->direction(), styleForCellFlow()->writingMode()) : 0;
-    CollapsedBorderValue result = CollapsedBorderValue(style()->borderEnd(), includeColor ? style()->visitedDependentColor(endColorProperty) : Color(), BCELL);
+    CollapsedBorderValue result = CollapsedBorderValue(style()->borderEnd(), includeColor ? resolveColor(endColorProperty) : Color(), BCELL);
     
     // (2) The start border of the following cell.
     if (!isEndColumn) {
         if (RenderTableCell* cellAfter = table->cellAfter(this)) {
-            CollapsedBorderValue cellAfterAdjoiningBorder = CollapsedBorderValue(cellAfter->borderAdjoiningCellBefore(this), includeColor ? cellAfter->style()->visitedDependentColor(startColorProperty) : Color(), BCELL);
+            CollapsedBorderValue cellAfterAdjoiningBorder = CollapsedBorderValue(cellAfter->borderAdjoiningCellBefore(this), includeColor ? cellAfter->resolveColor(startColorProperty) : Color(), BCELL);
             result = chooseBorder(result, cellAfterAdjoiningBorder);
             if (!result.exists())
                 return result;
@@ -618,12 +618,12 @@
     bool endBorderAdjoinsTable = hasEndBorderAdjoiningTable();
     if (endBorderAdjoinsTable) {
         // (3) Our row's end border.
-        result = chooseBorder(result, CollapsedBorderValue(row()->borderAdjoiningEndCell(this), includeColor ? parent()->style()->visitedDependentColor(endColorProperty) : Color(), BROW));
+        result = chooseBorder(result, CollapsedBorderValue(row()->borderAdjoiningEndCell(this), includeColor ? parent()->resolveColor(endColorProperty) : Color(), BROW));
         if (!result.exists())
             return result;
         
         // (4) Our row group's end border.
-        result = chooseBorder(result, CollapsedBorderValue(section()->borderAdjoiningEndCell(this), includeColor ? section()->style()->visitedDependentColor(endColorProperty) : Color(), BROWGROUP));
+        result = chooseBorder(result, CollapsedBorderValue(section()->borderAdjoiningEndCell(this), includeColor ? section()->resolveColor(endColorProperty) : Color(), BROWGROUP));
         if (!result.exists())
             return result;
     }
@@ -634,19 +634,19 @@
     if (RenderTableCol* colElt = table->colElement(col() + colSpan() - 1, &startColEdge, &endColEdge)) {
         if (colElt->isTableColumnGroup() && endColEdge) {
             // The element is a colgroup and is also the last colgroup (in case of spanned colgroups).
-            result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellEndBorder(this), includeColor ? colElt->style()->visitedDependentColor(endColorProperty) : Color(), BCOLGROUP));
+            result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellEndBorder(this), includeColor ? colElt->resolveColor(endColorProperty) : Color(), BCOLGROUP));
             if (!result.exists())
                 return result;
         } else if (!colElt->isTableColumnGroup()) {
             // First apply the end border of the column irrespective of whether it is spanned or not. This is as per
             // HTML5 which states that: "For the purposes of the CSS table model, the col element is expected to be
             // treated as if it was present as many times as its span attribute specifies".
-            result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellEndBorder(this), includeColor ? colElt->style()->visitedDependentColor(endColorProperty) : Color(), BCOL));
+            result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellEndBorder(this), includeColor ? colElt->resolveColor(endColorProperty) : Color(), BCOL));
             if (!result.exists())
                 return result;
             // Next, if it has a parent colgroup then we apply its end border but only if it is adjacent to the cell.
             if (RenderTableCol* enclosingColumnGroup = colElt->enclosingColumnGroupIfAdjacentAfter()) {
-                result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellEndBorder(this), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(endColorProperty) : Color(), BCOLGROUP));
+                result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellEndBorder(this), includeColor ? enclosingColumnGroup->resolveColor(endColorProperty) : Color(), BCOLGROUP));
                 if (!result.exists())
                     return result;
             }
@@ -658,17 +658,17 @@
         if (RenderTableCol* colElt = table->colElement(col() + colSpan(), &startColEdge, &endColEdge)) {
             if (colElt->isTableColumnGroup() && startColEdge) {
                 // This case is a colgroup without any col, we only compute it if it is adjacent to the cell's edge.
-                result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellBefore(this), includeColor ? colElt->style()->visitedDependentColor(startColorProperty) : Color(), BCOLGROUP));
+                result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellBefore(this), includeColor ? colElt->resolveColor(startColorProperty) : Color(), BCOLGROUP));
                 if (!result.exists())
                     return result;
             } else if (colElt->isTableColumn()) {
                 // Resolve the collapsing border against the col's border ignoring any 'span' as per HTML5.
-                result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellBefore(this), includeColor ? colElt->style()->visitedDependentColor(startColorProperty) : Color(), BCOL));
+                result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellBefore(this), includeColor ? colElt->resolveColor(startColorProperty) : Color(), BCOL));
                 if (!result.exists())
                     return result;
                 // If we have a parent colgroup, resolve the border only if it is adjacent to the cell.
                 if (RenderTableCol* enclosingColumnGroup = colElt->enclosingColumnGroupIfAdjacentBefore()) {
-                    result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellStartBorder(this), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(startColorProperty) : Color(), BCOLGROUP));
+                    result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellStartBorder(this), includeColor ? enclosingColumnGroup->resolveColor(startColorProperty) : Color(), BCOLGROUP));
                     if (!result.exists())
                         return result;
                 }
@@ -678,7 +678,7 @@
 
     if (endBorderAdjoinsTable) {
         // (7) The table's end border.
-        result = chooseBorder(result, CollapsedBorderValue(table->tableEndBorderAdjoiningCell(this), includeColor ? table->style()->visitedDependentColor(endColorProperty) : Color(), BTABLE));
+        result = chooseBorder(result, CollapsedBorderValue(table->tableEndBorderAdjoiningCell(this), includeColor ? table->resolveColor(endColorProperty) : Color(), BTABLE));
         if (!result.exists())
             return result;
     }
@@ -702,18 +702,18 @@
     // (1) Our before border.
     int beforeColorProperty = includeColor ? CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderBeforeColor, styleForCellFlow()->direction(), styleForCellFlow()->writingMode()) : 0;
     int afterColorProperty = includeColor ? CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderAfterColor, styleForCellFlow()->direction(), styleForCellFlow()->writingMode()) : 0;
-    CollapsedBorderValue result = CollapsedBorderValue(style()->borderBefore(), includeColor ? style()->visitedDependentColor(beforeColorProperty) : Color(), BCELL);
+    CollapsedBorderValue result = CollapsedBorderValue(style()->borderBefore(), includeColor ? resolveColor(beforeColorProperty) : Color(), BCELL);
     
     RenderTableCell* prevCell = table->cellAbove(this);
     if (prevCell) {
         // (2) A before cell's after border.
-        result = chooseBorder(CollapsedBorderValue(prevCell->style()->borderAfter(), includeColor ? prevCell->style()->visitedDependentColor(afterColorProperty) : Color(), BCELL), result);
+        result = chooseBorder(CollapsedBorderValue(prevCell->style()->borderAfter(), includeColor ? prevCell->resolveColor(afterColorProperty) : Color(), BCELL), result);
         if (!result.exists())
             return result;
     }
     
     // (3) Our row's before border.
-    result = chooseBorder(result, CollapsedBorderValue(parent()->style()->borderBefore(), includeColor ? parent()->style()->visitedDependentColor(beforeColorProperty) : Color(), BROW));
+    result = chooseBorder(result, CollapsedBorderValue(parent()->style()->borderBefore(), includeColor ? parent()->resolveColor(beforeColorProperty) : Color(), BROW));
     if (!result.exists())
         return result;
     
@@ -726,7 +726,7 @@
             prevRow = prevCell->section()->lastChild();
     
         if (prevRow) {
-            result = chooseBorder(CollapsedBorderValue(prevRow->style()->borderAfter(), includeColor ? prevRow->style()->visitedDependentColor(afterColorProperty) : Color(), BROW), result);
+            result = chooseBorder(CollapsedBorderValue(prevRow->style()->borderAfter(), includeColor ? prevRow->resolveColor(afterColorProperty) : Color(), BROW), result);
             if (!result.exists())
                 return result;
         }
@@ -736,14 +736,14 @@
     RenderTableSection* currSection = section();
     if (!rowIndex()) {
         // (5) Our row group's before border.
-        result = chooseBorder(result, CollapsedBorderValue(currSection->style()->borderBefore(), includeColor ? currSection->style()->visitedDependentColor(beforeColorProperty) : Color(), BROWGROUP));
+        result = chooseBorder(result, CollapsedBorderValue(currSection->style()->borderBefore(), includeColor ? currSection->resolveColor(beforeColorProperty) : Color(), BROWGROUP));
         if (!result.exists())
             return result;
         
         // (6) Previous row group's after border.
         currSection = table->sectionAbove(currSection, SkipEmptySections);
         if (currSection) {
-            result = chooseBorder(CollapsedBorderValue(currSection->style()->borderAfter(), includeColor ? currSection->style()->visitedDependentColor(afterColorProperty) : Color(), BROWGROUP), result);
+            result = chooseBorder(CollapsedBorderValue(currSection->style()->borderAfter(), includeColor ? currSection->resolveColor(afterColorProperty) : Color(), BROWGROUP), result);
             if (!result.exists())
                 return result;
         }
@@ -753,18 +753,18 @@
         // (8) Our column and column group's before borders.
         RenderTableCol* colElt = table->colElement(col());
         if (colElt) {
-            result = chooseBorder(result, CollapsedBorderValue(colElt->style()->borderBefore(), includeColor ? colElt->style()->visitedDependentColor(beforeColorProperty) : Color(), BCOL));
+            result = chooseBorder(result, CollapsedBorderValue(colElt->style()->borderBefore(), includeColor ? colElt->resolveColor(beforeColorProperty) : Color(), BCOL));
             if (!result.exists())
                 return result;
             if (RenderTableCol* enclosingColumnGroup = colElt->enclosingColumnGroup()) {
-                result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->style()->borderBefore(), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(beforeColorProperty) : Color(), BCOLGROUP));
+                result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->style()->borderBefore(), includeColor ? enclosingColumnGroup->resolveColor(beforeColorProperty) : Color(), BCOLGROUP));
                 if (!result.exists())
                     return result;
             }
         }
         
         // (9) The table's before border.
-        result = chooseBorder(result, CollapsedBorderValue(table->style()->borderBefore(), includeColor ? table->style()->visitedDependentColor(beforeColorProperty) : Color(), BTABLE));
+        result = chooseBorder(result, CollapsedBorderValue(table->style()->borderBefore(), includeColor ? table->resolveColor(beforeColorProperty) : Color(), BTABLE));
         if (!result.exists())
             return result;
     }
@@ -788,24 +788,24 @@
     // (1) Our after border.
     int beforeColorProperty = includeColor ? CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderBeforeColor, styleForCellFlow()->direction(), styleForCellFlow()->writingMode()) : 0;
     int afterColorProperty = includeColor ? CSSProperty::resolveDirectionAwareProperty(CSSPropertyWebkitBorderAfterColor, styleForCellFlow()->direction(), styleForCellFlow()->writingMode()) : 0;
-    CollapsedBorderValue result = CollapsedBorderValue(style()->borderAfter(), includeColor ? style()->visitedDependentColor(afterColorProperty) : Color(), BCELL);
+    CollapsedBorderValue result = CollapsedBorderValue(style()->borderAfter(), includeColor ? resolveColor(afterColorProperty) : Color(), BCELL);
     
     RenderTableCell* nextCell = table->cellBelow(this);
     if (nextCell) {
         // (2) An after cell's before border.
-        result = chooseBorder(result, CollapsedBorderValue(nextCell->style()->borderBefore(), includeColor ? nextCell->style()->visitedDependentColor(beforeColorProperty) : Color(), BCELL));
+        result = chooseBorder(result, CollapsedBorderValue(nextCell->style()->borderBefore(), includeColor ? nextCell->resolveColor(beforeColorProperty) : Color(), BCELL));
         if (!result.exists())
             return result;
     }
     
     // (3) Our row's after border. (FIXME: Deal with rowspan!)
-    result = chooseBorder(result, CollapsedBorderValue(parent()->style()->borderAfter(), includeColor ? parent()->style()->visitedDependentColor(afterColorProperty) : Color(), BROW));
+    result = chooseBorder(result, CollapsedBorderValue(parent()->style()->borderAfter(), includeColor ? parent()->resolveColor(afterColorProperty) : Color(), BROW));
     if (!result.exists())
         return result;
     
     // (4) The next row's before border.
     if (nextCell) {
-        result = chooseBorder(result, CollapsedBorderValue(nextCell->parent()->style()->borderBefore(), includeColor ? nextCell->parent()->style()->visitedDependentColor(beforeColorProperty) : Color(), BROW));
+        result = chooseBorder(result, CollapsedBorderValue(nextCell->parent()->style()->borderBefore(), includeColor ? nextCell->parent()->resolveColor(beforeColorProperty) : Color(), BROW));
         if (!result.exists())
             return result;
     }
@@ -814,14 +814,14 @@
     RenderTableSection* currSection = section();
     if (rowIndex() + rowSpan() >= currSection->numRows()) {
         // (5) Our row group's after border.
-        result = chooseBorder(result, CollapsedBorderValue(currSection->style()->borderAfter(), includeColor ? currSection->style()->visitedDependentColor(afterColorProperty) : Color(), BROWGROUP));
+        result = chooseBorder(result, CollapsedBorderValue(currSection->style()->borderAfter(), includeColor ? currSection->resolveColor(afterColorProperty) : Color(), BROWGROUP));
         if (!result.exists())
             return result;
         
         // (6) Following row group's before border.
         currSection = table->sectionBelow(currSection, SkipEmptySections);
         if (currSection) {
-            result = chooseBorder(result, CollapsedBorderValue(currSection->style()->borderBefore(), includeColor ? currSection->style()->visitedDependentColor(beforeColorProperty) : Color(), BROWGROUP));
+            result = chooseBorder(result, CollapsedBorderValue(currSection->style()->borderBefore(), includeColor ? currSection->resolveColor(beforeColorProperty) : Color(), BROWGROUP));
             if (!result.exists())
                 return result;
         }
@@ -831,17 +831,17 @@
         // (8) Our column and column group's after borders.
         RenderTableCol* colElt = table->colElement(col());
         if (colElt) {
-            result = chooseBorder(result, CollapsedBorderValue(colElt->style()->borderAfter(), includeColor ? colElt->style()->visitedDependentColor(afterColorProperty) : Color(), BCOL));
+            result = chooseBorder(result, CollapsedBorderValue(colElt->style()->borderAfter(), includeColor ? colElt->resolveColor(afterColorProperty) : Color(), BCOL));
             if (!result.exists()) return result;
             if (RenderTableCol* enclosingColumnGroup = colElt->enclosingColumnGroup()) {
-                result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->style()->borderAfter(), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(afterColorProperty) : Color(), BCOLGROUP));
+                result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->style()->borderAfter(), includeColor ? enclosingColumnGroup->resolveColor(afterColorProperty) : Color(), BCOLGROUP));
                 if (!result.exists())
                     return result;
             }
         }
         
         // (9) The table's after border.
-        result = chooseBorder(result, CollapsedBorderValue(table->style()->borderAfter(), includeColor ? table->style()->visitedDependentColor(afterColorProperty) : Color(), BTABLE));
+        result = chooseBorder(result, CollapsedBorderValue(table->style()->borderAfter(), includeColor ? table->resolveColor(afterColorProperty) : Color(), BTABLE));
         if (!result.exists())
             return result;
     }
@@ -1142,9 +1142,10 @@
     bool antialias = shouldAntialiasLines(graphicsContext);
     
     for (CollapsedBorder* border = borders.nextBorder(); border; border = borders.nextBorder()) {
-        if (border->borderValue.isSameIgnoringColor(*table()->currentBorderValue()))
+        if (border->borderValue.isSameIgnoringColor(*table()->currentBorderValue())) {
             drawLineForBoxSide(graphicsContext, border->x1, border->y1, border->x2, border->y2, border->side, 
-                               border->borderValue.color(), border->style, 0, 0, antialias);
+                resolveColor(border->borderValue.color()), border->style, 0, 0, antialias);
+        }
     }
 }
 
@@ -1167,7 +1168,7 @@
     if (backgroundObject != this)
         adjustedPaintOffset.moveBy(location());
 
-    Color c = backgroundObject->style()->visitedDependentColor(CSSPropertyBackgroundColor);
+    Color c = backgroundObject->resolveColor(CSSPropertyBackgroundColor);
     const FillLayer* bgLayer = backgroundObject->style()->backgroundLayers();
 
     if (bgLayer->hasImage() || c.isValid()) {
diff --git a/Source/core/rendering/RenderTableSection.cpp b/Source/core/rendering/RenderTableSection.cpp
index 9bca834..d8f632d 100644
--- a/Source/core/rendering/RenderTableSection.cpp
+++ b/Source/core/rendering/RenderTableSection.cpp
@@ -252,6 +252,123 @@
     cell->setCol(table()->effColToCol(col));
 }
 
+void RenderTableSection::populateSpanningRowsHeightFromCell(RenderTableCell* cell, struct SpanningRowsHeight& spanningRowsHeight)
+{
+    const unsigned rowSpan = cell->rowSpan();
+    const unsigned rowIndex = cell->rowIndex();
+
+    spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing = cell->logicalHeightForRowSizing();
+
+    spanningRowsHeight.rowHeight.resize(rowSpan);
+    spanningRowsHeight.totalRowsHeight = 0;
+    for (unsigned row = 0; row < rowSpan; row++) {
+        unsigned actualRow = row + rowIndex;
+        spanningRowsHeight.rowHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[actualRow] - borderSpacingForRow(actualRow);
+        spanningRowsHeight.totalRowsHeight += spanningRowsHeight.rowHeight[row];
+        spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing -= borderSpacingForRow(actualRow);
+    }
+    // We don't span the following row so its border-spacing (if any) should be included.
+    spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing += borderSpacingForRow(rowIndex + rowSpan - 1);
+}
+
+void RenderTableSection::distributeExtraRowSpanHeightToPercentRows(RenderTableCell* cell, int totalPercent, int& extraRowSpanningHeight, Vector<int>& rowsHeight)
+{
+    if (!extraRowSpanningHeight || !totalPercent)
+        return;
+
+    const unsigned rowSpan = cell->rowSpan();
+    const unsigned rowIndex = cell->rowIndex();
+    int percent = min(totalPercent, 100);
+    const int tableHeight = m_rowPos[m_grid.size()] + extraRowSpanningHeight;
+
+    // Our algorithm matches Firefox. Extra spanning height would be distributed Only in first percent height rows
+    // those total percent is 100. Other percent rows would be uneffected even extra spanning height is remain.
+    int accumulatedPositionIncrease = 0;
+    for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
+        if (percent > 0 && extraRowSpanningHeight > 0) {
+            if (m_grid[row].logicalHeight.isPercent()) {
+                int toAdd = (tableHeight * m_grid[row].logicalHeight.percent() / 100) - rowsHeight[row - rowIndex];
+                // FIXME: Note that this is wrong if we have a percentage above 100% and may make us grow
+                // above the available space.
+
+                toAdd = min(toAdd, extraRowSpanningHeight);
+                accumulatedPositionIncrease += toAdd;
+                extraRowSpanningHeight -= toAdd;
+                percent -= m_grid[row].logicalHeight.percent();
+            }
+        }
+        m_rowPos[row + 1] += accumulatedPositionIncrease;
+    }
+}
+
+void RenderTableSection::distributeExtraRowSpanHeightToAutoRows(RenderTableCell* cell, int totalAutoRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHeight)
+{
+    if (!extraRowSpanningHeight || !totalAutoRowsHeight)
+        return;
+
+    const unsigned rowSpan = cell->rowSpan();
+    const unsigned rowIndex = cell->rowIndex();
+    int accumulatedPositionIncrease = 0;
+    int remainder = 0;
+
+    // Aspect ratios of auto rows should not change otherwise table may look different than user expected.
+    // So extra height distributed in auto spanning rows based on their weight in spanning cell.
+    for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
+        if (m_grid[row].logicalHeight.isAuto()) {
+            accumulatedPositionIncrease += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) / totalAutoRowsHeight;
+            remainder += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) % totalAutoRowsHeight;
+
+            // While whole extra spanning height is distributing in auto spanning rows, rational parts remains
+            // in every integer division. So accumulating all remainder part in integer division and when total remainder
+            // is equvalent to divisor then 1 unit increased in row position.
+            // Note that this algorithm is biased towards adding more space towards the lower rows.
+            if (remainder >= totalAutoRowsHeight) {
+                remainder -= totalAutoRowsHeight;
+                accumulatedPositionIncrease++;
+            }
+        }
+        m_rowPos[row + 1] += accumulatedPositionIncrease;
+    }
+
+    ASSERT(!remainder);
+
+    extraRowSpanningHeight -= accumulatedPositionIncrease;
+}
+
+void RenderTableSection::distributeExtraRowSpanHeightToRemainingRows(RenderTableCell* cell, int totalRemainingRowsHeight, int& extraRowSpanningHeight, Vector<int>& rowsHeight)
+{
+    if (!extraRowSpanningHeight || !totalRemainingRowsHeight)
+        return;
+
+    const unsigned rowSpan = cell->rowSpan();
+    const unsigned rowIndex = cell->rowIndex();
+    int accumulatedPositionIncrease = 0;
+    int remainder = 0;
+
+    // Aspect ratios of the rows should not change otherwise table may look different than user expected.
+    // So extra height distribution in remaining spanning rows based on their weight in spanning cell.
+    for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
+        if (!m_grid[row].logicalHeight.isPercent()) {
+            accumulatedPositionIncrease += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) / totalRemainingRowsHeight;
+            remainder += (extraRowSpanningHeight * rowsHeight[row - rowIndex]) % totalRemainingRowsHeight;
+
+            // While whole extra spanning height is distributing in remaining spanning rows, rational parts remains
+            // in every integer division. So accumulating all remainder part in integer division and when total remainder
+            // is equvalent to divisor then 1 unit increased in row position.
+            // Note that this algorithm is biased towards adding more space towards the lower rows.
+            if (remainder >= totalRemainingRowsHeight) {
+                remainder -= totalRemainingRowsHeight;
+                accumulatedPositionIncrease++;
+            }
+        }
+        m_rowPos[row + 1] += accumulatedPositionIncrease;
+    }
+
+    ASSERT(!remainder);
+
+    extraRowSpanningHeight -= accumulatedPositionIncrease;
+}
+
 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on the ratio of row's height if
 // 1. RowSpan cell height is greater then the total height of rows in rowSpan cell
 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells)
@@ -262,38 +379,40 @@
     RenderTableCell* cell = rowSpanCells[0];
 
     unsigned rowSpan = cell->rowSpan();
-    unsigned rowIndex = cell->rowIndex();
-    int initialPos = m_rowPos[rowIndex + rowSpan];
 
-    int totalRowsHeight = 0;
-    int rowSpanCellHeight = cell->logicalHeightForRowSizing();
-    Vector<int> rowsHeight(rowSpan);
+    struct SpanningRowsHeight spanningRowsHeight;
 
-    // Getting height of rows in current rowSpan cell, getting total height of rows and adjusting rowSpan cell height with border spacing.
-    for (unsigned row = 0; row < rowSpan; row++) {
-        unsigned actualRow = row + rowIndex;
-        rowsHeight[row] = m_rowPos[actualRow + 1] - m_rowPos[actualRow] - borderSpacingForRow(actualRow);
-        totalRowsHeight += rowsHeight[row];
-        rowSpanCellHeight -= borderSpacingForRow(actualRow);
-    }
-    rowSpanCellHeight += borderSpacingForRow(rowIndex + rowSpan - 1);
+    populateSpanningRowsHeightFromCell(cell, spanningRowsHeight);
 
-    if (!totalRowsHeight || rowSpanCellHeight <= totalRowsHeight)
+    if (!spanningRowsHeight.totalRowsHeight || spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing <= spanningRowsHeight.totalRowsHeight)
         return;
 
-    // Recalculating the height of rows based on rowSpan cell height if rowSpan cell height is more than total height of rows.
-    int remainingHeight = rowSpanCellHeight;
+    unsigned rowIndex = cell->rowIndex();
+    int totalPercent = 0;
+    int totalAutoRowsHeight = 0;
+    int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight;
 
+    // Calculate total percentage, total auto rows height and total rows height except percent rows.
     for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
-        int rowHeight = (rowSpanCellHeight * rowsHeight[row - rowIndex]) / totalRowsHeight;
-        remainingHeight -= rowHeight;
-        m_rowPos[row + 1] = m_rowPos[row] + rowHeight + borderSpacingForRow(row);
+        if (m_grid[row].logicalHeight.isPercent()) {
+            totalPercent += m_grid[row].logicalHeight.percent();
+            totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - rowIndex];
+        } else if (m_grid[row].logicalHeight.isAuto()) {
+            totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - rowIndex];
+        }
     }
-    // Remaining height added in the last row under rowSpan cell
-    m_rowPos[rowIndex + rowSpan] += remainingHeight;
+
+    int initialPos = m_rowPos[rowIndex + rowSpan];
+    int extraRowSpanningHeight = spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing - spanningRowsHeight.totalRowsHeight;
+
+    distributeExtraRowSpanHeightToPercentRows(cell, totalPercent, extraRowSpanningHeight, spanningRowsHeight.rowHeight);
+    distributeExtraRowSpanHeightToAutoRows(cell, totalAutoRowsHeight, extraRowSpanningHeight, spanningRowsHeight.rowHeight);
+    distributeExtraRowSpanHeightToRemainingRows(cell, totalRemainingRowsHeight, extraRowSpanningHeight, spanningRowsHeight.rowHeight);
+
+    ASSERT(!extraRowSpanningHeight);
 
     // Getting total changed height in the table
-    unsigned changedHeight = changedHeight = m_rowPos[rowIndex + rowSpan] - initialPos;
+    unsigned changedHeight = m_rowPos[rowIndex + rowSpan] - initialPos;
 
     if (changedHeight) {
         unsigned totalRows = m_grid.size();
diff --git a/Source/core/rendering/RenderTableSection.h b/Source/core/rendering/RenderTableSection.h
index 4725240..2807af6 100644
--- a/Source/core/rendering/RenderTableSection.h
+++ b/Source/core/rendering/RenderTableSection.h
@@ -122,6 +122,21 @@
         Length logicalHeight;
     };
 
+    struct SpanningRowsHeight {
+        WTF_MAKE_NONCOPYABLE(SpanningRowsHeight);
+
+    public:
+        SpanningRowsHeight()
+            : totalRowsHeight(0)
+            , spanningCellHeightIgnoringBorderSpacing(0)
+        {
+        }
+
+        Vector<int> rowHeight;
+        int totalRowsHeight;
+        int spanningCellHeightIgnoringBorderSpacing;
+    };
+
     const BorderValue& borderAdjoiningTableStart() const
     {
         if (hasSameDirectionAs(table()))
@@ -226,6 +241,10 @@
 
     void ensureRows(unsigned);
 
+    void populateSpanningRowsHeightFromCell(RenderTableCell*, struct SpanningRowsHeight&);
+    void distributeExtraRowSpanHeightToPercentRows(RenderTableCell*, int, int&, Vector<int>&);
+    void distributeExtraRowSpanHeightToAutoRows(RenderTableCell*, int, int&, Vector<int>&);
+    void distributeExtraRowSpanHeightToRemainingRows(RenderTableCell*, int, int&, Vector<int>&);
     void distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells);
 
     void distributeExtraLogicalHeightToPercentRows(int& extraLogicalHeight, int totalPercent);
diff --git a/Source/core/rendering/RenderText.cpp b/Source/core/rendering/RenderText.cpp
index 55095ae..1e1ab09 100644
--- a/Source/core/rendering/RenderText.cpp
+++ b/Source/core/rendering/RenderText.cpp
@@ -889,7 +889,7 @@
     return font.width(RenderBlock::constructTextRun(renderer, font, style->hyphenString().string(), style));
 }
 
-static float maxWordFragmentWidth(RenderText* renderer, RenderStyle* style, const Font& font, const UChar* word, int wordLength, int minimumPrefixLength, int minimumSuffixLength, int& suffixStart)
+static float maxWordFragmentWidth(RenderText* renderer, RenderStyle* style, const Font& font, int wordOffset, int wordLength, int minimumPrefixLength, int minimumSuffixLength, int& suffixStart)
 {
     suffixStart = 0;
     if (wordLength <= minimumSuffixLength)
@@ -897,7 +897,8 @@
 
     Vector<int, 8> hyphenLocations;
     int hyphenLocation = wordLength - minimumSuffixLength;
-    while ((hyphenLocation = lastHyphenLocation(word, wordLength, hyphenLocation, style->locale())) >= minimumPrefixLength)
+    String word = renderer->substring(wordOffset, wordLength);
+    while ((hyphenLocation = lastHyphenLocation(word, hyphenLocation, style->locale())) >= minimumPrefixLength)
         hyphenLocations.append(hyphenLocation);
 
     if (hyphenLocations.isEmpty())
@@ -910,7 +911,10 @@
     for (size_t k = 0; k < hyphenLocations.size(); ++k) {
         int fragmentLength = hyphenLocations[k] - suffixStart;
         StringBuilder fragmentWithHyphen;
-        fragmentWithHyphen.append(word + suffixStart, fragmentLength);
+        if (renderer->is8Bit())
+            fragmentWithHyphen.append(renderer->characters8() + wordOffset + suffixStart, fragmentLength);
+        else
+            fragmentWithHyphen.append(renderer->characters16() + wordOffset + suffixStart, fragmentLength);
         fragmentWithHyphen.append(style->hyphenString());
 
         TextRun run = RenderBlock::constructTextRun(renderer, font, fragmentWithHyphen.toString(), style);
@@ -1068,7 +1072,7 @@
 
             if (w > maxWordWidth) {
                 int suffixStart;
-                float maxFragmentWidth = maxWordFragmentWidth(this, styleToUse, f, bloatedCharacters() + i, wordLen, minimumPrefixLength, minimumSuffixLength, suffixStart);
+                float maxFragmentWidth = maxWordFragmentWidth(this, styleToUse, f, i, wordLen, minimumPrefixLength, minimumSuffixLength, suffixStart);
 
                 if (suffixStart) {
                     float suffixWidth;
@@ -1368,6 +1372,11 @@
     return prev;
 }
 
+void RenderText::addLayerHitTestRects(LayerHitTestRects&, const RenderLayer* currentLayer, const LayoutPoint& layerOffset) const
+{
+    // Text nodes aren't event targets, so don't descend any further.
+}
+
 void applyTextTransform(const RenderStyle* style, String& text, UChar previousCharacter)
 {
     if (!style)
@@ -1894,7 +1903,7 @@
 {
     if (isAllASCII() || m_text.is8Bit())
         return true;
-    return Font::characterRangeCodePath(bloatedCharacters(), length()) == Font::Simple;
+    return Font::characterRangeCodePath(characters16(), length()) == Font::Simple;
 }
 
 #ifndef NDEBUG
diff --git a/Source/core/rendering/RenderText.h b/Source/core/rendering/RenderText.h
index 0b6d533..34ce468 100644
--- a/Source/core/rendering/RenderText.h
+++ b/Source/core/rendering/RenderText.h
@@ -72,7 +72,6 @@
     bool is8Bit() const { return m_text.is8Bit(); }
     const LChar* characters8() const { return m_text.impl()->characters8(); }
     const UChar* characters16() const { return m_text.impl()->characters16(); }
-    const UChar* bloatedCharacters() const { return m_text.bloatedCharacters(); }
     bool hasEmptyText() const { return m_text.isEmpty(); }
     String substring(unsigned position, unsigned length) const { return m_text.substring(position, length); }
     UChar characterAt(unsigned) const;
@@ -152,6 +151,8 @@
 
     virtual void setTextInternal(PassRefPtr<StringImpl>);
     virtual UChar previousCharacter() const;
+
+    virtual void addLayerHitTestRects(LayerHitTestRects&, const RenderLayer* currentLayer, const LayoutPoint& layerOffset) const OVERRIDE;
     
     virtual InlineTextBox* createTextBox(); // Subclassed by SVG.
 
diff --git a/Source/core/rendering/RenderTextControlSingleLine.cpp b/Source/core/rendering/RenderTextControlSingleLine.cpp
index 4326f71..81ba019 100644
--- a/Source/core/rendering/RenderTextControlSingleLine.cpp
+++ b/Source/core/rendering/RenderTextControlSingleLine.cpp
@@ -262,10 +262,7 @@
     bool shouldDrawCapsLockIndicator = false;
 
     if (Frame* frame = document()->frame())
-        shouldDrawCapsLockIndicator = inputElement()->isPasswordField()
-                                      && frame->selection()->isFocusedAndActive()
-                                      && document()->focusedNode() == node()
-                                      && PlatformKeyboardEvent::currentCapsLockState();
+        shouldDrawCapsLockIndicator = inputElement()->isPasswordField() && frame->selection()->isFocusedAndActive() && document()->focusedElement() == node() && PlatformKeyboardEvent::currentCapsLockState();
 
     if (shouldDrawCapsLockIndicator != m_shouldDrawCapsLockIndicator) {
         m_shouldDrawCapsLockIndicator = shouldDrawCapsLockIndicator;
@@ -391,8 +388,7 @@
 
 bool RenderTextControlSingleLine::textShouldBeTruncated() const
 {
-    return document()->focusedNode() != node()
-        && style()->textOverflow() == TextOverflowEllipsis;
+    return document()->focusedElement() != node() && style()->textOverflow() == TextOverflowEllipsis;
 }
 
 void RenderTextControlSingleLine::autoscroll(const IntPoint& position)
diff --git a/Source/core/rendering/RenderTheme.cpp b/Source/core/rendering/RenderTheme.cpp
index 05d9330..790b9ed 100644
--- a/Source/core/rendering/RenderTheme.cpp
+++ b/Source/core/rendering/RenderTheme.cpp
@@ -814,7 +814,7 @@
     node = node->focusDelegate();
     Document* document = node->document();
     Frame* frame = document->frame();
-    return node == document->focusedNode() && node->shouldHaveFocusAppearance() && frame && frame->selection()->isFocusedAndActive();
+    return node == document->focusedElement() && node->shouldHaveFocusAppearance() && frame && frame->selection()->isFocusedAndActive();
 }
 
 bool RenderTheme::isPressed(const RenderObject* o) const
@@ -1015,7 +1015,7 @@
     }
     RefPtr<HTMLCollection> options = dataList->options();
     GraphicsContextStateSaver stateSaver(*paintInfo.context);
-    paintInfo.context->setFillColor(o->style()->visitedDependentColor(CSSPropertyColor));
+    paintInfo.context->setFillColor(o->resolveColor(CSSPropertyColor));
     for (unsigned i = 0; Node* node = options->item(i); i++) {
         ASSERT(node->hasTagName(optionTag));
         HTMLOptionElement* optionElement = toHTMLOptionElement(node);
diff --git a/Source/core/rendering/RenderThemeChromiumDefault.cpp b/Source/core/rendering/RenderThemeChromiumDefault.cpp
index 7aab69b..41b12d2 100644
--- a/Source/core/rendering/RenderThemeChromiumDefault.cpp
+++ b/Source/core/rendering/RenderThemeChromiumDefault.cpp
@@ -272,7 +272,7 @@
     extraParams.button.hasBorder = true;
     extraParams.button.backgroundColor = defaultButtonBackgroundColor;
     if (o->hasBackground())
-        extraParams.button.backgroundColor = o->style()->visitedDependentColor(CSSPropertyBackgroundColor).rgb();
+        extraParams.button.backgroundColor = o->resolveColor(CSSPropertyBackgroundColor).rgb();
 
     WebKit::Platform::current()->themeEngine()->paint(canvas, WebKit::WebThemeEngine::PartButton, getWebThemeState(this, o), WebKit::WebRect(rect), &extraParams);
     return false;
@@ -294,9 +294,7 @@
     WebKit::WebCanvas* canvas = i.context->canvas();
 
     // 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);
+    Color backgroundColor = o->resolveColor(CSSPropertyBackgroundColor, Color::white);
     extraParams.textField.backgroundColor = backgroundColor.rgb();
 
     WebKit::Platform::current()->themeEngine()->paint(canvas, WebKit::WebThemeEngine::PartTextField, getWebThemeState(this, o), WebKit::WebRect(rect), &extraParams);
@@ -321,7 +319,7 @@
     // Fallback to transparent if the specified color object is invalid.
     extraParams.menuList.backgroundColor = Color::transparent;
     if (o->hasBackground())
-        extraParams.menuList.backgroundColor = o->style()->visitedDependentColor(CSSPropertyBackgroundColor).rgb();
+        extraParams.menuList.backgroundColor = o->resolveColor(CSSPropertyBackgroundColor).rgb();
 
     WebKit::WebCanvas* canvas = i.context->canvas();
 
diff --git a/Source/core/rendering/RenderTreeAsText.cpp b/Source/core/rendering/RenderTreeAsText.cpp
index 1b18a15..83f5e5e 100644
--- a/Source/core/rendering/RenderTreeAsText.cpp
+++ b/Source/core/rendering/RenderTreeAsText.cpp
@@ -199,6 +199,11 @@
     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();
@@ -262,23 +267,23 @@
             ts << " " << quoteAndEscapeNonPrintables(toRenderFileUploadControl(&o)->fileTextValue());
 
         if (o.parent()) {
-            Color color = o.style()->visitedDependentColor(CSSPropertyColor);
-            if (o.parent()->style()->visitedDependentColor(CSSPropertyColor) != color)
+            Color color = o.resolveColor(CSSPropertyColor);
+            if (o.parent()->resolveColor(CSSPropertyColor) != color)
                 ts << " [color=" << color.nameForRenderTreeAsText() << "]";
 
             // Do not dump invalid or transparent backgrounds, since that is the default.
-            Color backgroundColor = o.style()->visitedDependentColor(CSSPropertyBackgroundColor);
-            if (o.parent()->style()->visitedDependentColor(CSSPropertyBackgroundColor) != backgroundColor
+            Color backgroundColor = o.resolveColor(CSSPropertyBackgroundColor);
+            if (o.parent()->resolveColor(CSSPropertyBackgroundColor) != backgroundColor
                 && backgroundColor.isValid() && backgroundColor.rgb())
                 ts << " [bgcolor=" << backgroundColor.nameForRenderTreeAsText() << "]";
             
-            Color textFillColor = o.style()->visitedDependentColor(CSSPropertyWebkitTextFillColor);
-            if (o.parent()->style()->visitedDependentColor(CSSPropertyWebkitTextFillColor) != textFillColor
+            Color textFillColor = o.resolveColor(CSSPropertyWebkitTextFillColor);
+            if (o.parent()->resolveColor(CSSPropertyWebkitTextFillColor) != textFillColor
                 && textFillColor.isValid() && textFillColor != color && textFillColor.rgb())
                 ts << " [textFillColor=" << textFillColor.nameForRenderTreeAsText() << "]";
 
-            Color textStrokeColor = o.style()->visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
-            if (o.parent()->style()->visitedDependentColor(CSSPropertyWebkitTextStrokeColor) != textStrokeColor
+            Color textStrokeColor = o.resolveColor(CSSPropertyWebkitTextStrokeColor);
+            if (o.parent()->resolveColor(CSSPropertyWebkitTextStrokeColor) != textStrokeColor
                 && textStrokeColor.isValid() && textStrokeColor != color && textStrokeColor.rgb())
                 ts << " [textStrokeColor=" << textStrokeColor.nameForRenderTreeAsText() << "]";
 
@@ -299,9 +304,7 @@
             else {
                 ts << " (" << box.borderTop() << "px ";
                 printBorderStyle(ts, o.style()->borderTopStyle());
-                Color col = o.style()->borderTopColor();
-                if (!col.isValid())
-                    col = o.style()->color();
+                Color col = colorWithFallback(o, o.style()->borderTopColor());
                 ts << col.nameForRenderTreeAsText() << ")";
             }
 
@@ -312,9 +315,7 @@
                 else {
                     ts << " (" << box.borderRight() << "px ";
                     printBorderStyle(ts, o.style()->borderRightStyle());
-                    Color col = o.style()->borderRightColor();
-                    if (!col.isValid())
-                        col = o.style()->color();
+                    Color col = colorWithFallback(o, o.style()->borderRightColor());
                     ts << col.nameForRenderTreeAsText() << ")";
                 }
             }
@@ -326,9 +327,7 @@
                 else {
                     ts << " (" << box.borderBottom() << "px ";
                     printBorderStyle(ts, o.style()->borderBottomStyle());
-                    Color col = o.style()->borderBottomColor();
-                    if (!col.isValid())
-                        col = o.style()->color();
+                    Color col = colorWithFallback(o, o.style()->borderBottomColor());
                     ts << col.nameForRenderTreeAsText() << ")";
                 }
             }
@@ -340,9 +339,7 @@
                 else {
                     ts << " (" << box.borderLeft() << "px ";
                     printBorderStyle(ts, o.style()->borderLeftStyle());
-                    Color col = o.style()->borderLeftColor();
-                    if (!col.isValid())
-                        col = o.style()->color();
+                    Color col = colorWithFallback(o, o.style()->borderLeftColor());
                     ts << col.nameForRenderTreeAsText() << ")";
                 }
             }
diff --git a/Source/core/rendering/RenderView.cpp b/Source/core/rendering/RenderView.cpp
index 22e2250..89e7169 100644
--- a/Source/core/rendering/RenderView.cpp
+++ b/Source/core/rendering/RenderView.cpp
@@ -301,9 +301,6 @@
 
 void RenderView::mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFixed) const
 {
-    // If a container was specified, and was not 0 or the RenderView,
-    // then we should have found it by now.
-    ASSERT_ARG(repaintContainer, !repaintContainer || repaintContainer == this);
     ASSERT_UNUSED(wasFixed, !wasFixed || *wasFixed == (mode & IsFixed));
 
     if (!repaintContainer && mode & UseTransforms && shouldUseTransformFromContainer(0)) {
@@ -314,6 +311,23 @@
     
     if (mode & IsFixed && m_frameView)
         transformState.move(m_frameView->scrollOffsetForFixedPosition());
+
+    if (repaintContainer == this)
+        return;
+
+    if (mode & TraverseDocumentBoundaries) {
+        if (RenderObject* parentDocRenderer = frame()->ownerRenderer()) {
+            transformState.move(-frame()->view()->scrollOffset());
+            if (parentDocRenderer->isBox())
+                transformState.move(toLayoutSize(toRenderBox(parentDocRenderer)->contentBoxRect().location()));
+            parentDocRenderer->mapLocalToContainer(repaintContainer, transformState, mode, wasFixed);
+            return;
+        }
+    }
+
+    // If a container was specified, and was not 0 or the RenderView,
+    // then we should have found it by now.
+    ASSERT_ARG(repaintContainer, !repaintContainer);
 }
 
 const RenderObject* RenderView::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const
@@ -349,6 +363,14 @@
     }
 }
 
+void RenderView::computeSelfHitTestRects(Vector<LayoutRect>& rects, const LayoutPoint&) const
+{
+    // Record the entire size of the contents of the frame. Note that we don't just
+    // use the viewport size (containing block) here because we want to ensure this includes
+    // all children (so we can avoid walking them explicitly).
+    rects.append(LayoutRect(LayoutPoint::zero(), frameView()->contentsSize()));
+}
+
 bool RenderView::requiresColumns(int desiredColumnCount) const
 {
     if (m_frameView)
diff --git a/Source/core/rendering/RenderView.h b/Source/core/rendering/RenderView.h
index 8016e8e..cc36421 100644
--- a/Source/core/rendering/RenderView.h
+++ b/Source/core/rendering/RenderView.h
@@ -37,6 +37,9 @@
 class RenderQuote;
 class RenderWidget;
 
+// The root of the render tree, corresponding to the CSS initial containing block.
+// It's dimensions match that of the viewport, and it is always at position (0,0)
+// relative to the document (and so isn't necessarily in view).
 class RenderView FINAL : public RenderBlock {
 public:
     explicit RenderView(Document*);
@@ -203,6 +206,7 @@
     virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const OVERRIDE;
     virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) const;
     virtual bool requiresColumns(int desiredColumnCount) const OVERRIDE;
+    virtual void computeSelfHitTestRects(Vector<LayoutRect>&, const LayoutPoint& layerOffset) const OVERRIDE;
     
 private:
     bool initializeLayoutState(LayoutState&);
diff --git a/Source/core/rendering/style/RenderStyle.cpp b/Source/core/rendering/style/RenderStyle.cpp
index a607135..b833659 100644
--- a/Source/core/rendering/style/RenderStyle.cpp
+++ b/Source/core/rendering/style/RenderStyle.cpp
@@ -25,6 +25,7 @@
 
 #include <algorithm>
 #include "CSSPropertyNames.h"
+#include "RuntimeEnabledFeatures.h"
 #include "core/css/resolver/StyleResolver.h"
 #include "core/platform/graphics/Font.h"
 #include "core/platform/graphics/FontSelector.h"
diff --git a/Source/core/rendering/svg/RenderSVGGradientStop.cpp b/Source/core/rendering/svg/RenderSVGGradientStop.cpp
index f877717..274e3a6 100644
--- a/Source/core/rendering/svg/RenderSVGGradientStop.cpp
+++ b/Source/core/rendering/svg/RenderSVGGradientStop.cpp
@@ -70,7 +70,7 @@
 {
     ContainerNode* parentNode = node()->parentNode();
     if (parentNode->hasTagName(linearGradientTag) || parentNode->hasTagName(radialGradientTag))
-        return static_cast<SVGGradientElement*>(parentNode);
+        return toSVGGradientElement(parentNode);
     return 0;
 }
 
diff --git a/Source/core/rendering/svg/RenderSVGModelObject.cpp b/Source/core/rendering/svg/RenderSVGModelObject.cpp
index 2939781..f3e5ca8 100644
--- a/Source/core/rendering/svg/RenderSVGModelObject.cpp
+++ b/Source/core/rendering/svg/RenderSVGModelObject.cpp
@@ -33,6 +33,7 @@
 #include "core/rendering/svg/RenderSVGModelObject.h"
 
 #include "SVGNames.h"
+#include "core/rendering/svg/RenderSVGRoot.h"
 #include "core/rendering/svg/SVGResourcesCache.h"
 #include "core/svg/SVGStyledElement.h"
 
@@ -94,6 +95,17 @@
     RenderObject::willBeDestroyed();
 }
 
+void RenderSVGModelObject::computeLayerHitTestRects(LayerHitTestRects& rects) const
+{
+    // Using just the rect for the SVGRoot is good enough for now.
+    SVGRenderSupport::findTreeRootObject(this)->computeLayerHitTestRects(rects);
+}
+
+void RenderSVGModelObject::addLayerHitTestRects(LayerHitTestRects&, const RenderLayer* currentLayer, const LayoutPoint& layerOffset) const
+{
+    // We don't walk into SVG trees at all - just report their container.
+}
+
 void RenderSVGModelObject::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
 {
     if (diff == StyleDifferenceLayout) {
diff --git a/Source/core/rendering/svg/RenderSVGModelObject.h b/Source/core/rendering/svg/RenderSVGModelObject.h
index 5c7515d..5499d02 100644
--- a/Source/core/rendering/svg/RenderSVGModelObject.h
+++ b/Source/core/rendering/svg/RenderSVGModelObject.h
@@ -67,7 +67,10 @@
     bool hasSVGShadow() const { return m_hasSVGShadow; }
     void setHasSVGShadow(bool hasShadow) { m_hasSVGShadow = hasShadow; }
 
+    virtual void computeLayerHitTestRects(LayerHitTestRects&) const OVERRIDE;
+
 protected:
+    virtual void addLayerHitTestRects(LayerHitTestRects&, const RenderLayer* currentCompositedLayer, const LayoutPoint& layerOffset) const OVERRIDE;
     virtual void willBeDestroyed();
 
 private:
diff --git a/Source/core/rendering/svg/RenderSVGResourceClipper.cpp b/Source/core/rendering/svg/RenderSVGResourceClipper.cpp
index c1978d6..9d99a7d 100644
--- a/Source/core/rendering/svg/RenderSVGResourceClipper.cpp
+++ b/Source/core/rendering/svg/RenderSVGResourceClipper.cpp
@@ -234,7 +234,7 @@
         WindRule newClipRule = style->svgStyle()->clipRule();
         bool isUseElement = childNode->hasTagName(SVGNames::useTag);
         if (isUseElement) {
-            SVGUseElement* useElement = static_cast<SVGUseElement*>(childNode);
+            SVGUseElement* useElement = toSVGUseElement(childNode);
             renderer = useElement->rendererClipChild();
             if (!renderer)
                 continue;
diff --git a/Source/core/rendering/svg/RenderSVGResourceMarker.cpp b/Source/core/rendering/svg/RenderSVGResourceMarker.cpp
index 2f5bdb1..b33cc50 100644
--- a/Source/core/rendering/svg/RenderSVGResourceMarker.cpp
+++ b/Source/core/rendering/svg/RenderSVGResourceMarker.cpp
@@ -94,7 +94,7 @@
 
 FloatPoint RenderSVGResourceMarker::referencePoint() const
 {
-    SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(node());
+    SVGMarkerElement* marker = toSVGMarkerElement(node());
     ASSERT(marker);
 
     SVGLengthContext lengthContext(marker);
@@ -103,7 +103,7 @@
 
 float RenderSVGResourceMarker::angle() const
 {
-    SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(node());
+    SVGMarkerElement* marker = toSVGMarkerElement(node());
     ASSERT(marker);
 
     float angle = -1;
@@ -115,7 +115,7 @@
 
 AffineTransform RenderSVGResourceMarker::markerTransformation(const FloatPoint& origin, float autoAngle, float strokeWidth) const
 {
-    SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(node());
+    SVGMarkerElement* marker = toSVGMarkerElement(node());
     ASSERT(marker);
 
     float markerAngle = angle();
@@ -157,7 +157,7 @@
 
 AffineTransform RenderSVGResourceMarker::viewportTransform() const
 {
-    SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(node());
+    SVGMarkerElement* marker = toSVGMarkerElement(node());
     ASSERT(marker);
 
     return marker->viewBoxToViewTransform(m_viewport.width(), m_viewport.height());
@@ -168,7 +168,7 @@
     if (!selfNeedsLayout())
         return;
 
-    SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(node());
+    SVGMarkerElement* marker = toSVGMarkerElement(node());
     ASSERT(marker);
     
     SVGLengthContext lengthContext(marker);
diff --git a/Source/core/rendering/svg/RenderSVGResourceMarker.h b/Source/core/rendering/svg/RenderSVGResourceMarker.h
index b0cdcc1..409c65d 100644
--- a/Source/core/rendering/svg/RenderSVGResourceMarker.h
+++ b/Source/core/rendering/svg/RenderSVGResourceMarker.h
@@ -59,7 +59,7 @@
 
     FloatPoint referencePoint() const;
     float angle() const;
-    SVGMarkerUnitsType markerUnits() const { return static_cast<SVGMarkerElement*>(node())->markerUnitsCurrentValue(); }
+    SVGMarkerUnitsType markerUnits() const { return toSVGMarkerElement(node())->markerUnitsCurrentValue(); }
 
     virtual RenderSVGResourceType resourceType() const { return s_resourceType; }
     static RenderSVGResourceType s_resourceType;
diff --git a/Source/core/rendering/svg/RenderSVGTextPath.cpp b/Source/core/rendering/svg/RenderSVGTextPath.cpp
index 96a9ad2..022afad 100644
--- a/Source/core/rendering/svg/RenderSVGTextPath.cpp
+++ b/Source/core/rendering/svg/RenderSVGTextPath.cpp
@@ -40,7 +40,7 @@
     if (!targetElement || !targetElement->hasTagName(SVGNames::pathTag))
         return Path();
     
-    SVGPathElement* pathElement = static_cast<SVGPathElement*>(targetElement);
+    SVGPathElement* pathElement = toSVGPathElement(targetElement);
     
     Path pathData;
     updatePathFromGraphicsElement(pathElement, pathData);
diff --git a/Source/core/rendering/svg/RenderSVGTransformableContainer.cpp b/Source/core/rendering/svg/RenderSVGTransformableContainer.cpp
index e03be53..d53d892 100644
--- a/Source/core/rendering/svg/RenderSVGTransformableContainer.cpp
+++ b/Source/core/rendering/svg/RenderSVGTransformableContainer.cpp
@@ -46,11 +46,11 @@
     // need to respect the translations induced by their corresponding use elements x/y attributes.
     SVGUseElement* useElement = 0;
     if (element->hasTagName(SVGNames::useTag))
-        useElement = static_cast<SVGUseElement*>(element);
+        useElement = toSVGUseElement(element);
     else if (element->isInShadowTree() && element->hasTagName(SVGNames::gTag)) {
         SVGElement* correspondingElement = element->correspondingElement();
         if (correspondingElement && correspondingElement->hasTagName(SVGNames::useTag))
-            useElement = static_cast<SVGUseElement*>(correspondingElement);
+            useElement = toSVGUseElement(correspondingElement);
     }
 
     if (useElement) {
diff --git a/Source/core/rendering/svg/SVGInlineTextBox.cpp b/Source/core/rendering/svg/SVGInlineTextBox.cpp
index becc6bd..db62df8 100644
--- a/Source/core/rendering/svg/SVGInlineTextBox.cpp
+++ b/Source/core/rendering/svg/SVGInlineTextBox.cpp
@@ -606,7 +606,9 @@
 
     const Font& scaledFont = textRenderer->scaledFont();
     const ShadowData* shadow = style->textShadow();
-    bool hasShadow = shadow;
+
+    // Text shadows are disabled when printing. http://crbug.com/258321
+    bool hasShadow = shadow && !context->printing();
 
     FloatPoint textOrigin(fragment.x, fragment.y);
     FloatSize textSize(fragment.width, fragment.height);
diff --git a/Source/core/rendering/svg/SVGPathData.cpp b/Source/core/rendering/svg/SVGPathData.cpp
index 935e89f..aa69c37 100644
--- a/Source/core/rendering/svg/SVGPathData.cpp
+++ b/Source/core/rendering/svg/SVGPathData.cpp
@@ -72,8 +72,7 @@
 
 static void updatePathFromPathElement(SVGElement* element, Path& path)
 {
-    ASSERT(element->hasTagName(SVGNames::pathTag));
-    buildPathFromByteStream(static_cast<SVGPathElement*>(element)->pathByteStream(), path);
+    buildPathFromByteStream(toSVGPathElement(element)->pathByteStream(), path);
 }
 
 static void updatePathFromPolygonElement(SVGElement* element, Path& path)
diff --git a/Source/core/rendering/svg/SVGRenderTreeAsText.cpp b/Source/core/rendering/svg/SVGRenderTreeAsText.cpp
index 980fa19..a9c337e 100644
--- a/Source/core/rendering/svg/SVGRenderTreeAsText.cpp
+++ b/Source/core/rendering/svg/SVGRenderTreeAsText.cpp
@@ -357,7 +357,7 @@
         SVGPolyElement* element = static_cast<SVGPolyElement*>(svgElement);
         writeNameAndQuotedValue(ts, "points", element->pointList().valueAsString());
     } else if (svgElement->hasTagName(SVGNames::pathTag)) {
-        SVGPathElement* element = static_cast<SVGPathElement*>(svgElement);
+        SVGPathElement* element = toSVGPathElement(svgElement);
         String pathString;
         // FIXME: We should switch to UnalteredParsing here - this will affect the path dumping output of dozens of tests.
         buildStringFromByteStream(element->pathByteStream(), pathString, NormalizedParsing);
@@ -384,7 +384,7 @@
     ts << " contains 1 chunk(s)";
 
     if (text.parent() && (text.parent()->style()->visitedDependentColor(CSSPropertyColor) != text.style()->visitedDependentColor(CSSPropertyColor)))
-        writeNameValuePair(ts, "color", text.style()->visitedDependentColor(CSSPropertyColor).nameForRenderTreeAsText());
+        writeNameValuePair(ts, "color", text.resolveColor(CSSPropertyColor).nameForRenderTreeAsText());
 }
 
 static inline void writeSVGInlineTextBox(TextStream& ts, SVGInlineTextBox* textBox, int indent)
diff --git a/Source/core/rendering/svg/SVGRenderingContext.cpp b/Source/core/rendering/svg/SVGRenderingContext.cpp
index e4d7be5..6b9968b 100644
--- a/Source/core/rendering/svg/SVGRenderingContext.cpp
+++ b/Source/core/rendering/svg/SVGRenderingContext.cpp
@@ -102,12 +102,20 @@
     // Setup transparency layers before setting up SVG resources!
     bool isRenderingMask = isRenderingMaskImage(m_object);
     float opacity = isRenderingMask ? 1 : style->opacity();
+    BlendMode blendMode = isRenderingMask ? BlendModeNormal : style->blendMode();
     const ShadowData* shadow = svgStyle->shadow();
-    if (opacity < 1 || shadow) {
+    if (opacity < 1 || shadow || blendMode != BlendModeNormal) {
         FloatRect repaintRect = m_object->repaintRectInLocalCoordinates();
 
-        if (opacity < 1) {
+        if (opacity < 1 || blendMode != BlendModeNormal) {
             m_paintInfo->context->clip(repaintRect);
+            if (blendMode != BlendModeNormal) {
+                if (!(m_renderingFlags & RestoreGraphicsContext)) {
+                    m_paintInfo->context->save();
+                    m_renderingFlags |= RestoreGraphicsContext;
+                }
+                m_paintInfo->context->setCompositeOperation(CompositeSourceOver, blendMode);
+            }
             m_paintInfo->context->beginTransparencyLayer(opacity);
             m_renderingFlags |= EndOpacityLayer;
         }
diff --git a/Source/core/rendering/svg/SVGResources.cpp b/Source/core/rendering/svg/SVGResources.cpp
index e6c2564..f30edd1 100644
--- a/Source/core/rendering/svg/SVGResources.cpp
+++ b/Source/core/rendering/svg/SVGResources.cpp
@@ -145,7 +145,7 @@
     if (element->hasTagName(SVGNames::patternTag))
         target = static_cast<SVGPatternElement*>(element)->hrefCurrentValue();
     else if (element->hasTagName(SVGNames::linearGradientTag) || element->hasTagName(SVGNames::radialGradientTag))
-        target = static_cast<SVGGradientElement*>(element)->hrefCurrentValue();
+        target = toSVGGradientElement(element)->hrefCurrentValue();
     else if (element->hasTagName(SVGNames::filterTag))
         target = toSVGFilterElement(element)->hrefCurrentValue();
     else
diff --git a/Source/core/rendering/svg/SVGTextLayoutAttributesBuilder.cpp b/Source/core/rendering/svg/SVGTextLayoutAttributesBuilder.cpp
index 9ea1281..e7bb42b 100644
--- a/Source/core/rendering/svg/SVGTextLayoutAttributesBuilder.cpp
+++ b/Source/core/rendering/svg/SVGTextLayoutAttributesBuilder.cpp
@@ -44,7 +44,7 @@
         m_characterDataMap.clear();
 
         m_textLength = 0;
-        const UChar* lastCharacter = 0;
+        UChar lastCharacter = ' ';
         collectTextPositioningElements(textRoot, lastCharacter);
 
         if (!m_textLength)
@@ -64,7 +64,7 @@
 
     if (m_textPositions.isEmpty()) {
         m_textLength = 0;
-        const UChar* lastCharacter = 0;
+        UChar lastCharacter = ' ';
         collectTextPositioningElements(textRoot, lastCharacter);
     }
 
@@ -82,18 +82,17 @@
     m_metricsBuilder.measureTextRenderer(text);
 }
 
-static inline void processRenderSVGInlineText(RenderSVGInlineText* text, unsigned& atCharacter, const UChar*& lastCharacter)
+static inline void processRenderSVGInlineText(RenderSVGInlineText* text, unsigned& atCharacter, UChar& lastCharacter)
 {
     if (text->style()->whiteSpace() == PRE) {
         atCharacter += text->textLength();
         return;
     }
 
-    const UChar* characters = text->bloatedCharacters();
     unsigned textLength = text->textLength();    
     for (unsigned textPosition = 0; textPosition < textLength; ++textPosition) {
-        const UChar* currentCharacter = characters + textPosition;
-        if (*currentCharacter == ' ' && (!lastCharacter || *lastCharacter == ' '))
+        UChar currentCharacter = text->characterAt(textPosition);
+        if (currentCharacter == ' ' && lastCharacter == ' ')
             continue;
 
         lastCharacter = currentCharacter;
@@ -101,7 +100,7 @@
     }
 }
 
-void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderObject* start, const UChar*& lastCharacter)
+void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderObject* start, UChar& lastCharacter)
 {
     ASSERT(!start->isSVGText() || m_textPositions.isEmpty());
 
diff --git a/Source/core/rendering/svg/SVGTextLayoutAttributesBuilder.h b/Source/core/rendering/svg/SVGTextLayoutAttributesBuilder.h
index bbad6cb..f0e6fb0 100644
--- a/Source/core/rendering/svg/SVGTextLayoutAttributesBuilder.h
+++ b/Source/core/rendering/svg/SVGTextLayoutAttributesBuilder.h
@@ -66,7 +66,7 @@
     };
 
     void buildCharacterDataMap(RenderSVGText*);
-    void collectTextPositioningElements(RenderObject*, const UChar*& lastCharacter);
+    void collectTextPositioningElements(RenderObject*, UChar& lastCharacter);
     void fillCharacterDataMap(const TextPosition&);
 
 private:
diff --git a/Source/core/rendering/svg/SVGTextLayoutEngine.cpp b/Source/core/rendering/svg/SVGTextLayoutEngine.cpp
index cbdaf1b..793d14b 100644
--- a/Source/core/rendering/svg/SVGTextLayoutEngine.cpp
+++ b/Source/core/rendering/svg/SVGTextLayoutEngine.cpp
@@ -441,7 +441,6 @@
     Vector<SVGTextMetrics>& visualMetricsValues = text->layoutAttributes()->textMetricsValues();
     ASSERT(!visualMetricsValues.isEmpty());
 
-    const UChar* characters = text->bloatedCharacters();
     const Font& font = style->font();
 
     SVGTextLayoutEngineSpacing spacingLayout(font);
@@ -492,8 +491,8 @@
         float angle = data.rotate == SVGTextLayoutAttributes::emptyValue() ? 0 : data.rotate;
 
         // Calculate glyph orientation angle.
-        const UChar* currentCharacter = characters + m_visualCharacterOffset;
-        float orientationAngle = baselineLayout.calculateGlyphOrientationAngle(m_isVerticalText, svgStyle, *currentCharacter);
+        UChar currentCharacter = text->characterAt(m_visualCharacterOffset);
+        float orientationAngle = baselineLayout.calculateGlyphOrientationAngle(m_isVerticalText, svgStyle, currentCharacter);
 
         // Calculate glyph advance & x/y orientation shifts.
         float xOrientationShift = 0;
diff --git a/Source/core/rendering/svg/SVGTextLayoutEngineSpacing.cpp b/Source/core/rendering/svg/SVGTextLayoutEngineSpacing.cpp
index 6b95d09..b2360f0 100644
--- a/Source/core/rendering/svg/SVGTextLayoutEngineSpacing.cpp
+++ b/Source/core/rendering/svg/SVGTextLayoutEngineSpacing.cpp
@@ -82,7 +82,7 @@
 #endif
 }
 
-float SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing(const SVGRenderStyle* style, SVGElement* contextElement, const UChar* currentCharacter)
+float SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing(const SVGRenderStyle* style, SVGElement* contextElement, UChar currentCharacter)
 {
     float kerning = 0;
     SVGLength kerningLength = style->kerning();
@@ -93,7 +93,7 @@
         kerning = kerningLength.value(lengthContext);
     }
 
-    const UChar* lastCharacter = m_lastCharacter;
+    UChar lastCharacter = m_lastCharacter;
     m_lastCharacter = currentCharacter;
 
     if (!kerning && !m_font.letterSpacing() && !m_font.wordSpacing())
@@ -101,7 +101,7 @@
 
     float spacing = m_font.letterSpacing() + kerning;
     if (currentCharacter && lastCharacter && m_font.wordSpacing()) {
-        if (Font::treatAsSpace(*currentCharacter) && !Font::treatAsSpace(*lastCharacter))
+        if (Font::treatAsSpace(currentCharacter) && !Font::treatAsSpace(lastCharacter))
             spacing += m_font.wordSpacing();
     }
 
diff --git a/Source/core/rendering/svg/SVGTextLayoutEngineSpacing.h b/Source/core/rendering/svg/SVGTextLayoutEngineSpacing.h
index 78cfbe1..5cc8bec 100644
--- a/Source/core/rendering/svg/SVGTextLayoutEngineSpacing.h
+++ b/Source/core/rendering/svg/SVGTextLayoutEngineSpacing.h
@@ -35,11 +35,11 @@
     SVGTextLayoutEngineSpacing(const Font&);
 
     float calculateSVGKerning(bool isVerticalText, const SVGTextMetrics::Glyph& currentGlyph);
-    float calculateCSSKerningAndSpacing(const SVGRenderStyle*, SVGElement* lengthContext, const UChar* currentCharacter);
+    float calculateCSSKerningAndSpacing(const SVGRenderStyle*, SVGElement* lengthContext, UChar currentCharacter);
 
 private:
     const Font& m_font;
-    const UChar* m_lastCharacter;
+    UChar m_lastCharacter;
 
 #if ENABLE(SVG_FONTS)
     SVGTextMetrics::Glyph m_lastGlyph;
diff --git a/Source/core/scripts/StaticString.pm b/Source/core/scripts/StaticString.pm
index 99dfe2e..5636b7b 100644
--- a/Source/core/scripts/StaticString.pm
+++ b/Source/core/scripts/StaticString.pm
@@ -33,11 +33,6 @@
 
     my @result = ();
 
-    while ( my ($name, $value) = each %strings ) {
-        my $characterList = join("', '", split("", $value));
-        push(@result, "static const UChar ${name}String16[] = { '$characterList' };\n");
-    }
-
     push(@result, "\n");
 
     while ( my ($name, $value) = each %strings ) {
@@ -52,7 +47,6 @@
         push(@result, <<END);
 static StringImpl::StaticASCIILiteral ${name}Data = {
     ${name}String8,
-    ${name}String16,
     StringImpl::StaticASCIILiteral::s_initialRefCount,
     $length,
     StringImpl::StaticASCIILiteral::s_initialFlags | (${hash} << StringImpl::StaticASCIILiteral::s_hashShift)
diff --git a/Source/core/scripts/make_style_shorthands.py b/Source/core/scripts/make_style_shorthands.py
new file mode 100644
index 0000000..db5d188
--- /dev/null
+++ b/Source/core/scripts/make_style_shorthands.py
@@ -0,0 +1,87 @@
+#!/usr/bin/env python
+# Copyright (C) 2013 Intel Corporation. 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.
+
+import re
+import sys
+from collections import defaultdict
+
+import in_generator
+import template_expander
+
+
+class StylePropertyShorthandWriter(in_generator.Writer):
+    class_name = 'StylePropertyShorthand'
+
+    defaults = {
+        'longhands': "",
+    }
+
+    def __init__(self, in_files, enabled_conditions):
+        super(StylePropertyShorthandWriter, self).__init__(in_files, enabled_conditions)
+        self._outputs = {("StylePropertyShorthand.cpp"): self.generate_style_property_shorthand_cpp, ("StylePropertyShorthand.h"): self.generate_style_property_shorthand_h}
+
+        self._properties = self.in_file.name_dictionaries
+        self._longhand_dictionary = defaultdict(list)
+
+        for property in self._properties:
+            cc = self._camelcase_property_name(property["name"])
+            property["property_id"] = self._create_css_property_name_enum_value(cc)
+            cc = cc[0].lower() + cc[1:]
+            property["camel_case_name"] = cc
+            longhands = property["longhands"].split(';')
+            property["camel_case_longhands"] = list()
+            for longhand in longhands:
+                longhand = self._camelcase_property_name(longhand)
+                longhand = self._create_css_property_name_enum_value(longhand)
+                property["camel_case_longhands"].append(longhand)
+                self._longhand_dictionary[longhand].append(property)
+        self._properties = dict((property["property_id"], property) for property in self._properties)
+
+# FIXME: some of these might be better in a utils file
+    def _camelcase_property_name(self, property_name):
+        return re.sub(r'(^[^-])|-(.)', lambda match: (match.group(1) or match.group(2)).upper(), property_name)
+
+    def _create_css_property_name_enum_value(self, property_name):
+        return "CSSProperty" + property_name
+
+    @template_expander.use_jinja("StylePropertyShorthand.cpp.tmpl")
+    def generate_style_property_shorthand_cpp(self):
+        return {
+            "properties": self._properties,
+            "longhands_dictionary": self._longhand_dictionary,
+        }
+
+    @template_expander.use_jinja("StylePropertyShorthand.h.tmpl")
+    def generate_style_property_shorthand_h(self):
+        return {
+            "properties": self._properties,
+        }
+
+if __name__ == "__main__":
+    in_generator.Maker(StylePropertyShorthandWriter).main(sys.argv)
diff --git a/Source/core/scripts/templates/StyleBuilder.cpp.tmpl b/Source/core/scripts/templates/StyleBuilder.cpp.tmpl
index f5a4637..64b840d 100644
--- a/Source/core/scripts/templates/StyleBuilder.cpp.tmpl
+++ b/Source/core/scripts/templates/StyleBuilder.cpp.tmpl
@@ -58,7 +58,7 @@
 {%- endif %}
 
     case CSSValueInvalid:
-        length = primitiveValue->convertToLength<FixedIntegerConversion | CalculatedConversion | PercentConversion | ViewportPercentageConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom());
+        length = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom());
         length.setQuirk(primitiveValue->isQuirkValue());
         break;
     default:
diff --git a/Source/core/scripts/templates/StyleBuilderFunctions.cpp.tmpl b/Source/core/scripts/templates/StyleBuilderFunctions.cpp.tmpl
index 3d82503..f803622 100644
--- a/Source/core/scripts/templates/StyleBuilderFunctions.cpp.tmpl
+++ b/Source/core/scripts/templates/StyleBuilderFunctions.cpp.tmpl
@@ -247,8 +247,8 @@
     if (!pair || !pair->first() || !pair->second())
         return;
 
-    Length radiusWidth = pair->first()->convertToLength<FixedIntegerConversion | CalculatedConversion | PercentConversion | ViewportPercentageConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom());
-    Length radiusHeight = pair->second()->convertToLength<FixedIntegerConversion | CalculatedConversion | PercentConversion | ViewportPercentageConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom());
+    Length radiusWidth = pair->first()->convertToLength<FixedIntegerConversion | PercentConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom());
+    Length radiusHeight = pair->second()->convertToLength<FixedIntegerConversion | PercentConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom());
     int width = radiusWidth.value();
     int height = radiusHeight.value();
     if (width < 0 || height < 0)
diff --git a/Source/core/scripts/templates/StylePropertyShorthand.cpp.tmpl b/Source/core/scripts/templates/StylePropertyShorthand.cpp.tmpl
new file mode 100644
index 0000000..2a5f803
--- /dev/null
+++ b/Source/core/scripts/templates/StylePropertyShorthand.cpp.tmpl
@@ -0,0 +1,80 @@
+/*
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2013 Intel Corporation. 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.
+ */
+
+#include "config.h"
+#include "StylePropertyShorthand.h"
+
+#include "wtf/HashMap.h"
+#include "wtf/StdLibExtras.h"
+
+namespace WebCore {
+
+{%- for property_id, property in properties.items() %}
+{% if property.camel_case_name != "border" %}
+const StylePropertyShorthand& {{ property.camel_case_name }}Shorthand()
+{
+    static const CSSPropertyID {{ property.camel_case_name }}Properties[] = {
+        {%- for longhand_id in property.camel_case_longhands %}
+        {{ longhand_id }},
+        {%- endfor %}
+    };
+    DEFINE_STATIC_LOCAL(StylePropertyShorthand, {{ property.camel_case_name }}Longhands, ({{ property_id }}, {{ property.camel_case_name }}Properties, WTF_ARRAY_LENGTH({{ property.camel_case_name }}Properties)));
+    return {{ property.camel_case_name }}Longhands;
+}
+{%- endif -%}
+{% endfor %}
+
+// Returns an empty list if the property is not a shorthand
+const StylePropertyShorthand& shorthandForProperty(CSSPropertyID propertyID)
+{
+    switch (propertyID) {
+{%- for property_id, property in properties.items() %}
+    {%- if property.camel_case_name not in ["width", "height", "marker"] %}
+        case {{ property_id }}:
+            return {{ property.camel_case_name }}Shorthand();
+    {%- endif %}
+{%- endfor %}
+    default: {
+        DEFINE_STATIC_LOCAL(StylePropertyShorthand, emptyShorthand, ());
+        return emptyShorthand;
+    }
+    }
+}
+
+typedef HashMap<CSSPropertyID, Vector<StylePropertyShorthand> > longhandsMap;
+const Vector<StylePropertyShorthand> matchingShorthandsForLonghand(CSSPropertyID propertyID)
+{
+    DEFINE_STATIC_LOCAL(longhandsMap, map, ());
+    if (map.isEmpty()) {
+{%- for longhand_id, shorthands in longhands_dictionary.items() %}
+
+        Vector<StylePropertyShorthand, {{ shorthands|length }}> {{ longhand_id }}Shorthands;
+        {% for shorthand in shorthands -%}
+            {{ longhand_id }}Shorthands.uncheckedAppend({{ shorthand.camel_case_name }}Shorthand());
+        {% endfor -%}
+        map.set({{ longhand_id }}, {{ longhand_id }}Shorthands);
+{%- endfor %}
+    }
+    return map.get(propertyID);
+}
+
+} // namespace WebCore
+
diff --git a/Source/core/scripts/templates/StylePropertyShorthand.h.tmpl b/Source/core/scripts/templates/StylePropertyShorthand.h.tmpl
new file mode 100644
index 0000000..2bf0382
--- /dev/null
+++ b/Source/core/scripts/templates/StylePropertyShorthand.h.tmpl
@@ -0,0 +1,87 @@
+/*
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2013 Intel Corporation. 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 StylePropertyShorthand_h
+#define StylePropertyShorthand_h
+
+#include "CSSPropertyNames.h"
+#include "wtf/Vector.h"
+
+namespace WebCore {
+
+class StylePropertyShorthand {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    StylePropertyShorthand()
+        : m_properties(0)
+        , m_propertiesForInitialization(0)
+        , m_length(0)
+        , m_shorthandID(CSSPropertyInvalid)
+    {
+    }
+
+    StylePropertyShorthand(CSSPropertyID id, const CSSPropertyID* properties, unsigned numProperties)
+        : m_properties(properties)
+        , m_propertiesForInitialization(0)
+        , m_length(numProperties)
+        , m_shorthandID(id)
+    {
+    }
+
+    StylePropertyShorthand(CSSPropertyID id, const CSSPropertyID* properties, const StylePropertyShorthand** propertiesForInitialization, unsigned numProperties)
+        : m_properties(properties)
+        , m_propertiesForInitialization(propertiesForInitialization)
+        , m_length(numProperties)
+        , m_shorthandID(id)
+    {
+    }
+
+    const CSSPropertyID* properties() const { return m_properties; }
+    const StylePropertyShorthand** propertiesForInitialization() const { return m_propertiesForInitialization; }
+    unsigned length() const { return m_length; }
+    CSSPropertyID id() const { return m_shorthandID; }
+
+private:
+    const CSSPropertyID* m_properties;
+    const StylePropertyShorthand** m_propertiesForInitialization;
+    unsigned m_length;
+    CSSPropertyID m_shorthandID;
+};
+
+{% for property_id, property in properties.items() %}
+{%- set camel_case_name = property.camel_case_name %}
+const StylePropertyShorthand& {{ camel_case_name }}Shorthand();
+{%- endfor %}
+const StylePropertyShorthand& borderShorthandForParsing();
+const StylePropertyShorthand& webkitAnimationShorthandForParsing();
+
+// Returns an empty list if the property is not a shorthand.
+const StylePropertyShorthand& shorthandForProperty(CSSPropertyID);
+
+// Return the list of shorthands for a given longhand.
+const Vector<StylePropertyShorthand> matchingShorthandsForLonghand(CSSPropertyID);
+unsigned indexOfShorthandForLonghand(CSSPropertyID, const Vector<StylePropertyShorthand>&);
+
+bool isExpandedShorthand(CSSPropertyID);
+
+} // namespace WebCore
+
+#endif // StylePropertyShorthand_h
diff --git a/Source/core/svg/SVGAnimateMotionElement.cpp b/Source/core/svg/SVGAnimateMotionElement.cpp
index 86fc661..15ab56c 100644
--- a/Source/core/svg/SVGAnimateMotionElement.cpp
+++ b/Source/core/svg/SVGAnimateMotionElement.cpp
@@ -231,18 +231,6 @@
     return true;
 }
 
-void SVGAnimateMotionElement::buildTransformForProgress(AffineTransform* transform, float percentage)
-{
-    ASSERT(!m_animationPath.isEmpty());
-
-    bool ok = false;
-    float positionOnPath = m_animationPath.length() * percentage;
-    FloatPoint position = m_animationPath.pointAtLength(positionOnPath, ok);
-    if (!ok)
-        return;
-    transform->translate(position.x(), position.y());
-}
-
 void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement*)
 {
     SVGElement* targetElement = this->targetElement();
@@ -273,19 +261,24 @@
         return;
     }
 
-    buildTransformForProgress(transform, percentage);
-
-    // Handle accumulate="sum".
-    if (isAccumulated() && repeatCount) {
-        for (unsigned i = 0; i < repeatCount; ++i)
-            buildTransformForProgress(transform, 1);
-    }
+    ASSERT(!m_animationPath.isEmpty());
 
     bool ok = false;
     float positionOnPath = m_animationPath.length() * percentage;
-    float angle = m_animationPath.normalAngleAtLength(positionOnPath, ok);
+    FloatPoint position;
+    float angle;
+    ok = m_animationPath.pointAndNormalAtLength(positionOnPath, position, angle);
     if (!ok)
         return;
+
+    // Handle accumulate="sum".
+    if (isAccumulated() && repeatCount) {
+        FloatPoint positionAtEndOfDuration = m_animationPath.pointAtLength(m_animationPath.length(), ok);
+        if (ok)
+            position.move(positionAtEndOfDuration.x() * repeatCount, positionAtEndOfDuration.y() * repeatCount);
+    }
+
+    transform->translate(position.x(), position.y());
     RotateMode rotateMode = this->rotateMode();
     if (rotateMode != RotateAuto && rotateMode != RotateAutoReverse)
         return;
diff --git a/Source/core/svg/SVGAnimateMotionElement.h b/Source/core/svg/SVGAnimateMotionElement.h
index 2be152c..252e663 100644
--- a/Source/core/svg/SVGAnimateMotionElement.h
+++ b/Source/core/svg/SVGAnimateMotionElement.h
@@ -57,7 +57,6 @@
         RotateAutoReverse
     };
     RotateMode rotateMode() const;
-    void buildTransformForProgress(AffineTransform*, float percentage);
 
     bool m_hasToPointAtEndOfDuration;
 
diff --git a/Source/core/svg/SVGExternalResourcesRequired.idl b/Source/core/svg/SVGExternalResourcesRequired.idl
index 50f8471..d80071c 100644
--- a/Source/core/svg/SVGExternalResourcesRequired.idl
+++ b/Source/core/svg/SVGExternalResourcesRequired.idl
@@ -25,7 +25,8 @@
  */
 
 [
-    NoInterfaceObject
+    NoInterfaceObject,
+    LegacyImplementedInBaseClass
 ] interface SVGExternalResourcesRequired { 
     readonly attribute SVGAnimatedBoolean externalResourcesRequired;
 };
diff --git a/Source/core/svg/SVGFilterPrimitiveStandardAttributes.idl b/Source/core/svg/SVGFilterPrimitiveStandardAttributes.idl
index 62fb567..3f1e56b 100644
--- a/Source/core/svg/SVGFilterPrimitiveStandardAttributes.idl
+++ b/Source/core/svg/SVGFilterPrimitiveStandardAttributes.idl
@@ -25,7 +25,8 @@
  */
 
 [
-    NoInterfaceObject
+    NoInterfaceObject,
+    LegacyImplementedInBaseClass
 ] interface SVGFilterPrimitiveStandardAttributes {
     readonly attribute SVGAnimatedLength x;
     readonly attribute SVGAnimatedLength y;
diff --git a/Source/core/svg/SVGFitToViewBox.idl b/Source/core/svg/SVGFitToViewBox.idl
index a6388ab..0cd3b52 100644
--- a/Source/core/svg/SVGFitToViewBox.idl
+++ b/Source/core/svg/SVGFitToViewBox.idl
@@ -25,7 +25,8 @@
  */
 
 [
-    NoInterfaceObject
+    NoInterfaceObject,
+    LegacyImplementedInBaseClass
 ] interface SVGFitToViewBox {
     readonly attribute SVGAnimatedRect                viewBox;
     readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio;
diff --git a/Source/core/svg/SVGGradientElement.h b/Source/core/svg/SVGGradientElement.h
index 09cb256..dc578af 100644
--- a/Source/core/svg/SVGGradientElement.h
+++ b/Source/core/svg/SVGGradientElement.h
@@ -21,6 +21,7 @@
 #ifndef SVGGradientElement_h
 #define SVGGradientElement_h
 
+#include "SVGNames.h"
 #include "core/platform/graphics/Gradient.h"
 #include "core/svg/SVGAnimatedBoolean.h"
 #include "core/svg/SVGAnimatedEnumeration.h"
@@ -106,6 +107,12 @@
     END_DECLARE_ANIMATED_PROPERTIES
 };
 
+inline SVGGradientElement* toSVGGradientElement(Node* node)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(!node || (node->hasTagName(SVGNames::radialGradientTag) || node->hasTagName(SVGNames::linearGradientTag)));
+    return static_cast<SVGGradientElement*>(node);
+}
+
 } // namespace WebCore
 
 #endif
diff --git a/Source/core/svg/SVGLinearGradientElement.cpp b/Source/core/svg/SVGLinearGradientElement.cpp
index b74bf9c..700b2ab 100644
--- a/Source/core/svg/SVGLinearGradientElement.cpp
+++ b/Source/core/svg/SVGLinearGradientElement.cpp
@@ -168,7 +168,7 @@
         // Respect xlink:href, take attributes from referenced element
         Node* refNode = SVGURIReference::targetElementFromIRIString(current->hrefCurrentValue(), document());
         if (refNode && (refNode->hasTagName(SVGNames::linearGradientTag) || refNode->hasTagName(SVGNames::radialGradientTag))) {
-            current = static_cast<SVGGradientElement*>(refNode);
+            current = toSVGGradientElement(refNode);
 
             // Cycle detection
             if (processedGradients.contains(current)) {
diff --git a/Source/core/svg/SVGMPathElement.cpp b/Source/core/svg/SVGMPathElement.cpp
index 93a21c8..5930ccc 100644
--- a/Source/core/svg/SVGMPathElement.cpp
+++ b/Source/core/svg/SVGMPathElement.cpp
@@ -154,7 +154,7 @@
 {
     Element* target = targetElementFromIRIString(hrefCurrentValue(), document());
     if (target && target->hasTagName(SVGNames::pathTag))
-        return static_cast<SVGPathElement*>(target);
+        return toSVGPathElement(target);
     return 0;
 }
 
diff --git a/Source/core/svg/SVGMarkerElement.h b/Source/core/svg/SVGMarkerElement.h
index 71593e7..df6a0c5 100644
--- a/Source/core/svg/SVGMarkerElement.h
+++ b/Source/core/svg/SVGMarkerElement.h
@@ -164,10 +164,10 @@
     mutable SVGSynchronizableAnimatedProperty<SVGMarkerOrientType> m_orientType;
 };
 
-inline SVGMarkerElement* toSVGMarkerElement(SVGElement* element)
+inline SVGMarkerElement* toSVGMarkerElement(Node* node)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(!element || element->hasTagName(SVGNames::markerTag));
-    return static_cast<SVGMarkerElement*>(element);
+    ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::markerTag));
+    return static_cast<SVGMarkerElement*>(node);
 }
 
 }
diff --git a/Source/core/svg/SVGPathElement.h b/Source/core/svg/SVGPathElement.h
index 99f68e9..0ee1888 100644
--- a/Source/core/svg/SVGPathElement.h
+++ b/Source/core/svg/SVGPathElement.h
@@ -130,7 +130,7 @@
     bool m_isAnimValObserved;
 };
 
-inline SVGPathElement* toSVGPathElement(SVGElement* element)
+inline SVGPathElement* toSVGPathElement(Element* element)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!element || element->hasTagName(SVGNames::pathTag));
     return static_cast<SVGPathElement*>(element);
diff --git a/Source/core/svg/SVGPathSegList.cpp b/Source/core/svg/SVGPathSegList.cpp
index e10e1fa..475a043 100644
--- a/Source/core/svg/SVGPathSegList.cpp
+++ b/Source/core/svg/SVGPathSegList.cpp
@@ -40,8 +40,7 @@
 void SVGPathSegList::commitChange(SVGElement* contextElement, ListModification listModification)
 {
     ASSERT(contextElement);
-    ASSERT(contextElement->hasTagName(SVGNames::pathTag));
-    static_cast<SVGPathElement*>(contextElement)->pathSegListChanged(m_role, listModification);
+    toSVGPathElement(contextElement)->pathSegListChanged(m_role, listModification);
 }
 
 }
diff --git a/Source/core/svg/SVGRadialGradientElement.cpp b/Source/core/svg/SVGRadialGradientElement.cpp
index 9fcd9a7..d20683d 100644
--- a/Source/core/svg/SVGRadialGradientElement.cpp
+++ b/Source/core/svg/SVGRadialGradientElement.cpp
@@ -185,7 +185,7 @@
         // Respect xlink:href, take attributes from referenced element
         Node* refNode = SVGURIReference::targetElementFromIRIString(current->hrefCurrentValue(), document());
         if (refNode && (refNode->hasTagName(SVGNames::radialGradientTag) || refNode->hasTagName(SVGNames::linearGradientTag))) {
-            current = static_cast<SVGGradientElement*>(refNode);
+            current = toSVGGradientElement(refNode);
 
             // Cycle detection
             if (processedGradients.contains(current)) {
diff --git a/Source/core/svg/SVGStyledElement.cpp b/Source/core/svg/SVGStyledElement.cpp
index 718a938..20fd2e0 100644
--- a/Source/core/svg/SVGStyledElement.cpp
+++ b/Source/core/svg/SVGStyledElement.cpp
@@ -90,7 +90,7 @@
         // that do enable SVG in a shadow tree.
         ASSERT(!shadowHostElement || shadowHostElement->hasTagName(SVGNames::useTag));
         if (shadowHostElement && shadowHostElement->hasTagName(SVGNames::useTag)) {
-            SVGUseElement* useElement = static_cast<SVGUseElement*>(shadowHostElement);
+            SVGUseElement* useElement = toSVGUseElement(shadowHostElement);
  
             // If the <use> title is not empty we found the title to use.
             String useTitle(useElement->title());
diff --git a/Source/core/svg/SVGTests.idl b/Source/core/svg/SVGTests.idl
index e2eaa13..7a25e46 100644
--- a/Source/core/svg/SVGTests.idl
+++ b/Source/core/svg/SVGTests.idl
@@ -25,7 +25,8 @@
  */
 
 [
-    NoInterfaceObject
+    NoInterfaceObject,
+    LegacyImplementedInBaseClass
 ] interface SVGTests {
     readonly attribute SVGStringList requiredFeatures;
     readonly attribute SVGStringList requiredExtensions;
diff --git a/Source/core/svg/SVGURIReference.idl b/Source/core/svg/SVGURIReference.idl
index 06dcca9..d7aceff 100644
--- a/Source/core/svg/SVGURIReference.idl
+++ b/Source/core/svg/SVGURIReference.idl
@@ -25,7 +25,8 @@
  */
 
 [
-    NoInterfaceObject
+    NoInterfaceObject,
+    LegacyImplementedInBaseClass
 ] interface SVGURIReference {
     readonly attribute SVGAnimatedString href;
 };
diff --git a/Source/core/svg/SVGUseElement.cpp b/Source/core/svg/SVGUseElement.cpp
index a1aeec2..87f7faf 100644
--- a/Source/core/svg/SVGUseElement.cpp
+++ b/Source/core/svg/SVGUseElement.cpp
@@ -270,7 +270,7 @@
     ASSERT(element);
 
     if (element->hasTagName(SVGNames::useTag)) {
-        if (static_cast<SVGUseElement*>(element)->cachedDocumentIsStillLoading())
+        if (toSVGUseElement(element)->cachedDocumentIsStillLoading())
             return;
     }
 
@@ -579,7 +579,7 @@
     bool targetHasUseTag = target->hasTagName(SVGNames::useTag);
     SVGElement* newTarget = 0;
     if (targetHasUseTag) {
-        foundProblem = hasCycleUseReferencing(static_cast<SVGUseElement*>(target), targetInstance, newTarget);
+        foundProblem = hasCycleUseReferencing(toSVGUseElement(target), targetInstance, newTarget);
         if (foundProblem)
             return;
 
@@ -625,7 +625,7 @@
     if (!targetHasUseTag || !newTarget)
         return;
 
-    RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, static_cast<SVGUseElement*>(target), newTarget);
+    RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, toSVGUseElement(target), newTarget);
     SVGElementInstance* newInstancePtr = newInstance.get();
     targetInstance->appendChild(newInstance.release());
     buildInstanceTree(newTarget, newInstancePtr, foundProblem, foundUse);
@@ -702,7 +702,7 @@
     // actual shadow tree (after the special case modification for svg/symbol) we have
     // to walk it completely and expand all <use> elements.
     if (element->hasTagName(SVGNames::useTag)) {
-        SVGUseElement* use = static_cast<SVGUseElement*>(element);
+        SVGUseElement* use = toSVGUseElement(element);
         ASSERT(!use->cachedDocumentIsStillLoading());
 
         Element* targetElement = SVGURIReference::targetElementFromIRIString(use->hrefCurrentValue(), referencedDocument());
diff --git a/Source/core/svg/SVGUseElement.h b/Source/core/svg/SVGUseElement.h
index b659fac..942a3e5 100644
--- a/Source/core/svg/SVGUseElement.h
+++ b/Source/core/svg/SVGUseElement.h
@@ -21,6 +21,7 @@
 #ifndef SVGUseElement_h
 #define SVGUseElement_h
 
+#include "SVGNames.h"
 #include "core/loader/cache/CachedDocument.h"
 #include "core/svg/SVGAnimatedBoolean.h"
 #include "core/svg/SVGAnimatedLength.h"
@@ -124,6 +125,12 @@
     Timer<SVGElement> m_svgLoadEventTimer;
 };
 
+inline SVGUseElement* toSVGUseElement(Node* node)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::useTag));
+    return static_cast<SVGUseElement*>(node);
+}
+
 }
 
 #endif
diff --git a/Source/core/svg/SVGZoomAndPan.idl b/Source/core/svg/SVGZoomAndPan.idl
index edc9f8e..24dc1c4 100644
--- a/Source/core/svg/SVGZoomAndPan.idl
+++ b/Source/core/svg/SVGZoomAndPan.idl
@@ -25,7 +25,8 @@
  */
 
 [
-    NoInterfaceObject
+    NoInterfaceObject,
+    LegacyImplementedInBaseClass
 ] interface SVGZoomAndPan {
     const unsigned short SVG_ZOOMANDPAN_UNKNOWN = 0;
     const unsigned short SVG_ZOOMANDPAN_DISABLE = 1;
diff --git a/Source/core/svg/animation/SMILTimeContainer.cpp b/Source/core/svg/animation/SMILTimeContainer.cpp
index 01f0677..b29e12d 100644
--- a/Source/core/svg/animation/SMILTimeContainer.cpp
+++ b/Source/core/svg/animation/SMILTimeContainer.cpp
@@ -40,7 +40,8 @@
 SMILTimeContainer::SMILTimeContainer(SVGSVGElement* owner) 
     : m_beginTime(0)
     , m_pauseTime(0)
-    , m_accumulatedPauseTime(0)
+    , m_resumeTime(0)
+    , m_accumulatedActiveTime(0)
     , m_presetStartTime(0)
     , m_documentOrderIndexesDirty(false)
     , m_timer(this, &SMILTimeContainer::timerFired)
@@ -107,7 +108,11 @@
 {
     if (!m_beginTime)
         return 0;
-    return currentTime() - m_beginTime - m_accumulatedPauseTime;
+
+    if (isPaused())
+        return m_accumulatedActiveTime;
+
+    return currentTime() + m_accumulatedActiveTime - lastResumeTime();
 }
 
 bool SMILTimeContainer::isActive() const
@@ -147,16 +152,17 @@
     ASSERT(!isPaused());
     m_pauseTime = currentTime();
 
-    if (m_beginTime)
+    if (m_beginTime) {
+        m_accumulatedActiveTime += m_pauseTime - lastResumeTime();
         m_timer.stop();
+    }
+    m_resumeTime = 0;
 }
 
 void SMILTimeContainer::resume()
 {
     ASSERT(isPaused());
-
-    if (m_beginTime)
-        m_accumulatedPauseTime += currentTime() - m_pauseTime;
+    m_resumeTime = currentTime();
 
     m_pauseTime = 0;
     startTimer(0);
@@ -176,9 +182,12 @@
     double now = currentTime();
     m_beginTime = now - time.value();
 
-    m_accumulatedPauseTime = 0;
-    if (m_pauseTime)
-        m_pauseTime = now;
+    if (m_pauseTime) {
+        m_resumeTime = m_pauseTime = now;
+        m_accumulatedActiveTime = time.value();
+    } else {
+        m_resumeTime = 0;
+    }
 
 #ifndef NDEBUG
     m_preventScheduledAnimationsChanges = true;
diff --git a/Source/core/svg/animation/SMILTimeContainer.h b/Source/core/svg/animation/SMILTimeContainer.h
index 2eae5df..7c59c57 100644
--- a/Source/core/svg/animation/SMILTimeContainer.h
+++ b/Source/core/svg/animation/SMILTimeContainer.h
@@ -73,10 +73,12 @@
     
     void updateDocumentOrderIndexes();
     void sortByPriority(Vector<SVGSMILElement*>& smilElements, SMILTime elapsed);
+    double lastResumeTime() const { return m_resumeTime ? m_resumeTime : m_beginTime; }
 
     double m_beginTime;
     double m_pauseTime;
-    double m_accumulatedPauseTime;
+    double m_resumeTime;
+    double m_accumulatedActiveTime;
     double m_presetStartTime;
 
     bool m_documentOrderIndexesDirty;
diff --git a/Source/core/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h b/Source/core/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h
index 404406d..dfdb6d4 100644
--- a/Source/core/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h
+++ b/Source/core/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h
@@ -88,7 +88,7 @@
     void animValDidChange()
     {
         ASSERT(m_animatedPathByteStream);
-        SVGPathElement* pathElement = static_cast<SVGPathElement*>(contextElement());
+        SVGPathElement* pathElement = toSVGPathElement(contextElement());
 
         // If the animVal is observed from JS, we have to update it on each animation step.
         // This is an expensive operation and only done, if someone actually observes the animatedPathSegList() while an animation is running.
diff --git a/Source/core/svg/properties/SVGAttributeToPropertyMap.cpp b/Source/core/svg/properties/SVGAttributeToPropertyMap.cpp
index efc164e..18a1079 100644
--- a/Source/core/svg/properties/SVGAttributeToPropertyMap.cpp
+++ b/Source/core/svg/properties/SVGAttributeToPropertyMap.cpp
@@ -29,31 +29,36 @@
 {
     AttributeToPropertiesMap::const_iterator end = map.m_map.end();
     for (AttributeToPropertiesMap::const_iterator it = map.m_map.begin(); it != end; ++it) {
-        const PropertiesVector* vector = it->value.get();
-        ASSERT(vector);
+        const PropertiesVector* mapVector = it->value.get();
+        ASSERT(mapVector);
 
-        // FIXME: This looks up the attribute name in the hash table for each property, even though all the
-        // properties in a single vector are guaranteed to have the same attribute name.
-        // FIXME: This grows the vector one item at a time, even though we know up front exactly how many
-        // elements we are adding to the vector.
-        PropertiesVector::const_iterator vectorEnd = vector->end();
-        for (PropertiesVector::const_iterator vectorIt = vector->begin(); vectorIt != vectorEnd; ++vectorIt)
-            addProperty(*vectorIt);
+        if (!mapVector->isEmpty()) {
+            const SVGPropertyInfo* firstProperty = mapVector->first();
+            ASSERT(firstProperty);
+            const QualifiedName& attributeName = firstProperty->attributeName;
+
+            // All of the properties in mapVector are guaranteed to have the same attribute name.
+            // Add them to our properties vector for that attribute name, reserving capacity up
+            // front.
+            PropertiesVector* vector = getOrCreatePropertiesVector(attributeName);
+            ASSERT(vector);
+            vector->reserveCapacity(vector->size() + mapVector->size());
+            const PropertiesVector::const_iterator mapVectorEnd = mapVector->end();
+            for (PropertiesVector::const_iterator mapVectorIt = mapVector->begin(); mapVectorIt != mapVectorEnd; ++mapVectorIt) {
+                ASSERT(*mapVectorIt);
+                ASSERT(attributeName == (*mapVectorIt)->attributeName);
+                vector->append(*mapVectorIt);
+            }
+        }
     }
 }
 
 void SVGAttributeToPropertyMap::addProperty(const SVGPropertyInfo* info)
 {
     ASSERT(info);
-    ASSERT(info->attributeName != anyQName());
-    if (PropertiesVector* vector = m_map.get(info->attributeName)) {
-        vector->append(info);
-        return;
-    }
-    // FIXME: This does a second hash table lookup, but with HashMap::add we could instead do only one.
-    OwnPtr<PropertiesVector> vector = adoptPtr(new PropertiesVector);
+    PropertiesVector* vector = getOrCreatePropertiesVector(info->attributeName);
+    ASSERT(vector);
     vector->append(info);
-    m_map.set(info->attributeName, vector.release());
 }
 
 void SVGAttributeToPropertyMap::animatedPropertiesForAttribute(SVGElement* ownerType, const QualifiedName& attributeName, Vector<RefPtr<SVGAnimatedProperty> >& properties)
@@ -63,7 +68,8 @@
     if (!vector)
         return;
 
-    PropertiesVector::iterator vectorEnd = vector->end();
+    properties.reserveCapacity(properties.size() + vector->size());
+    const PropertiesVector::iterator vectorEnd = vector->end();
     for (PropertiesVector::iterator vectorIt = vector->begin(); vectorIt != vectorEnd; ++vectorIt)
         properties.append(animatedProperty(ownerType, attributeName, *vectorIt));
 }
@@ -74,7 +80,8 @@
     if (!vector)
         return;
 
-    PropertiesVector::iterator vectorEnd = vector->end();
+    propertyTypes.reserveCapacity(propertyTypes.size() + vector->size());
+    const PropertiesVector::iterator vectorEnd = vector->end();
     for (PropertiesVector::iterator vectorIt = vector->begin(); vectorIt != vectorEnd; ++vectorIt)
         propertyTypes.append((*vectorIt)->animatedPropertyType);
 }
@@ -82,12 +89,12 @@
 void SVGAttributeToPropertyMap::synchronizeProperties(SVGElement* contextElement)
 {
     ASSERT(contextElement);
-    AttributeToPropertiesMap::iterator end = m_map.end();
+    const AttributeToPropertiesMap::iterator end = m_map.end();
     for (AttributeToPropertiesMap::iterator it = m_map.begin(); it != end; ++it) {
         PropertiesVector* vector = it->value.get();
         ASSERT(vector);
 
-        PropertiesVector::iterator vectorEnd = vector->end();
+        const PropertiesVector::iterator vectorEnd = vector->end();
         for (PropertiesVector::iterator vectorIt = vector->begin(); vectorIt != vectorEnd; ++vectorIt)
             synchronizeProperty(contextElement, it->key, *vectorIt);
     } 
@@ -100,13 +107,27 @@
     if (!vector)
         return false;
 
-    PropertiesVector::iterator vectorEnd = vector->end();
+    const PropertiesVector::iterator vectorEnd = vector->end();
     for (PropertiesVector::iterator vectorIt = vector->begin(); vectorIt != vectorEnd; ++vectorIt)
         synchronizeProperty(contextElement, attributeName, *vectorIt);
 
     return true;
 }
 
+SVGAttributeToPropertyMap::PropertiesVector* SVGAttributeToPropertyMap::getOrCreatePropertiesVector(const QualifiedName& attributeName)
+{
+    ASSERT(attributeName != anyQName());
+    AttributeToPropertiesMap::AddResult addResult = m_map.add(attributeName, PassOwnPtr<PropertiesVector>());
+    PropertiesVector* vector = addResult.iterator->value.get();
+    if (addResult.isNewEntry) {
+        ASSERT(!vector);
+        vector = (addResult.iterator->value = adoptPtr(new PropertiesVector)).get();
+    }
+    ASSERT(vector);
+    ASSERT(addResult.iterator->value.get() == vector);
+    return vector;
+}
+
 void SVGAttributeToPropertyMap::synchronizeProperty(SVGElement* contextElement, const QualifiedName& attributeName, const SVGPropertyInfo* info)
 {
     ASSERT(info);
diff --git a/Source/core/svg/properties/SVGAttributeToPropertyMap.h b/Source/core/svg/properties/SVGAttributeToPropertyMap.h
index f277b5b..d2e04cf 100644
--- a/Source/core/svg/properties/SVGAttributeToPropertyMap.h
+++ b/Source/core/svg/properties/SVGAttributeToPropertyMap.h
@@ -29,6 +29,10 @@
 class SVGElement;
 
 class SVGAttributeToPropertyMap {
+private:
+    typedef Vector<const SVGPropertyInfo*> PropertiesVector;
+    typedef HashMap<QualifiedName, OwnPtr<PropertiesVector> > AttributeToPropertiesMap;
+
 public:
     bool isEmpty() const { return m_map.isEmpty(); }
 
@@ -44,11 +48,10 @@
     bool synchronizeProperty(SVGElement* contextElement, const QualifiedName& attributeName);
 
 private:
+    PropertiesVector* getOrCreatePropertiesVector(const QualifiedName&);
     void synchronizeProperty(SVGElement* contextElement, const QualifiedName& attributeName, const SVGPropertyInfo*);
     PassRefPtr<SVGAnimatedProperty> animatedProperty(SVGElement* contextElement, const QualifiedName& attributeName, const SVGPropertyInfo*);
 
-    typedef Vector<const SVGPropertyInfo*> PropertiesVector;
-    typedef HashMap<QualifiedName, OwnPtr<PropertiesVector> > AttributeToPropertiesMap;
     AttributeToPropertiesMap m_map;
 };
 
diff --git a/Source/core/svg/properties/SVGPathSegListPropertyTearOff.cpp b/Source/core/svg/properties/SVGPathSegListPropertyTearOff.cpp
index b090664..6a15cad 100644
--- a/Source/core/svg/properties/SVGPathSegListPropertyTearOff.cpp
+++ b/Source/core/svg/properties/SVGPathSegListPropertyTearOff.cpp
@@ -89,8 +89,7 @@
 {
     SVGElement* contextElement = m_animatedProperty->contextElement();
     ASSERT(contextElement);
-    ASSERT(contextElement->hasTagName(SVGNames::pathTag));
-    return static_cast<SVGPathElement*>(contextElement);
+    return toSVGPathElement(contextElement);
 }
 
 bool SVGPathSegListPropertyTearOff::processIncomingListItemValue(const ListItemType& newItem, unsigned* indexToModify)
diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp
index 8f73675..6823d00 100644
--- a/Source/core/testing/Internals.cpp
+++ b/Source/core/testing/Internals.cpp
@@ -32,12 +32,16 @@
 #include "InternalProfilers.h"
 #include "InternalRuntimeFlags.h"
 #include "InternalSettings.h"
+#include "LayerRect.h"
+#include "LayerRectList.h"
 #include "MallocStatistics.h"
 #include "MockPagePopupDriver.h"
 #include "RuntimeEnabledFeatures.h"
 #include "TypeConversions.h"
 #include "bindings/v8/SerializedScriptValue.h"
 #include "core/css/StyleSheetContents.h"
+#include "core/css/resolver/StyleResolver.h"
+#include "core/css/resolver/ViewportStyleResolver.h"
 #include "core/dom/ClientRect.h"
 #include "core/dom/ClientRectList.h"
 #include "core/dom/DOMStringList.h"
@@ -174,6 +178,9 @@
 
 Internals::~Internals()
 {
+    if (m_scrollingCoordinator) {
+        m_scrollingCoordinator->removeTouchEventTargetRectsObserver(this);
+    }
 }
 
 void Internals::resetToConsistentState(Page* page)
@@ -198,7 +205,12 @@
 Internals::Internals(Document* document)
     : ContextLifecycleObserver(document)
     , m_runtimeFlags(InternalRuntimeFlags::create())
+    , m_scrollingCoordinator(document->page()->scrollingCoordinator())
+    , m_touchEventTargetRectUpdateCount(0)
 {
+    if (m_scrollingCoordinator) {
+        m_scrollingCoordinator->addTouchEventTargetRectsObserver(this);
+    }
 }
 
 Document* Internals::contextDocument() const
@@ -909,7 +921,7 @@
     page->setPagination(pagination);
 }
 
-String Internals::configurationForViewport(Document* document, float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode& ec)
+String Internals::configurationForViewport(Document* document, float, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode& ec)
 {
     if (!document || !document->page()) {
         ec = InvalidAccessError;
@@ -917,16 +929,34 @@
     }
     Page* page = document->page();
 
-    const int defaultLayoutWidthForNonMobilePages = 980;
-
-    // FIXME(aelias): Remove this argument from all the fast/viewport tests.
-    ASSERT(devicePixelRatio == 1);
+    // Update initial viewport size.
+    IntSize initialViewportSize(availableWidth, availableHeight);
+    document->page()->mainFrame()->view()->setFrameRect(IntRect(IntPoint::zero(), initialViewportSize));
+    document->styleResolver()->viewportStyleResolver()->resolve();
 
     ViewportArguments arguments = page->viewportArguments();
-    PageScaleConstraints constraints = arguments.resolve(IntSize(availableWidth, availableHeight), FloatSize(deviceWidth, deviceHeight), defaultLayoutWidthForNonMobilePages);
+    PageScaleConstraints constraints = arguments.resolve(initialViewportSize, FloatSize(deviceWidth, deviceHeight), 980 /* defaultLayoutWidthForNonMobilePages */);
+
     constraints.fitToContentsWidth(constraints.layoutSize.width(), availableWidth);
 
-    return "viewport size " + String::number(constraints.layoutSize.width()) + "x" + String::number(constraints.layoutSize.height()) + " scale " + String::number(constraints.initialScale) + " with limits [" + String::number(constraints.minimumScale) + ", " + String::number(constraints.maximumScale) + "] and userScalable " + (arguments.userZoom ? "true" : "false");
+    StringBuilder builder;
+
+    builder.appendLiteral("viewport size ");
+    builder.append(String::number(constraints.layoutSize.width()));
+    builder.append('x');
+    builder.append(String::number(constraints.layoutSize.height()));
+
+    builder.appendLiteral(" scale ");
+    builder.append(String::number(constraints.initialScale));
+    builder.appendLiteral(" with limits [");
+    builder.append(String::number(constraints.minimumScale));
+    builder.appendLiteral(", ");
+    builder.append(String::number(constraints.maximumScale));
+
+    builder.appendLiteral("] and userScalable ");
+    builder.append(arguments.userZoom ? "true" : "false");
+
+    return builder.toString();
 }
 
 bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionCode& ec)
@@ -1245,25 +1275,44 @@
     return count;
 }
 
-PassRefPtr<ClientRectList> Internals::touchEventTargetClientRects(Document* document, ExceptionCode& ec)
+LayerRectList* Internals::touchEventTargetLayerRects(Document* document, ExceptionCode& ec)
 {
-    if (!document || !document->view() || !document->page()) {
+    if (!document || !document->view() || !document->page() || document != contextDocument()) {
         ec = InvalidAccessError;
         return 0;
     }
-    if (!document->page()->scrollingCoordinator())
-        return ClientRectList::create();
 
-    document->updateLayoutIgnorePendingStylesheets();
+    // Do any pending layouts (which may call touchEventTargetRectsChange) to ensure this
+    // really takes any previous changes into account.
+    document->updateLayout();
+    return m_currentTouchEventRects.get();
+}
 
-    Vector<IntRect> absoluteRects;
-    document->page()->scrollingCoordinator()->computeAbsoluteTouchEventTargetRects(document, absoluteRects);
-    Vector<FloatQuad> absoluteQuads(absoluteRects.size());
+unsigned Internals::touchEventTargetLayerRectsUpdateCount(Document* document, ExceptionCode& ec)
+{
+    if (!document || !document->view() || !document->page() || document != contextDocument()) {
+        ec = InvalidAccessError;
+        return 0;
+    }
 
-    for (size_t i = 0; i < absoluteRects.size(); ++i)
-        absoluteQuads[i] = FloatQuad(absoluteRects[i]);
+    // Do any pending layouts to ensure this really takes any previous changes into account.
+    document->updateLayout();
 
-    return ClientRectList::create(absoluteQuads);
+    return m_touchEventTargetRectUpdateCount;
+}
+
+void Internals::touchEventTargetRectsChanged(const LayerHitTestRects& rects)
+{
+    m_touchEventTargetRectUpdateCount++;
+
+    // Since it's not safe to hang onto the pointers in a LayerHitTestRects, we immediately
+    // copy into a LayerRectList.
+    m_currentTouchEventRects = LayerRectList::create();
+    for (LayerHitTestRects::const_iterator iter = rects.begin(); iter != rects.end(); ++iter) {
+        for (size_t i = 0; i < iter->value.size(); ++i) {
+            m_currentTouchEventRects->append(iter->key->renderer()->node(), ClientRect::create(enclosingIntRect(iter->value[i])));
+        }
+    }
 }
 
 PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int centerX, int centerY, unsigned topPadding, unsigned rightPadding,
@@ -1391,7 +1440,7 @@
     Page* page = contextDocument()->frame()->page();
     ASSERT(page);
 
-    DOMWindow* window = page->mainFrame()->document()->domWindow();
+    DOMWindow* window = page->mainFrame()->domWindow();
     ASSERT(window);
 
     m_frontendWindow = window->open(url, "", "", window, window);
@@ -1948,7 +1997,7 @@
 
 void Internals::forceReload(bool endToEnd)
 {
-    frame()->loader()->reload(endToEnd);
+    frame()->loader()->reload(endToEnd ? EndToEndReload : NormalReload);
 }
 
 PassRefPtr<ClientRect> Internals::selectionBounds(ExceptionCode& ec)
diff --git a/Source/core/testing/Internals.h b/Source/core/testing/Internals.h
index 9a01f53..20ec6c7 100644
--- a/Source/core/testing/Internals.h
+++ b/Source/core/testing/Internals.h
@@ -31,6 +31,7 @@
 #include "core/dom/ContextLifecycleObserver.h"
 #include "core/dom/ExceptionCodePlaceholder.h"
 #include "core/dom/NodeList.h"
+#include "core/page/scrolling/ScrollingCoordinator.h"
 #include <wtf/ArrayBuffer.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
@@ -51,6 +52,7 @@
 class InternalRuntimeFlags;
 class InternalProfilers;
 class InternalSettings;
+class LayerRectList;
 class Node;
 class Page;
 class PagePopupController;
@@ -63,7 +65,9 @@
 
 typedef int ExceptionCode;
 
-class Internals : public RefCounted<Internals>, public ContextLifecycleObserver {
+class Internals : public RefCounted<Internals>
+    , public ContextLifecycleObserver
+    , public ScrollingCoordinator::TouchEventTargetRectsObserver {
 public:
     static PassRefPtr<Internals> create(Document*);
     virtual ~Internals();
@@ -175,7 +179,9 @@
 
     unsigned wheelEventHandlerCount(Document*, ExceptionCode&);
     unsigned touchEventHandlerCount(Document*, ExceptionCode&);
-    PassRefPtr<ClientRectList> touchEventTargetClientRects(Document*, ExceptionCode&);
+    LayerRectList* touchEventTargetLayerRects(Document*, ExceptionCode&);
+    unsigned touchEventTargetLayerRectsUpdateCount(Document*, ExceptionCode&);
+    virtual void touchEventTargetRectsChanged(const LayerHitTestRects&);
 
     // This is used to test rect based hit testing like what's done on touch screens.
     PassRefPtr<NodeList> nodesFromRect(Document*, int x, int y, unsigned topPadding, unsigned rightPadding,
@@ -296,6 +302,9 @@
     RefPtr<DOMWindow> m_frontendWindow;
     OwnPtr<InspectorFrontendChannelDummy> m_frontendChannel;
     RefPtr<InternalRuntimeFlags> m_runtimeFlags;
+    RefPtr<ScrollingCoordinator> m_scrollingCoordinator;
+    int m_touchEventTargetRectUpdateCount;
+    RefPtr<LayerRectList> m_currentTouchEventRects;
     RefPtr<InternalProfilers> m_profilers;
 };
 
diff --git a/Source/core/testing/Internals.idl b/Source/core/testing/Internals.idl
index a3ea3bc..4b19e6c 100644
--- a/Source/core/testing/Internals.idl
+++ b/Source/core/testing/Internals.idl
@@ -139,7 +139,8 @@
 
     [RaisesException] unsigned long wheelEventHandlerCount(Document document);
     [RaisesException] unsigned long touchEventHandlerCount(Document document);
-    [RaisesException] ClientRectList touchEventTargetClientRects(Document document);
+    [RaisesException] LayerRectList touchEventTargetLayerRects(Document document);
+    [RaisesException] unsigned long touchEventTargetLayerRectsUpdateCount(Document document);
 
     [RaisesException] NodeList nodesFromRect(Document document, long x, long y,
         unsigned long topPadding, unsigned long rightPadding, unsigned long bottomPadding, unsigned long leftPadding,
diff --git a/Source/core/testing/LayerRect.h b/Source/core/testing/LayerRect.h
new file mode 100644
index 0000000..f945681
--- /dev/null
+++ b/Source/core/testing/LayerRect.h
@@ -0,0 +1,67 @@
+/*
+ * 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:
+ *
+ *     * 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 LayerRect_h
+#define LayerRect_h
+
+#include "core/dom/ClientRect.h"
+
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+
+namespace WebCore {
+
+class Node;
+
+class LayerRect : public RefCounted<LayerRect> {
+public:
+    static PassRefPtr<LayerRect> create(PassRefPtr<Node> node, PassRefPtr<ClientRect> rect)
+    {
+        return adoptRef(new LayerRect(node, rect));
+    }
+
+    Node* layerRootNode() const { return m_layerRootNode.get(); }
+    ClientRect* layerRelativeRect() const { return m_rect.get(); }
+
+private:
+    LayerRect(PassRefPtr<Node> node, PassRefPtr<ClientRect> rect)
+        : m_layerRootNode(node)
+        , m_rect(rect)
+    {
+    }
+
+    RefPtr<Node> m_layerRootNode;
+    RefPtr<ClientRect> m_rect;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/core/testing/LayerRect.idl b/Source/core/testing/LayerRect.idl
new file mode 100644
index 0000000..78910b5
--- /dev/null
+++ b/Source/core/testing/LayerRect.idl
@@ -0,0 +1,35 @@
+/*
+ * 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:
+ * 
+ *     * 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.
+ */
+
+[
+] interface LayerRect {
+    readonly attribute Node layerRootNode;
+    readonly attribute ClientRect layerRelativeRect;
+};
diff --git a/Source/core/testing/LayerRectList.cpp b/Source/core/testing/LayerRectList.cpp
new file mode 100644
index 0000000..578b407
--- /dev/null
+++ b/Source/core/testing/LayerRectList.cpp
@@ -0,0 +1,66 @@
+/*
+ * 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:
+ *
+ *     * 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/testing/LayerRectList.h"
+
+#include "core/dom/ClientRect.h"
+#include "core/dom/Node.h"
+#include "core/testing/LayerRect.h"
+
+namespace WebCore {
+
+LayerRectList::LayerRectList()
+{
+}
+
+LayerRectList::~LayerRectList()
+{
+}
+
+unsigned LayerRectList::length() const
+{
+    return m_list.size();
+}
+
+LayerRect* LayerRectList::item(unsigned index)
+{
+    if (index >= m_list.size())
+        return 0;
+
+    return m_list[index].get();
+}
+
+void LayerRectList::append(PassRefPtr<Node> layerRootNode, PassRefPtr<ClientRect> layerRelativeRect)
+{
+    m_list.append(LayerRect::create(layerRootNode, layerRelativeRect));
+}
+
+} // namespace WebCore
diff --git a/Source/core/testing/LayerRectList.h b/Source/core/testing/LayerRectList.h
new file mode 100644
index 0000000..d46d1dc
--- /dev/null
+++ b/Source/core/testing/LayerRectList.h
@@ -0,0 +1,63 @@
+/*
+ * 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:
+ *
+ *     * 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 LayerRectList_h
+#define LayerRectList_h
+
+#include "bindings/v8/ScriptWrappable.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
+
+namespace WebCore {
+
+class ClientRect;
+class ClientRectList;
+class LayerRect;
+class Node;
+
+class LayerRectList : public RefCounted<LayerRectList> {
+public:
+    static PassRefPtr<LayerRectList> create() { return adoptRef(new LayerRectList); }
+    ~LayerRectList();
+
+    unsigned length() const;
+    LayerRect* item(unsigned index);
+    void append(PassRefPtr<Node> layerRootNode, PassRefPtr<ClientRect> layerRelativeRect);
+
+private:
+    LayerRectList();
+
+    Vector<RefPtr<LayerRect> > m_list;
+};
+
+} // namespace WebCore
+
+#endif // ClientRectList_h
diff --git a/Source/core/testing/LayerRectList.idl b/Source/core/testing/LayerRectList.idl
new file mode 100644
index 0000000..7551667
--- /dev/null
+++ b/Source/core/testing/LayerRectList.idl
@@ -0,0 +1,36 @@
+/*
+ * 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:
+ * 
+ *     * 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.
+ */
+
+[
+] interface LayerRectList {
+    readonly attribute unsigned long length;
+    getter LayerRect item([IsIndex,Default=Undefined] optional unsigned long index);
+};
+
diff --git a/Source/core/tests/HTMLDimension.cpp b/Source/core/tests/HTMLDimension.cpp
index 043d506..4ef334b 100644
--- a/Source/core/tests/HTMLDimension.cpp
+++ b/Source/core/tests/HTMLDimension.cpp
@@ -37,9 +37,9 @@
 namespace WebCore {
 
 // This assertion-prettify function needs to be in the WebCore namespace.
-void PrintTo(const Length& length, ::std::ostream* os)
+void PrintTo(const HTMLDimension& dimension, ::std::ostream* os)
 {
-    *os << "Length => lengthType: " << length.type() << ", value=" << length.value();
+    *os << "HTMLDimension => type: " << dimension.type() << ", value=" << dimension.value();
 }
 
 }
@@ -50,178 +50,178 @@
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsEmptyString)
 {
-    Vector<Length> result = parseListOfDimensions(String(""));
-    ASSERT_EQ(Vector<Length>(), result);
+    Vector<HTMLDimension> result = parseListOfDimensions(String(""));
+    ASSERT_EQ(Vector<HTMLDimension>(), result);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsNoNumberAbsolute)
 {
-    Vector<Length> result = parseListOfDimensions(String(" \t"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String(" \t"));
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(0, Relative), result[0]);
+    ASSERT_EQ(HTMLDimension(0, HTMLDimension::Relative), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsNoNumberPercent)
 {
-    Vector<Length> result = parseListOfDimensions(String(" \t%"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String(" \t%"));
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(0, Percent), result[0]);
+    ASSERT_EQ(HTMLDimension(0, HTMLDimension::Percentage), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsNoNumberRelative)
 {
-    Vector<Length> result = parseListOfDimensions(String("\t *"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("\t *"));
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(0, Relative), result[0]);
+    ASSERT_EQ(HTMLDimension(0, HTMLDimension::Relative), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsSingleAbsolute)
 {
-    Vector<Length> result = parseListOfDimensions(String("10"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("10"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(10, Fixed), result[0]);
+    ASSERT_EQ(HTMLDimension(10, HTMLDimension::Absolute), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsSinglePercentageWithSpaces)
 {
-    Vector<Length> result = parseListOfDimensions(String("50  %"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("50  %"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(50, Percent), result[0]);
+    ASSERT_EQ(HTMLDimension(50, HTMLDimension::Percentage), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsSingleRelative)
 {
-    Vector<Length> result = parseListOfDimensions(String("25*"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("25*"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(25, Relative), result[0]);
+    ASSERT_EQ(HTMLDimension(25, HTMLDimension::Relative), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsDoubleAbsolute)
 {
-    Vector<Length> result = parseListOfDimensions(String("10.054"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("10.054"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(10.054, Fixed), result[0]);
+    ASSERT_EQ(HTMLDimension(10.054, HTMLDimension::Absolute), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsLeadingSpaceAbsolute)
 {
-    Vector<Length> result = parseListOfDimensions(String("\t \t 10"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("\t \t 10"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(10, Fixed), result[0]);
+    ASSERT_EQ(HTMLDimension(10, HTMLDimension::Absolute), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsLeadingSpaceRelative)
 {
-    Vector<Length> result = parseListOfDimensions(String(" \r25*"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String(" \r25*"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(25, Relative), result[0]);
+    ASSERT_EQ(HTMLDimension(25, HTMLDimension::Relative), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsLeadingSpacePercentage)
 {
-    Vector<Length> result = parseListOfDimensions(String("\n 25%"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("\n 25%"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(25, Percent), result[0]);
+    ASSERT_EQ(HTMLDimension(25, HTMLDimension::Percentage), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsDoublePercentage)
 {
-    Vector<Length> result = parseListOfDimensions(String("10.054%"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("10.054%"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(10.054, Percent), result[0]);
+    ASSERT_EQ(HTMLDimension(10.054, HTMLDimension::Percentage), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsDoubleRelative)
 {
-    Vector<Length> result = parseListOfDimensions(String("10.054*"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("10.054*"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(10.054, Relative), result[0]);
+    ASSERT_EQ(HTMLDimension(10.054, HTMLDimension::Relative), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsSpacesInIntegerDoubleAbsolute)
 {
-    Vector<Length> result = parseListOfDimensions(String("1\n0 .025%"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("1\n0 .025%"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(1, Fixed), result[0]);
+    ASSERT_EQ(HTMLDimension(1, HTMLDimension::Absolute), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsSpacesInIntegerDoublePercent)
 {
-    Vector<Length> result = parseListOfDimensions(String("1\n0 .025%"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("1\n0 .025%"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(1, Fixed), result[0]);
+    ASSERT_EQ(HTMLDimension(1, HTMLDimension::Absolute), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsSpacesInIntegerDoubleRelative)
 {
-    Vector<Length> result = parseListOfDimensions(String("1\n0 .025*"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("1\n0 .025*"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(1, Fixed), result[0]);
+    ASSERT_EQ(HTMLDimension(1, HTMLDimension::Absolute), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsSpacesInFractionAfterDotDoublePercent)
 {
-    Vector<Length> result = parseListOfDimensions(String("10.  0 25%"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("10.  0 25%"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(10.025, Percent), result[0]);
+    ASSERT_EQ(HTMLDimension(10.025, HTMLDimension::Percentage), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsSpacesInFractionAfterDigitDoublePercent)
 {
-    Vector<Length> result = parseListOfDimensions(String("10.05\r25%"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("10.05\r25%"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(10.0525, Percent), result[0]);
+    ASSERT_EQ(HTMLDimension(10.0525, HTMLDimension::Percentage), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsTrailingComma)
 {
-    Vector<Length> result = parseListOfDimensions(String("10,"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("10,"));
 
     ASSERT_EQ(1U, result.size());
-    ASSERT_EQ(Length(10, Fixed), result[0]);
+    ASSERT_EQ(HTMLDimension(10, HTMLDimension::Absolute), result[0]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsTwoDimensions)
 {
-    Vector<Length> result = parseListOfDimensions(String("10*,25 %"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("10*,25 %"));
 
     ASSERT_EQ(2U, result.size());
-    ASSERT_EQ(Length(10, Relative), result[0]);
-    ASSERT_EQ(Length(25, Percent), result[1]);
+    ASSERT_EQ(HTMLDimension(10, HTMLDimension::Relative), result[0]);
+    ASSERT_EQ(HTMLDimension(25, HTMLDimension::Percentage), result[1]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsMultipleDimensionsWithSpaces)
 {
-    Vector<Length> result = parseListOfDimensions(String("10   *   ,\t25 , 10.05\n5%"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("10   *   ,\t25 , 10.05\n5%"));
 
     ASSERT_EQ(3U, result.size());
-    ASSERT_EQ(Length(10, Relative), result[0]);
-    ASSERT_EQ(Length(25, Fixed), result[1]);
-    ASSERT_EQ(Length(10.055, Percent), result[2]);
+    ASSERT_EQ(HTMLDimension(10, HTMLDimension::Relative), result[0]);
+    ASSERT_EQ(HTMLDimension(25, HTMLDimension::Absolute), result[1]);
+    ASSERT_EQ(HTMLDimension(10.055, HTMLDimension::Percentage), result[2]);
 }
 
 TEST(WebCoreHTMLDimension, parseListOfDimensionsMultipleDimensionsWithOneEmpty)
 {
-    Vector<Length> result = parseListOfDimensions(String("2*,,8.%"));
+    Vector<HTMLDimension> result = parseListOfDimensions(String("2*,,8.%"));
 
     ASSERT_EQ(3U, result.size());
-    ASSERT_EQ(Length(2, Relative), result[0]);
-    ASSERT_EQ(Length(0, Relative), result[1]);
-    ASSERT_EQ(Length(8., Percent), result[2]);
+    ASSERT_EQ(HTMLDimension(2, HTMLDimension::Relative), result[0]);
+    ASSERT_EQ(HTMLDimension(0, HTMLDimension::Relative), result[1]);
+    ASSERT_EQ(HTMLDimension(8., HTMLDimension::Percentage), result[2]);
 }
 
 }
diff --git a/Source/core/webcore_derived.target.darwin-arm.mk b/Source/core/webcore_derived.target.darwin-arm.mk
index fa8c010..a67709f 100644
--- a/Source/core/webcore_derived.target.darwin-arm.mk
+++ b/Source/core/webcore_derived.target.darwin-arm.mk
@@ -127,6 +127,8 @@
 	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/V8SVGElementWrapperFactory.cpp: $(gyp_shared_intermediate_dir)/webkit/V8SVGElementWrapperFactory.cpp
 	mkdir -p $(@D); cp $< $@
+$(gyp_intermediate_dir)/StylePropertyShorthand.cpp: $(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp
+	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/StyleBuilder.cpp: $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp
 	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/StyleBuilderFunctions.cpp: $(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.cpp
@@ -180,6 +182,7 @@
 	$(gyp_intermediate_dir)/InspectorInstrumentationImpl.cpp \
 	$(gyp_intermediate_dir)/SVGElementFactory.cpp \
 	$(gyp_intermediate_dir)/V8SVGElementWrapperFactory.cpp \
+	$(gyp_intermediate_dir)/StylePropertyShorthand.cpp \
 	$(gyp_intermediate_dir)/StyleBuilder.cpp \
 	$(gyp_intermediate_dir)/StyleBuilderFunctions.cpp
 
@@ -214,6 +217,7 @@
 	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 \
diff --git a/Source/core/webcore_derived.target.darwin-mips.mk b/Source/core/webcore_derived.target.darwin-mips.mk
index 6990fe4..0c62494 100644
--- a/Source/core/webcore_derived.target.darwin-mips.mk
+++ b/Source/core/webcore_derived.target.darwin-mips.mk
@@ -127,6 +127,8 @@
 	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/V8SVGElementWrapperFactory.cpp: $(gyp_shared_intermediate_dir)/webkit/V8SVGElementWrapperFactory.cpp
 	mkdir -p $(@D); cp $< $@
+$(gyp_intermediate_dir)/StylePropertyShorthand.cpp: $(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp
+	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/StyleBuilder.cpp: $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp
 	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/StyleBuilderFunctions.cpp: $(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.cpp
@@ -180,6 +182,7 @@
 	$(gyp_intermediate_dir)/InspectorInstrumentationImpl.cpp \
 	$(gyp_intermediate_dir)/SVGElementFactory.cpp \
 	$(gyp_intermediate_dir)/V8SVGElementWrapperFactory.cpp \
+	$(gyp_intermediate_dir)/StylePropertyShorthand.cpp \
 	$(gyp_intermediate_dir)/StyleBuilder.cpp \
 	$(gyp_intermediate_dir)/StyleBuilderFunctions.cpp
 
@@ -214,6 +217,7 @@
 	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 \
diff --git a/Source/core/webcore_derived.target.darwin-x86.mk b/Source/core/webcore_derived.target.darwin-x86.mk
index 164c7e8..6434b13 100644
--- a/Source/core/webcore_derived.target.darwin-x86.mk
+++ b/Source/core/webcore_derived.target.darwin-x86.mk
@@ -127,6 +127,8 @@
 	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/V8SVGElementWrapperFactory.cpp: $(gyp_shared_intermediate_dir)/webkit/V8SVGElementWrapperFactory.cpp
 	mkdir -p $(@D); cp $< $@
+$(gyp_intermediate_dir)/StylePropertyShorthand.cpp: $(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp
+	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/StyleBuilder.cpp: $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp
 	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/StyleBuilderFunctions.cpp: $(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.cpp
@@ -180,6 +182,7 @@
 	$(gyp_intermediate_dir)/InspectorInstrumentationImpl.cpp \
 	$(gyp_intermediate_dir)/SVGElementFactory.cpp \
 	$(gyp_intermediate_dir)/V8SVGElementWrapperFactory.cpp \
+	$(gyp_intermediate_dir)/StylePropertyShorthand.cpp \
 	$(gyp_intermediate_dir)/StyleBuilder.cpp \
 	$(gyp_intermediate_dir)/StyleBuilderFunctions.cpp
 
@@ -214,6 +217,7 @@
 	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 \
diff --git a/Source/core/webcore_derived.target.linux-arm.mk b/Source/core/webcore_derived.target.linux-arm.mk
index fa8c010..a67709f 100644
--- a/Source/core/webcore_derived.target.linux-arm.mk
+++ b/Source/core/webcore_derived.target.linux-arm.mk
@@ -127,6 +127,8 @@
 	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/V8SVGElementWrapperFactory.cpp: $(gyp_shared_intermediate_dir)/webkit/V8SVGElementWrapperFactory.cpp
 	mkdir -p $(@D); cp $< $@
+$(gyp_intermediate_dir)/StylePropertyShorthand.cpp: $(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp
+	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/StyleBuilder.cpp: $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp
 	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/StyleBuilderFunctions.cpp: $(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.cpp
@@ -180,6 +182,7 @@
 	$(gyp_intermediate_dir)/InspectorInstrumentationImpl.cpp \
 	$(gyp_intermediate_dir)/SVGElementFactory.cpp \
 	$(gyp_intermediate_dir)/V8SVGElementWrapperFactory.cpp \
+	$(gyp_intermediate_dir)/StylePropertyShorthand.cpp \
 	$(gyp_intermediate_dir)/StyleBuilder.cpp \
 	$(gyp_intermediate_dir)/StyleBuilderFunctions.cpp
 
@@ -214,6 +217,7 @@
 	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 \
diff --git a/Source/core/webcore_derived.target.linux-mips.mk b/Source/core/webcore_derived.target.linux-mips.mk
index 6990fe4..0c62494 100644
--- a/Source/core/webcore_derived.target.linux-mips.mk
+++ b/Source/core/webcore_derived.target.linux-mips.mk
@@ -127,6 +127,8 @@
 	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/V8SVGElementWrapperFactory.cpp: $(gyp_shared_intermediate_dir)/webkit/V8SVGElementWrapperFactory.cpp
 	mkdir -p $(@D); cp $< $@
+$(gyp_intermediate_dir)/StylePropertyShorthand.cpp: $(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp
+	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/StyleBuilder.cpp: $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp
 	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/StyleBuilderFunctions.cpp: $(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.cpp
@@ -180,6 +182,7 @@
 	$(gyp_intermediate_dir)/InspectorInstrumentationImpl.cpp \
 	$(gyp_intermediate_dir)/SVGElementFactory.cpp \
 	$(gyp_intermediate_dir)/V8SVGElementWrapperFactory.cpp \
+	$(gyp_intermediate_dir)/StylePropertyShorthand.cpp \
 	$(gyp_intermediate_dir)/StyleBuilder.cpp \
 	$(gyp_intermediate_dir)/StyleBuilderFunctions.cpp
 
@@ -214,6 +217,7 @@
 	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 \
diff --git a/Source/core/webcore_derived.target.linux-x86.mk b/Source/core/webcore_derived.target.linux-x86.mk
index 164c7e8..6434b13 100644
--- a/Source/core/webcore_derived.target.linux-x86.mk
+++ b/Source/core/webcore_derived.target.linux-x86.mk
@@ -127,6 +127,8 @@
 	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/V8SVGElementWrapperFactory.cpp: $(gyp_shared_intermediate_dir)/webkit/V8SVGElementWrapperFactory.cpp
 	mkdir -p $(@D); cp $< $@
+$(gyp_intermediate_dir)/StylePropertyShorthand.cpp: $(gyp_shared_intermediate_dir)/webkit/StylePropertyShorthand.cpp
+	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/StyleBuilder.cpp: $(gyp_shared_intermediate_dir)/webkit/StyleBuilder.cpp
 	mkdir -p $(@D); cp $< $@
 $(gyp_intermediate_dir)/StyleBuilderFunctions.cpp: $(gyp_shared_intermediate_dir)/webkit/StyleBuilderFunctions.cpp
@@ -180,6 +182,7 @@
 	$(gyp_intermediate_dir)/InspectorInstrumentationImpl.cpp \
 	$(gyp_intermediate_dir)/SVGElementFactory.cpp \
 	$(gyp_intermediate_dir)/V8SVGElementWrapperFactory.cpp \
+	$(gyp_intermediate_dir)/StylePropertyShorthand.cpp \
 	$(gyp_intermediate_dir)/StyleBuilder.cpp \
 	$(gyp_intermediate_dir)/StyleBuilderFunctions.cpp
 
@@ -214,6 +217,7 @@
 	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 \
diff --git a/Source/core/webcore_dom.target.darwin-arm.mk b/Source/core/webcore_dom.target.darwin-arm.mk
index f1388c8..eaf35b3 100644
--- a/Source/core/webcore_dom.target.darwin-arm.mk
+++ b/Source/core/webcore_dom.target.darwin-arm.mk
@@ -49,6 +49,7 @@
 	third_party/WebKit/Source/core/dom/CustomElementCallbackDispatcher.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackInvocation.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackQueue.cpp \
+	third_party/WebKit/Source/core/dom/CustomElementCallbackScheduler.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementDefinition.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementRegistrationContext.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementRegistry.cpp \
@@ -64,8 +65,6 @@
 	third_party/WebKit/Source/core/dom/DatasetDOMStringMap.cpp \
 	third_party/WebKit/Source/core/dom/DecodedDataDocumentParser.cpp \
 	third_party/WebKit/Source/core/dom/DeviceOrientationController.cpp \
-	third_party/WebKit/Source/core/dom/DeviceOrientationData.cpp \
-	third_party/WebKit/Source/core/dom/DeviceOrientationEvent.cpp \
 	third_party/WebKit/Source/core/dom/Document.cpp \
 	third_party/WebKit/Source/core/dom/DocumentEventQueue.cpp \
 	third_party/WebKit/Source/core/dom/DocumentFragment.cpp \
diff --git a/Source/core/webcore_dom.target.darwin-mips.mk b/Source/core/webcore_dom.target.darwin-mips.mk
index b998caf..66a5e6d 100644
--- a/Source/core/webcore_dom.target.darwin-mips.mk
+++ b/Source/core/webcore_dom.target.darwin-mips.mk
@@ -49,6 +49,7 @@
 	third_party/WebKit/Source/core/dom/CustomElementCallbackDispatcher.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackInvocation.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackQueue.cpp \
+	third_party/WebKit/Source/core/dom/CustomElementCallbackScheduler.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementDefinition.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementRegistrationContext.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementRegistry.cpp \
@@ -64,8 +65,6 @@
 	third_party/WebKit/Source/core/dom/DatasetDOMStringMap.cpp \
 	third_party/WebKit/Source/core/dom/DecodedDataDocumentParser.cpp \
 	third_party/WebKit/Source/core/dom/DeviceOrientationController.cpp \
-	third_party/WebKit/Source/core/dom/DeviceOrientationData.cpp \
-	third_party/WebKit/Source/core/dom/DeviceOrientationEvent.cpp \
 	third_party/WebKit/Source/core/dom/Document.cpp \
 	third_party/WebKit/Source/core/dom/DocumentEventQueue.cpp \
 	third_party/WebKit/Source/core/dom/DocumentFragment.cpp \
diff --git a/Source/core/webcore_dom.target.darwin-x86.mk b/Source/core/webcore_dom.target.darwin-x86.mk
index 1dd6f9b..f284e6e 100644
--- a/Source/core/webcore_dom.target.darwin-x86.mk
+++ b/Source/core/webcore_dom.target.darwin-x86.mk
@@ -49,6 +49,7 @@
 	third_party/WebKit/Source/core/dom/CustomElementCallbackDispatcher.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackInvocation.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackQueue.cpp \
+	third_party/WebKit/Source/core/dom/CustomElementCallbackScheduler.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementDefinition.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementRegistrationContext.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementRegistry.cpp \
@@ -64,8 +65,6 @@
 	third_party/WebKit/Source/core/dom/DatasetDOMStringMap.cpp \
 	third_party/WebKit/Source/core/dom/DecodedDataDocumentParser.cpp \
 	third_party/WebKit/Source/core/dom/DeviceOrientationController.cpp \
-	third_party/WebKit/Source/core/dom/DeviceOrientationData.cpp \
-	third_party/WebKit/Source/core/dom/DeviceOrientationEvent.cpp \
 	third_party/WebKit/Source/core/dom/Document.cpp \
 	third_party/WebKit/Source/core/dom/DocumentEventQueue.cpp \
 	third_party/WebKit/Source/core/dom/DocumentFragment.cpp \
diff --git a/Source/core/webcore_dom.target.linux-arm.mk b/Source/core/webcore_dom.target.linux-arm.mk
index f1388c8..eaf35b3 100644
--- a/Source/core/webcore_dom.target.linux-arm.mk
+++ b/Source/core/webcore_dom.target.linux-arm.mk
@@ -49,6 +49,7 @@
 	third_party/WebKit/Source/core/dom/CustomElementCallbackDispatcher.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackInvocation.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackQueue.cpp \
+	third_party/WebKit/Source/core/dom/CustomElementCallbackScheduler.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementDefinition.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementRegistrationContext.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementRegistry.cpp \
@@ -64,8 +65,6 @@
 	third_party/WebKit/Source/core/dom/DatasetDOMStringMap.cpp \
 	third_party/WebKit/Source/core/dom/DecodedDataDocumentParser.cpp \
 	third_party/WebKit/Source/core/dom/DeviceOrientationController.cpp \
-	third_party/WebKit/Source/core/dom/DeviceOrientationData.cpp \
-	third_party/WebKit/Source/core/dom/DeviceOrientationEvent.cpp \
 	third_party/WebKit/Source/core/dom/Document.cpp \
 	third_party/WebKit/Source/core/dom/DocumentEventQueue.cpp \
 	third_party/WebKit/Source/core/dom/DocumentFragment.cpp \
diff --git a/Source/core/webcore_dom.target.linux-mips.mk b/Source/core/webcore_dom.target.linux-mips.mk
index b998caf..66a5e6d 100644
--- a/Source/core/webcore_dom.target.linux-mips.mk
+++ b/Source/core/webcore_dom.target.linux-mips.mk
@@ -49,6 +49,7 @@
 	third_party/WebKit/Source/core/dom/CustomElementCallbackDispatcher.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackInvocation.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackQueue.cpp \
+	third_party/WebKit/Source/core/dom/CustomElementCallbackScheduler.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementDefinition.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementRegistrationContext.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementRegistry.cpp \
@@ -64,8 +65,6 @@
 	third_party/WebKit/Source/core/dom/DatasetDOMStringMap.cpp \
 	third_party/WebKit/Source/core/dom/DecodedDataDocumentParser.cpp \
 	third_party/WebKit/Source/core/dom/DeviceOrientationController.cpp \
-	third_party/WebKit/Source/core/dom/DeviceOrientationData.cpp \
-	third_party/WebKit/Source/core/dom/DeviceOrientationEvent.cpp \
 	third_party/WebKit/Source/core/dom/Document.cpp \
 	third_party/WebKit/Source/core/dom/DocumentEventQueue.cpp \
 	third_party/WebKit/Source/core/dom/DocumentFragment.cpp \
diff --git a/Source/core/webcore_dom.target.linux-x86.mk b/Source/core/webcore_dom.target.linux-x86.mk
index 1dd6f9b..f284e6e 100644
--- a/Source/core/webcore_dom.target.linux-x86.mk
+++ b/Source/core/webcore_dom.target.linux-x86.mk
@@ -49,6 +49,7 @@
 	third_party/WebKit/Source/core/dom/CustomElementCallbackDispatcher.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackInvocation.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementCallbackQueue.cpp \
+	third_party/WebKit/Source/core/dom/CustomElementCallbackScheduler.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementDefinition.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementRegistrationContext.cpp \
 	third_party/WebKit/Source/core/dom/CustomElementRegistry.cpp \
@@ -64,8 +65,6 @@
 	third_party/WebKit/Source/core/dom/DatasetDOMStringMap.cpp \
 	third_party/WebKit/Source/core/dom/DecodedDataDocumentParser.cpp \
 	third_party/WebKit/Source/core/dom/DeviceOrientationController.cpp \
-	third_party/WebKit/Source/core/dom/DeviceOrientationData.cpp \
-	third_party/WebKit/Source/core/dom/DeviceOrientationEvent.cpp \
 	third_party/WebKit/Source/core/dom/Document.cpp \
 	third_party/WebKit/Source/core/dom/DocumentEventQueue.cpp \
 	third_party/WebKit/Source/core/dom/DocumentFragment.cpp \
diff --git a/Source/core/webcore_remaining.target.darwin-arm.mk b/Source/core/webcore_remaining.target.darwin-arm.mk
index 908dc07..3fdb646 100644
--- a/Source/core/webcore_remaining.target.darwin-arm.mk
+++ b/Source/core/webcore_remaining.target.darwin-arm.mk
@@ -110,6 +110,7 @@
 	third_party/WebKit/Source/core/css/CSSSelector.cpp \
 	third_party/WebKit/Source/core/css/CSSSelectorList.cpp \
 	third_party/WebKit/Source/core/css/CSSShaderValue.cpp \
+	third_party/WebKit/Source/core/css/CSSStyleDeclaration.cpp \
 	third_party/WebKit/Source/core/css/CSSStyleRule.cpp \
 	third_party/WebKit/Source/core/css/CSSStyleSheet.cpp \
 	third_party/WebKit/Source/core/css/CSSSupportsRule.cpp \
@@ -121,6 +122,7 @@
 	third_party/WebKit/Source/core/css/CSSValue.cpp \
 	third_party/WebKit/Source/core/css/CSSValueList.cpp \
 	third_party/WebKit/Source/core/css/CSSValuePool.cpp \
+	third_party/WebKit/Source/core/css/CSSVariablesMap.cpp \
 	third_party/WebKit/Source/core/css/CSSViewportRule.cpp \
 	third_party/WebKit/Source/core/css/DOMWindowCSS.cpp \
 	third_party/WebKit/Source/core/css/DocumentRuleSets.cpp \
@@ -154,7 +156,7 @@
 	third_party/WebKit/Source/core/css/StyleMedia.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySerializer.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySet.cpp \
-	third_party/WebKit/Source/core/css/StylePropertyShorthand.cpp \
+	third_party/WebKit/Source/core/css/StylePropertyShorthandCustom.cpp \
 	third_party/WebKit/Source/core/css/StyleRule.cpp \
 	third_party/WebKit/Source/core/css/StyleRuleImport.cpp \
 	third_party/WebKit/Source/core/css/StyleSheet.cpp \
@@ -372,6 +374,8 @@
 	third_party/WebKit/Source/core/page/DOMSelection.cpp \
 	third_party/WebKit/Source/core/page/DOMTimer.cpp \
 	third_party/WebKit/Source/core/page/DOMWindow.cpp \
+	third_party/WebKit/Source/core/page/DOMWindowBase64.cpp \
+	third_party/WebKit/Source/core/page/DOMWindowTimers.cpp \
 	third_party/WebKit/Source/core/page/DOMWindowPagePopup.cpp \
 	third_party/WebKit/Source/core/page/DOMWindowProperty.cpp \
 	third_party/WebKit/Source/core/page/DragController.cpp \
@@ -452,14 +456,15 @@
 	third_party/WebKit/Source/core/workers/SharedWorkerGlobalScope.cpp \
 	third_party/WebKit/Source/core/workers/SharedWorkerThread.cpp \
 	third_party/WebKit/Source/core/workers/Worker.cpp \
-	third_party/WebKit/Source/core/workers/WorkerGlobalScopeProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerEventQueue.cpp \
+	third_party/WebKit/Source/core/workers/WorkerGlobalScopeProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp \
 	third_party/WebKit/Source/core/workers/WorkerLocation.cpp \
 	third_party/WebKit/Source/core/workers/WorkerMessagingProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerRunLoop.cpp \
 	third_party/WebKit/Source/core/workers/WorkerScriptLoader.cpp \
 	third_party/WebKit/Source/core/workers/WorkerThread.cpp \
+	third_party/WebKit/Source/core/workers/WorkerThreadStartupData.cpp \
 	third_party/WebKit/Source/core/xml/parser/XMLDocumentParser.cpp \
 	third_party/WebKit/Source/core/xml/parser/XMLDocumentParserScope.cpp \
 	third_party/WebKit/Source/core/xml/DocumentXPathEvaluator.cpp \
diff --git a/Source/core/webcore_remaining.target.darwin-mips.mk b/Source/core/webcore_remaining.target.darwin-mips.mk
index 719cc6a..e52010a 100644
--- a/Source/core/webcore_remaining.target.darwin-mips.mk
+++ b/Source/core/webcore_remaining.target.darwin-mips.mk
@@ -110,6 +110,7 @@
 	third_party/WebKit/Source/core/css/CSSSelector.cpp \
 	third_party/WebKit/Source/core/css/CSSSelectorList.cpp \
 	third_party/WebKit/Source/core/css/CSSShaderValue.cpp \
+	third_party/WebKit/Source/core/css/CSSStyleDeclaration.cpp \
 	third_party/WebKit/Source/core/css/CSSStyleRule.cpp \
 	third_party/WebKit/Source/core/css/CSSStyleSheet.cpp \
 	third_party/WebKit/Source/core/css/CSSSupportsRule.cpp \
@@ -121,6 +122,7 @@
 	third_party/WebKit/Source/core/css/CSSValue.cpp \
 	third_party/WebKit/Source/core/css/CSSValueList.cpp \
 	third_party/WebKit/Source/core/css/CSSValuePool.cpp \
+	third_party/WebKit/Source/core/css/CSSVariablesMap.cpp \
 	third_party/WebKit/Source/core/css/CSSViewportRule.cpp \
 	third_party/WebKit/Source/core/css/DOMWindowCSS.cpp \
 	third_party/WebKit/Source/core/css/DocumentRuleSets.cpp \
@@ -154,7 +156,7 @@
 	third_party/WebKit/Source/core/css/StyleMedia.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySerializer.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySet.cpp \
-	third_party/WebKit/Source/core/css/StylePropertyShorthand.cpp \
+	third_party/WebKit/Source/core/css/StylePropertyShorthandCustom.cpp \
 	third_party/WebKit/Source/core/css/StyleRule.cpp \
 	third_party/WebKit/Source/core/css/StyleRuleImport.cpp \
 	third_party/WebKit/Source/core/css/StyleSheet.cpp \
@@ -372,6 +374,8 @@
 	third_party/WebKit/Source/core/page/DOMSelection.cpp \
 	third_party/WebKit/Source/core/page/DOMTimer.cpp \
 	third_party/WebKit/Source/core/page/DOMWindow.cpp \
+	third_party/WebKit/Source/core/page/DOMWindowBase64.cpp \
+	third_party/WebKit/Source/core/page/DOMWindowTimers.cpp \
 	third_party/WebKit/Source/core/page/DOMWindowPagePopup.cpp \
 	third_party/WebKit/Source/core/page/DOMWindowProperty.cpp \
 	third_party/WebKit/Source/core/page/DragController.cpp \
@@ -452,14 +456,15 @@
 	third_party/WebKit/Source/core/workers/SharedWorkerGlobalScope.cpp \
 	third_party/WebKit/Source/core/workers/SharedWorkerThread.cpp \
 	third_party/WebKit/Source/core/workers/Worker.cpp \
-	third_party/WebKit/Source/core/workers/WorkerGlobalScopeProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerEventQueue.cpp \
+	third_party/WebKit/Source/core/workers/WorkerGlobalScopeProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp \
 	third_party/WebKit/Source/core/workers/WorkerLocation.cpp \
 	third_party/WebKit/Source/core/workers/WorkerMessagingProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerRunLoop.cpp \
 	third_party/WebKit/Source/core/workers/WorkerScriptLoader.cpp \
 	third_party/WebKit/Source/core/workers/WorkerThread.cpp \
+	third_party/WebKit/Source/core/workers/WorkerThreadStartupData.cpp \
 	third_party/WebKit/Source/core/xml/parser/XMLDocumentParser.cpp \
 	third_party/WebKit/Source/core/xml/parser/XMLDocumentParserScope.cpp \
 	third_party/WebKit/Source/core/xml/DocumentXPathEvaluator.cpp \
diff --git a/Source/core/webcore_remaining.target.darwin-x86.mk b/Source/core/webcore_remaining.target.darwin-x86.mk
index acd7cb3..f42f81f 100644
--- a/Source/core/webcore_remaining.target.darwin-x86.mk
+++ b/Source/core/webcore_remaining.target.darwin-x86.mk
@@ -110,6 +110,7 @@
 	third_party/WebKit/Source/core/css/CSSSelector.cpp \
 	third_party/WebKit/Source/core/css/CSSSelectorList.cpp \
 	third_party/WebKit/Source/core/css/CSSShaderValue.cpp \
+	third_party/WebKit/Source/core/css/CSSStyleDeclaration.cpp \
 	third_party/WebKit/Source/core/css/CSSStyleRule.cpp \
 	third_party/WebKit/Source/core/css/CSSStyleSheet.cpp \
 	third_party/WebKit/Source/core/css/CSSSupportsRule.cpp \
@@ -121,6 +122,7 @@
 	third_party/WebKit/Source/core/css/CSSValue.cpp \
 	third_party/WebKit/Source/core/css/CSSValueList.cpp \
 	third_party/WebKit/Source/core/css/CSSValuePool.cpp \
+	third_party/WebKit/Source/core/css/CSSVariablesMap.cpp \
 	third_party/WebKit/Source/core/css/CSSViewportRule.cpp \
 	third_party/WebKit/Source/core/css/DOMWindowCSS.cpp \
 	third_party/WebKit/Source/core/css/DocumentRuleSets.cpp \
@@ -154,7 +156,7 @@
 	third_party/WebKit/Source/core/css/StyleMedia.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySerializer.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySet.cpp \
-	third_party/WebKit/Source/core/css/StylePropertyShorthand.cpp \
+	third_party/WebKit/Source/core/css/StylePropertyShorthandCustom.cpp \
 	third_party/WebKit/Source/core/css/StyleRule.cpp \
 	third_party/WebKit/Source/core/css/StyleRuleImport.cpp \
 	third_party/WebKit/Source/core/css/StyleSheet.cpp \
@@ -372,6 +374,8 @@
 	third_party/WebKit/Source/core/page/DOMSelection.cpp \
 	third_party/WebKit/Source/core/page/DOMTimer.cpp \
 	third_party/WebKit/Source/core/page/DOMWindow.cpp \
+	third_party/WebKit/Source/core/page/DOMWindowBase64.cpp \
+	third_party/WebKit/Source/core/page/DOMWindowTimers.cpp \
 	third_party/WebKit/Source/core/page/DOMWindowPagePopup.cpp \
 	third_party/WebKit/Source/core/page/DOMWindowProperty.cpp \
 	third_party/WebKit/Source/core/page/DragController.cpp \
@@ -452,14 +456,15 @@
 	third_party/WebKit/Source/core/workers/SharedWorkerGlobalScope.cpp \
 	third_party/WebKit/Source/core/workers/SharedWorkerThread.cpp \
 	third_party/WebKit/Source/core/workers/Worker.cpp \
-	third_party/WebKit/Source/core/workers/WorkerGlobalScopeProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerEventQueue.cpp \
+	third_party/WebKit/Source/core/workers/WorkerGlobalScopeProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp \
 	third_party/WebKit/Source/core/workers/WorkerLocation.cpp \
 	third_party/WebKit/Source/core/workers/WorkerMessagingProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerRunLoop.cpp \
 	third_party/WebKit/Source/core/workers/WorkerScriptLoader.cpp \
 	third_party/WebKit/Source/core/workers/WorkerThread.cpp \
+	third_party/WebKit/Source/core/workers/WorkerThreadStartupData.cpp \
 	third_party/WebKit/Source/core/xml/parser/XMLDocumentParser.cpp \
 	third_party/WebKit/Source/core/xml/parser/XMLDocumentParserScope.cpp \
 	third_party/WebKit/Source/core/xml/DocumentXPathEvaluator.cpp \
diff --git a/Source/core/webcore_remaining.target.linux-arm.mk b/Source/core/webcore_remaining.target.linux-arm.mk
index 908dc07..3fdb646 100644
--- a/Source/core/webcore_remaining.target.linux-arm.mk
+++ b/Source/core/webcore_remaining.target.linux-arm.mk
@@ -110,6 +110,7 @@
 	third_party/WebKit/Source/core/css/CSSSelector.cpp \
 	third_party/WebKit/Source/core/css/CSSSelectorList.cpp \
 	third_party/WebKit/Source/core/css/CSSShaderValue.cpp \
+	third_party/WebKit/Source/core/css/CSSStyleDeclaration.cpp \
 	third_party/WebKit/Source/core/css/CSSStyleRule.cpp \
 	third_party/WebKit/Source/core/css/CSSStyleSheet.cpp \
 	third_party/WebKit/Source/core/css/CSSSupportsRule.cpp \
@@ -121,6 +122,7 @@
 	third_party/WebKit/Source/core/css/CSSValue.cpp \
 	third_party/WebKit/Source/core/css/CSSValueList.cpp \
 	third_party/WebKit/Source/core/css/CSSValuePool.cpp \
+	third_party/WebKit/Source/core/css/CSSVariablesMap.cpp \
 	third_party/WebKit/Source/core/css/CSSViewportRule.cpp \
 	third_party/WebKit/Source/core/css/DOMWindowCSS.cpp \
 	third_party/WebKit/Source/core/css/DocumentRuleSets.cpp \
@@ -154,7 +156,7 @@
 	third_party/WebKit/Source/core/css/StyleMedia.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySerializer.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySet.cpp \
-	third_party/WebKit/Source/core/css/StylePropertyShorthand.cpp \
+	third_party/WebKit/Source/core/css/StylePropertyShorthandCustom.cpp \
 	third_party/WebKit/Source/core/css/StyleRule.cpp \
 	third_party/WebKit/Source/core/css/StyleRuleImport.cpp \
 	third_party/WebKit/Source/core/css/StyleSheet.cpp \
@@ -372,6 +374,8 @@
 	third_party/WebKit/Source/core/page/DOMSelection.cpp \
 	third_party/WebKit/Source/core/page/DOMTimer.cpp \
 	third_party/WebKit/Source/core/page/DOMWindow.cpp \
+	third_party/WebKit/Source/core/page/DOMWindowBase64.cpp \
+	third_party/WebKit/Source/core/page/DOMWindowTimers.cpp \
 	third_party/WebKit/Source/core/page/DOMWindowPagePopup.cpp \
 	third_party/WebKit/Source/core/page/DOMWindowProperty.cpp \
 	third_party/WebKit/Source/core/page/DragController.cpp \
@@ -452,14 +456,15 @@
 	third_party/WebKit/Source/core/workers/SharedWorkerGlobalScope.cpp \
 	third_party/WebKit/Source/core/workers/SharedWorkerThread.cpp \
 	third_party/WebKit/Source/core/workers/Worker.cpp \
-	third_party/WebKit/Source/core/workers/WorkerGlobalScopeProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerEventQueue.cpp \
+	third_party/WebKit/Source/core/workers/WorkerGlobalScopeProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp \
 	third_party/WebKit/Source/core/workers/WorkerLocation.cpp \
 	third_party/WebKit/Source/core/workers/WorkerMessagingProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerRunLoop.cpp \
 	third_party/WebKit/Source/core/workers/WorkerScriptLoader.cpp \
 	third_party/WebKit/Source/core/workers/WorkerThread.cpp \
+	third_party/WebKit/Source/core/workers/WorkerThreadStartupData.cpp \
 	third_party/WebKit/Source/core/xml/parser/XMLDocumentParser.cpp \
 	third_party/WebKit/Source/core/xml/parser/XMLDocumentParserScope.cpp \
 	third_party/WebKit/Source/core/xml/DocumentXPathEvaluator.cpp \
diff --git a/Source/core/webcore_remaining.target.linux-mips.mk b/Source/core/webcore_remaining.target.linux-mips.mk
index 719cc6a..e52010a 100644
--- a/Source/core/webcore_remaining.target.linux-mips.mk
+++ b/Source/core/webcore_remaining.target.linux-mips.mk
@@ -110,6 +110,7 @@
 	third_party/WebKit/Source/core/css/CSSSelector.cpp \
 	third_party/WebKit/Source/core/css/CSSSelectorList.cpp \
 	third_party/WebKit/Source/core/css/CSSShaderValue.cpp \
+	third_party/WebKit/Source/core/css/CSSStyleDeclaration.cpp \
 	third_party/WebKit/Source/core/css/CSSStyleRule.cpp \
 	third_party/WebKit/Source/core/css/CSSStyleSheet.cpp \
 	third_party/WebKit/Source/core/css/CSSSupportsRule.cpp \
@@ -121,6 +122,7 @@
 	third_party/WebKit/Source/core/css/CSSValue.cpp \
 	third_party/WebKit/Source/core/css/CSSValueList.cpp \
 	third_party/WebKit/Source/core/css/CSSValuePool.cpp \
+	third_party/WebKit/Source/core/css/CSSVariablesMap.cpp \
 	third_party/WebKit/Source/core/css/CSSViewportRule.cpp \
 	third_party/WebKit/Source/core/css/DOMWindowCSS.cpp \
 	third_party/WebKit/Source/core/css/DocumentRuleSets.cpp \
@@ -154,7 +156,7 @@
 	third_party/WebKit/Source/core/css/StyleMedia.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySerializer.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySet.cpp \
-	third_party/WebKit/Source/core/css/StylePropertyShorthand.cpp \
+	third_party/WebKit/Source/core/css/StylePropertyShorthandCustom.cpp \
 	third_party/WebKit/Source/core/css/StyleRule.cpp \
 	third_party/WebKit/Source/core/css/StyleRuleImport.cpp \
 	third_party/WebKit/Source/core/css/StyleSheet.cpp \
@@ -372,6 +374,8 @@
 	third_party/WebKit/Source/core/page/DOMSelection.cpp \
 	third_party/WebKit/Source/core/page/DOMTimer.cpp \
 	third_party/WebKit/Source/core/page/DOMWindow.cpp \
+	third_party/WebKit/Source/core/page/DOMWindowBase64.cpp \
+	third_party/WebKit/Source/core/page/DOMWindowTimers.cpp \
 	third_party/WebKit/Source/core/page/DOMWindowPagePopup.cpp \
 	third_party/WebKit/Source/core/page/DOMWindowProperty.cpp \
 	third_party/WebKit/Source/core/page/DragController.cpp \
@@ -452,14 +456,15 @@
 	third_party/WebKit/Source/core/workers/SharedWorkerGlobalScope.cpp \
 	third_party/WebKit/Source/core/workers/SharedWorkerThread.cpp \
 	third_party/WebKit/Source/core/workers/Worker.cpp \
-	third_party/WebKit/Source/core/workers/WorkerGlobalScopeProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerEventQueue.cpp \
+	third_party/WebKit/Source/core/workers/WorkerGlobalScopeProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp \
 	third_party/WebKit/Source/core/workers/WorkerLocation.cpp \
 	third_party/WebKit/Source/core/workers/WorkerMessagingProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerRunLoop.cpp \
 	third_party/WebKit/Source/core/workers/WorkerScriptLoader.cpp \
 	third_party/WebKit/Source/core/workers/WorkerThread.cpp \
+	third_party/WebKit/Source/core/workers/WorkerThreadStartupData.cpp \
 	third_party/WebKit/Source/core/xml/parser/XMLDocumentParser.cpp \
 	third_party/WebKit/Source/core/xml/parser/XMLDocumentParserScope.cpp \
 	third_party/WebKit/Source/core/xml/DocumentXPathEvaluator.cpp \
diff --git a/Source/core/webcore_remaining.target.linux-x86.mk b/Source/core/webcore_remaining.target.linux-x86.mk
index acd7cb3..f42f81f 100644
--- a/Source/core/webcore_remaining.target.linux-x86.mk
+++ b/Source/core/webcore_remaining.target.linux-x86.mk
@@ -110,6 +110,7 @@
 	third_party/WebKit/Source/core/css/CSSSelector.cpp \
 	third_party/WebKit/Source/core/css/CSSSelectorList.cpp \
 	third_party/WebKit/Source/core/css/CSSShaderValue.cpp \
+	third_party/WebKit/Source/core/css/CSSStyleDeclaration.cpp \
 	third_party/WebKit/Source/core/css/CSSStyleRule.cpp \
 	third_party/WebKit/Source/core/css/CSSStyleSheet.cpp \
 	third_party/WebKit/Source/core/css/CSSSupportsRule.cpp \
@@ -121,6 +122,7 @@
 	third_party/WebKit/Source/core/css/CSSValue.cpp \
 	third_party/WebKit/Source/core/css/CSSValueList.cpp \
 	third_party/WebKit/Source/core/css/CSSValuePool.cpp \
+	third_party/WebKit/Source/core/css/CSSVariablesMap.cpp \
 	third_party/WebKit/Source/core/css/CSSViewportRule.cpp \
 	third_party/WebKit/Source/core/css/DOMWindowCSS.cpp \
 	third_party/WebKit/Source/core/css/DocumentRuleSets.cpp \
@@ -154,7 +156,7 @@
 	third_party/WebKit/Source/core/css/StyleMedia.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySerializer.cpp \
 	third_party/WebKit/Source/core/css/StylePropertySet.cpp \
-	third_party/WebKit/Source/core/css/StylePropertyShorthand.cpp \
+	third_party/WebKit/Source/core/css/StylePropertyShorthandCustom.cpp \
 	third_party/WebKit/Source/core/css/StyleRule.cpp \
 	third_party/WebKit/Source/core/css/StyleRuleImport.cpp \
 	third_party/WebKit/Source/core/css/StyleSheet.cpp \
@@ -372,6 +374,8 @@
 	third_party/WebKit/Source/core/page/DOMSelection.cpp \
 	third_party/WebKit/Source/core/page/DOMTimer.cpp \
 	third_party/WebKit/Source/core/page/DOMWindow.cpp \
+	third_party/WebKit/Source/core/page/DOMWindowBase64.cpp \
+	third_party/WebKit/Source/core/page/DOMWindowTimers.cpp \
 	third_party/WebKit/Source/core/page/DOMWindowPagePopup.cpp \
 	third_party/WebKit/Source/core/page/DOMWindowProperty.cpp \
 	third_party/WebKit/Source/core/page/DragController.cpp \
@@ -452,14 +456,15 @@
 	third_party/WebKit/Source/core/workers/SharedWorkerGlobalScope.cpp \
 	third_party/WebKit/Source/core/workers/SharedWorkerThread.cpp \
 	third_party/WebKit/Source/core/workers/Worker.cpp \
-	third_party/WebKit/Source/core/workers/WorkerGlobalScopeProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerEventQueue.cpp \
+	third_party/WebKit/Source/core/workers/WorkerGlobalScopeProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp \
 	third_party/WebKit/Source/core/workers/WorkerLocation.cpp \
 	third_party/WebKit/Source/core/workers/WorkerMessagingProxy.cpp \
 	third_party/WebKit/Source/core/workers/WorkerRunLoop.cpp \
 	third_party/WebKit/Source/core/workers/WorkerScriptLoader.cpp \
 	third_party/WebKit/Source/core/workers/WorkerThread.cpp \
+	third_party/WebKit/Source/core/workers/WorkerThreadStartupData.cpp \
 	third_party/WebKit/Source/core/xml/parser/XMLDocumentParser.cpp \
 	third_party/WebKit/Source/core/xml/parser/XMLDocumentParserScope.cpp \
 	third_party/WebKit/Source/core/xml/DocumentXPathEvaluator.cpp \
diff --git a/Source/core/workers/AbstractWorker.cpp b/Source/core/workers/AbstractWorker.cpp
index 1d1eee0..e4b9c7f 100644
--- a/Source/core/workers/AbstractWorker.cpp
+++ b/Source/core/workers/AbstractWorker.cpp
@@ -29,9 +29,9 @@
  */
 
 #include "config.h"
-
 #include "core/workers/AbstractWorker.h"
 
+#include "bindings/v8/ExceptionState.h"
 #include "core/dom/EventNames.h"
 #include "core/dom/ExceptionCode.h"
 #include "core/dom/ScriptExecutionContext.h"
@@ -54,27 +54,27 @@
     ActiveDOMObject::contextDestroyed();
 }
 
-KURL AbstractWorker::resolveURL(const String& url, ExceptionCode& ec)
+KURL AbstractWorker::resolveURL(const String& url, ExceptionState& es)
 {
     if (url.isEmpty()) {
-        ec = SyntaxError;
+        es.throwDOMException(SyntaxError);
         return KURL();
     }
 
     // FIXME: This should use the dynamic global scope (bug #27887)
     KURL scriptURL = scriptExecutionContext()->completeURL(url);
     if (!scriptURL.isValid()) {
-        ec = SyntaxError;
+        es.throwDOMException(SyntaxError);
         return KURL();
     }
 
     if (!scriptExecutionContext()->securityOrigin()->canRequest(scriptURL)) {
-        ec = SecurityError;
+        es.throwDOMException(SecurityError);
         return KURL();
     }
 
     if (scriptExecutionContext()->contentSecurityPolicy() && !scriptExecutionContext()->contentSecurityPolicy()->allowScriptFromSource(scriptURL)) {
-        ec = SecurityError;
+        es.throwDOMException(SecurityError);
         return KURL();
     }
 
diff --git a/Source/core/workers/AbstractWorker.h b/Source/core/workers/AbstractWorker.h
index 13bb929..5805534 100644
--- a/Source/core/workers/AbstractWorker.h
+++ b/Source/core/workers/AbstractWorker.h
@@ -43,36 +43,37 @@
 
 namespace WebCore {
 
-    class KURL;
-    class ScriptExecutionContext;
+class ExceptionState;
+class KURL;
+class ScriptExecutionContext;
 
-    class AbstractWorker : public RefCounted<AbstractWorker>, public EventTarget, public ActiveDOMObject {
-    public:
-        // EventTarget APIs
-        virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { return ActiveDOMObject::scriptExecutionContext(); }
+class AbstractWorker : public RefCounted<AbstractWorker>, public EventTarget, public ActiveDOMObject {
+public:
+    // EventTarget APIs
+    virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { return ActiveDOMObject::scriptExecutionContext(); }
 
-        DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
+    DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
 
-        using RefCounted<AbstractWorker>::ref;
-        using RefCounted<AbstractWorker>::deref;
+    using RefCounted<AbstractWorker>::ref;
+    using RefCounted<AbstractWorker>::deref;
 
-        virtual void contextDestroyed() OVERRIDE;
-        AbstractWorker(ScriptExecutionContext*);
-        virtual ~AbstractWorker();
+    virtual void contextDestroyed() OVERRIDE;
+    AbstractWorker(ScriptExecutionContext*);
+    virtual ~AbstractWorker();
 
-    protected:
-        // Helper function that converts a URL to an absolute URL and checks the result for validity.
-        KURL resolveURL(const String& url, ExceptionCode& ec);
-        intptr_t asID() const { return reinterpret_cast<intptr_t>(this); }
+protected:
+    // Helper function that converts a URL to an absolute URL and checks the result for validity.
+    KURL resolveURL(const String& url, ExceptionState&);
+    intptr_t asID() const { return reinterpret_cast<intptr_t>(this); }
 
-    private:
-        virtual void refEventTarget() OVERRIDE { ref(); }
-        virtual void derefEventTarget() OVERRIDE { deref(); }
-        virtual EventTargetData* eventTargetData() OVERRIDE;
-        virtual EventTargetData* ensureEventTargetData() OVERRIDE;
-        
-        EventTargetData m_eventTargetData;
-    };
+private:
+    virtual void refEventTarget() OVERRIDE { ref(); }
+    virtual void derefEventTarget() OVERRIDE { deref(); }
+    virtual EventTargetData* eventTargetData() OVERRIDE;
+    virtual EventTargetData* ensureEventTargetData() OVERRIDE;
+
+    EventTargetData m_eventTargetData;
+};
 
 } // namespace WebCore
 
diff --git a/Source/core/workers/AbstractWorker.idl b/Source/core/workers/AbstractWorker.idl
index 4211e68..2b6e1f9 100644
--- a/Source/core/workers/AbstractWorker.idl
+++ b/Source/core/workers/AbstractWorker.idl
@@ -30,7 +30,8 @@
  */
 
 [
-    NoInterfaceObject
+    NoInterfaceObject,
+    LegacyImplementedInBaseClass
 ] interface AbstractWorker {
     attribute EventListener onerror;
 };
diff --git a/Source/core/workers/DedicatedWorkerGlobalScope.cpp b/Source/core/workers/DedicatedWorkerGlobalScope.cpp
index 0992639..358f8cb 100644
--- a/Source/core/workers/DedicatedWorkerGlobalScope.cpp
+++ b/Source/core/workers/DedicatedWorkerGlobalScope.cpp
@@ -29,24 +29,26 @@
  */
 
 #include "config.h"
-
 #include "core/workers/DedicatedWorkerGlobalScope.h"
 
+#include "bindings/v8/ExceptionState.h"
 #include "core/page/DOMWindow.h"
 #include "core/workers/DedicatedWorkerThread.h"
+#include "core/workers/WorkerClients.h"
 #include "core/workers/WorkerObjectProxy.h"
+#include "core/workers/WorkerThreadStartupData.h"
 
 namespace WebCore {
 
-PassRefPtr<DedicatedWorkerGlobalScope> DedicatedWorkerGlobalScope::create(const KURL& url, const String& userAgent, DedicatedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, PassRefPtr<SecurityOrigin> topOrigin, double timeOrigin)
+PassRefPtr<DedicatedWorkerGlobalScope> DedicatedWorkerGlobalScope::create(DedicatedWorkerThread* thread, PassOwnPtr<WorkerThreadStartupData> startupData, double timeOrigin)
 {
-    RefPtr<DedicatedWorkerGlobalScope> context = adoptRef(new DedicatedWorkerGlobalScope(url, userAgent, thread, topOrigin, timeOrigin));
-    context->applyContentSecurityPolicyFromString(contentSecurityPolicy, contentSecurityPolicyType);
+    RefPtr<DedicatedWorkerGlobalScope> context = adoptRef(new DedicatedWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, thread, startupData->m_topOrigin, timeOrigin, startupData->m_workerClients.release()));
+    context->applyContentSecurityPolicyFromString(startupData->m_contentSecurityPolicy, startupData->m_contentSecurityPolicyType);
     return context.release();
 }
 
-DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(const KURL& url, const String& userAgent, DedicatedWorkerThread* thread, PassRefPtr<SecurityOrigin> topOrigin, double timeOrigin)
-    : WorkerGlobalScope(url, userAgent, thread, topOrigin, timeOrigin)
+DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(const KURL& url, const String& userAgent, DedicatedWorkerThread* thread, PassRefPtr<SecurityOrigin> topOrigin, double timeOrigin, PassOwnPtr<WorkerClients> workerClients)
+    : WorkerGlobalScope(url, userAgent, thread, topOrigin, timeOrigin, workerClients)
 {
     ScriptWrappable::init(this);
 }
@@ -60,18 +62,18 @@
     return eventNames().interfaceForDedicatedWorkerGlobalScope;
 }
 
-void DedicatedWorkerGlobalScope::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionCode& ec)
+void DedicatedWorkerGlobalScope::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionState& es)
 {
     // Disentangle the port in preparation for sending it to the remote context.
-    OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, ec);
-    if (ec)
+    OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, es);
+    if (es.hadException())
         return;
     thread()->workerObjectProxy().postMessageToWorkerObject(message, channels.release());
 }
 
-void DedicatedWorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionCode& ec)
+void DedicatedWorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState& es)
 {
-    Base::importScripts(urls, ec);
+    Base::importScripts(urls, es);
     thread()->workerObjectProxy().reportPendingActivity(hasPendingActivity());
 }
 
diff --git a/Source/core/workers/DedicatedWorkerGlobalScope.h b/Source/core/workers/DedicatedWorkerGlobalScope.h
index 9654a46..022145d 100644
--- a/Source/core/workers/DedicatedWorkerGlobalScope.h
+++ b/Source/core/workers/DedicatedWorkerGlobalScope.h
@@ -37,31 +37,32 @@
 
 namespace WebCore {
 
-    class DedicatedWorkerThread;
+class DedicatedWorkerThread;
+struct WorkerThreadStartupData;
 
-    class DedicatedWorkerGlobalScope : public WorkerGlobalScope {
-    public:
-        typedef WorkerGlobalScope Base;
-        static PassRefPtr<DedicatedWorkerGlobalScope> create(const KURL&, const String& userAgent, DedicatedWorkerThread*, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, PassRefPtr<SecurityOrigin> topOrigin, double timeOrigin);
-        virtual ~DedicatedWorkerGlobalScope();
+class DedicatedWorkerGlobalScope : public WorkerGlobalScope {
+public:
+    typedef WorkerGlobalScope Base;
+    static PassRefPtr<DedicatedWorkerGlobalScope> create(DedicatedWorkerThread*, PassOwnPtr<WorkerThreadStartupData>, double timeOrigin);
+    virtual ~DedicatedWorkerGlobalScope();
 
-        virtual bool isDedicatedWorkerGlobalScope() const OVERRIDE { return true; }
+    virtual bool isDedicatedWorkerGlobalScope() const OVERRIDE { return true; }
 
-        // Overridden to allow us to check our pending activity after executing imported script.
-        virtual void importScripts(const Vector<String>& urls, ExceptionCode&) OVERRIDE;
+    // Overridden to allow us to check our pending activity after executing imported script.
+    virtual void importScripts(const Vector<String>& urls, ExceptionState&) OVERRIDE;
 
-        // EventTarget
-        virtual const AtomicString& interfaceName() const OVERRIDE;
+    // EventTarget
+    virtual const AtomicString& interfaceName() const OVERRIDE;
 
-        void postMessage(PassRefPtr<SerializedScriptValue>, const MessagePortArray*, ExceptionCode&);
+    void postMessage(PassRefPtr<SerializedScriptValue>, const MessagePortArray*, ExceptionState&);
 
-        DEFINE_ATTRIBUTE_EVENT_LISTENER(message);
+    DEFINE_ATTRIBUTE_EVENT_LISTENER(message);
 
-        DedicatedWorkerThread* thread();
+    DedicatedWorkerThread* thread();
 
-    private:
-        DedicatedWorkerGlobalScope(const KURL&, const String& userAgent, DedicatedWorkerThread*, PassRefPtr<SecurityOrigin> topOrigin, double timeOrigin);
-    };
+private:
+    DedicatedWorkerGlobalScope(const KURL&, const String& userAgent, DedicatedWorkerThread*, PassRefPtr<SecurityOrigin> topOrigin, double timeOrigin, PassOwnPtr<WorkerClients>);
+};
 
 } // namespace WebCore
 
diff --git a/Source/core/workers/DedicatedWorkerThread.cpp b/Source/core/workers/DedicatedWorkerThread.cpp
index 30c44f9..94038c6 100644
--- a/Source/core/workers/DedicatedWorkerThread.cpp
+++ b/Source/core/workers/DedicatedWorkerThread.cpp
@@ -34,16 +34,17 @@
 
 #include "core/workers/DedicatedWorkerGlobalScope.h"
 #include "core/workers/WorkerObjectProxy.h"
+#include "core/workers/WorkerThreadStartupData.h"
 
 namespace WebCore {
 
-PassRefPtr<DedicatedWorkerThread> DedicatedWorkerThread::create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin, double timeOrigin)
+PassRefPtr<DedicatedWorkerThread> DedicatedWorkerThread::create(WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, double timeOrigin, PassOwnPtr<WorkerThreadStartupData> startupData)
 {
-    return adoptRef(new DedicatedWorkerThread(scriptURL, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin, timeOrigin));
+    return adoptRef(new DedicatedWorkerThread(workerLoaderProxy, workerObjectProxy, timeOrigin, startupData));
 }
 
-DedicatedWorkerThread::DedicatedWorkerThread(const KURL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin, double timeOrigin)
-    : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin)
+DedicatedWorkerThread::DedicatedWorkerThread(WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, double timeOrigin, PassOwnPtr<WorkerThreadStartupData> startupData)
+    : WorkerThread(workerLoaderProxy, workerObjectProxy, startupData)
     , m_workerObjectProxy(workerObjectProxy)
     , m_timeOrigin(timeOrigin)
 {
@@ -53,9 +54,9 @@
 {
 }
 
-PassRefPtr<WorkerGlobalScope> DedicatedWorkerThread::createWorkerGlobalScope(const KURL& url, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, PassRefPtr<SecurityOrigin> topOrigin)
+PassRefPtr<WorkerGlobalScope> DedicatedWorkerThread::createWorkerGlobalScope(PassOwnPtr<WorkerThreadStartupData> startupData)
 {
-    return DedicatedWorkerGlobalScope::create(url, userAgent, this, contentSecurityPolicy, contentSecurityPolicyType, topOrigin, m_timeOrigin);
+    return DedicatedWorkerGlobalScope::create(this, startupData, m_timeOrigin);
 }
 
 void DedicatedWorkerThread::runEventLoop()
diff --git a/Source/core/workers/DedicatedWorkerThread.h b/Source/core/workers/DedicatedWorkerThread.h
index d4440e1..9701929 100644
--- a/Source/core/workers/DedicatedWorkerThread.h
+++ b/Source/core/workers/DedicatedWorkerThread.h
@@ -35,24 +35,26 @@
 
 namespace WebCore {
 
-    class WorkerObjectProxy;
+class WorkerObjectProxy;
+struct WorkerThreadStartupData;
 
-    class DedicatedWorkerThread : public WorkerThread {
-    public:
-        static PassRefPtr<DedicatedWorkerThread> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType, const SecurityOrigin* topOrigin, double timeOrigin);
-        WorkerObjectProxy& workerObjectProxy() const { return m_workerObjectProxy; }
-        virtual ~DedicatedWorkerThread();
+class DedicatedWorkerThread : public WorkerThread {
+public:
+    static PassRefPtr<DedicatedWorkerThread> create(WorkerLoaderProxy&, WorkerObjectProxy&, double timeOrigin, PassOwnPtr<WorkerThreadStartupData>);
+    WorkerObjectProxy& workerObjectProxy() const { return m_workerObjectProxy; }
+    virtual ~DedicatedWorkerThread();
 
-    protected:
-        virtual PassRefPtr<WorkerGlobalScope> createWorkerGlobalScope(const KURL&, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType, PassRefPtr<SecurityOrigin> topOrigin) OVERRIDE;
-        virtual void runEventLoop() OVERRIDE;
+protected:
+    virtual PassRefPtr<WorkerGlobalScope> createWorkerGlobalScope(PassOwnPtr<WorkerThreadStartupData>) OVERRIDE;
+    virtual void runEventLoop() OVERRIDE;
 
-    private:
-        DedicatedWorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType, const SecurityOrigin* topOrigin, double timeOrigin);
+private:
+    DedicatedWorkerThread(WorkerLoaderProxy&, WorkerObjectProxy&, double timeOrigin, PassOwnPtr<WorkerThreadStartupData>);
 
-        WorkerObjectProxy& m_workerObjectProxy;
-        double m_timeOrigin;
-    };
+    WorkerObjectProxy& m_workerObjectProxy;
+    double m_timeOrigin;
+};
+
 } // namespace WebCore
 
 #endif // DedicatedWorkerThread_h
diff --git a/Source/core/workers/DefaultSharedWorkerRepository.h b/Source/core/workers/DefaultSharedWorkerRepository.h
index de297e7..1237988 100644
--- a/Source/core/workers/DefaultSharedWorkerRepository.h
+++ b/Source/core/workers/DefaultSharedWorkerRepository.h
@@ -44,14 +44,13 @@
 namespace WebCore {
 
     class Document;
+    class ExceptionState;
     class KURL;
     class MessagePortChannel;
     class ScriptExecutionContext;
     class SharedWorker;
     class SharedWorkerProxy;
 
-    typedef int ExceptionCode;
-
     // Platform-specific implementation of the SharedWorkerRepository static interface.
     class DefaultSharedWorkerRepository {
         WTF_MAKE_NONCOPYABLE(DefaultSharedWorkerRepository); WTF_MAKE_FAST_ALLOCATED;
@@ -60,7 +59,7 @@
         void workerScriptLoaded(SharedWorkerProxy&, const String& userAgent, const String& workerScript, PassOwnPtr<MessagePortChannel>, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
 
         // Internal implementation of SharedWorkerRepository::connect()
-        void connectToWorker(PassRefPtr<SharedWorker>, PassOwnPtr<MessagePortChannel>, const KURL&, const String& name, ExceptionCode&);
+        void connectToWorker(PassRefPtr<SharedWorker>, PassOwnPtr<MessagePortChannel>, const KURL&, const String& name, ExceptionState&);
 
         // Notification that a document has been detached.
         void documentDetached(Document*);
diff --git a/Source/core/workers/SharedWorker.cpp b/Source/core/workers/SharedWorker.cpp
index a282eb4..55019ec 100644
--- a/Source/core/workers/SharedWorker.cpp
+++ b/Source/core/workers/SharedWorker.cpp
@@ -30,9 +30,9 @@
  */
 
 #include "config.h"
-
 #include "core/workers/SharedWorker.h"
 
+#include "bindings/v8/ExceptionState.h"
 #include "core/dom/ExceptionCode.h"
 #include "core/dom/MessageChannel.h"
 #include "core/dom/MessagePort.h"
@@ -51,7 +51,7 @@
     ScriptWrappable::init(this);
 }
 
-PassRefPtr<SharedWorker> SharedWorker::create(ScriptExecutionContext* context, const String& url, const String& name, ExceptionCode& ec)
+PassRefPtr<SharedWorker> SharedWorker::create(ScriptExecutionContext* context, const String& url, const String& name, ExceptionState& es)
 {
     ASSERT(isMainThread());
     UseCounter::count(toDocument(context)->domWindow(), UseCounter::SharedWorkerStart);
@@ -65,19 +65,19 @@
 
     worker->suspendIfNeeded();
 
-    KURL scriptURL = worker->resolveURL(url, ec);
+    KURL scriptURL = worker->resolveURL(url, es);
     if (scriptURL.isEmpty())
         return 0;
 
     // We don't currently support nested workers, so workers can only be created from documents.
     ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument());
     Document* document = toDocument(context);
-    if (!document->securityOrigin()->canAccessSharedWorkers(document->topOrigin())) {
-        ec = SecurityError;
+    if (!document->securityOrigin()->canAccessSharedWorkers()) {
+        es.throwDOMException(SecurityError);
         return 0;
     }
 
-    SharedWorkerRepository::connect(worker.get(), remotePort.release(), scriptURL, name, ec);
+    SharedWorkerRepository::connect(worker.get(), remotePort.release(), scriptURL, name, es);
 
     return worker.release();
 }
diff --git a/Source/core/workers/SharedWorker.h b/Source/core/workers/SharedWorker.h
index a84449b..6ec7506 100644
--- a/Source/core/workers/SharedWorker.h
+++ b/Source/core/workers/SharedWorker.h
@@ -36,20 +36,22 @@
 
 namespace WebCore {
 
-    class SharedWorker : public AbstractWorker, public ScriptWrappable {
-    public:
-        static PassRefPtr<SharedWorker> create(ScriptExecutionContext*, const String& url, const String& name, ExceptionCode&);
-        virtual ~SharedWorker();
+class ExceptionState;
 
-        MessagePort* port() const { return m_port.get(); }
+class SharedWorker : public AbstractWorker, public ScriptWrappable {
+public:
+    static PassRefPtr<SharedWorker> create(ScriptExecutionContext*, const String& url, const String& name, ExceptionState&);
+    virtual ~SharedWorker();
 
-        virtual const AtomicString& interfaceName() const OVERRIDE;
+    MessagePort* port() const { return m_port.get(); }
 
-    private:
-        explicit SharedWorker(ScriptExecutionContext*);
+    virtual const AtomicString& interfaceName() const OVERRIDE;
 
-        RefPtr<MessagePort> m_port;
-    };
+private:
+    explicit SharedWorker(ScriptExecutionContext*);
+
+    RefPtr<MessagePort> m_port;
+};
 
 } // namespace WebCore
 
diff --git a/Source/core/workers/SharedWorkerGlobalScope.cpp b/Source/core/workers/SharedWorkerGlobalScope.cpp
index 3f74aa0..f135fe9 100644
--- a/Source/core/workers/SharedWorkerGlobalScope.cpp
+++ b/Source/core/workers/SharedWorkerGlobalScope.cpp
@@ -37,6 +37,8 @@
 #include "core/inspector/ScriptCallStack.h"
 #include "core/page/DOMWindow.h"
 #include "core/workers/SharedWorkerThread.h"
+#include "core/workers/WorkerClients.h"
+#include "core/workers/WorkerThreadStartupData.h"
 #include "wtf/CurrentTime.h"
 
 namespace WebCore {
@@ -49,15 +51,15 @@
 }
 
 // static
-PassRefPtr<SharedWorkerGlobalScope> SharedWorkerGlobalScope::create(const String& name, const KURL& url, const String& userAgent, SharedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
+PassRefPtr<SharedWorkerGlobalScope> SharedWorkerGlobalScope::create(const String& name, SharedWorkerThread* thread, PassOwnPtr<WorkerThreadStartupData> startupData)
 {
-    RefPtr<SharedWorkerGlobalScope> context = adoptRef(new SharedWorkerGlobalScope(name, url, userAgent, thread));
-    context->applyContentSecurityPolicyFromString(contentSecurityPolicy, contentSecurityPolicyType);
+    RefPtr<SharedWorkerGlobalScope> context = adoptRef(new SharedWorkerGlobalScope(name, startupData->m_scriptURL, startupData->m_userAgent, thread, startupData->m_workerClients.release()));
+    context->applyContentSecurityPolicyFromString(startupData->m_contentSecurityPolicy, startupData->m_contentSecurityPolicyType);
     return context.release();
 }
 
-SharedWorkerGlobalScope::SharedWorkerGlobalScope(const String& name, const KURL& url, const String& userAgent, SharedWorkerThread* thread)
-    : WorkerGlobalScope(url, userAgent, thread, 0, monotonicallyIncreasingTime())
+SharedWorkerGlobalScope::SharedWorkerGlobalScope(const String& name, const KURL& url, const String& userAgent, SharedWorkerThread* thread, PassOwnPtr<WorkerClients> workerClients)
+    : WorkerGlobalScope(url, userAgent, thread, 0, monotonicallyIncreasingTime(), workerClients)
     , m_name(name)
 {
     ScriptWrappable::init(this);
@@ -77,9 +79,9 @@
     return static_cast<SharedWorkerThread*>(Base::thread());
 }
 
-void SharedWorkerGlobalScope::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack> callStack)
+void SharedWorkerGlobalScope::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack> callStack)
 {
-    WorkerGlobalScope::logExceptionToConsole(errorMessage, sourceURL, lineNumber, callStack);
+    WorkerGlobalScope::logExceptionToConsole(errorMessage, sourceURL, lineNumber, columnNumber, callStack);
     addMessageToWorkerConsole(JSMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, callStack);
 }
 
diff --git a/Source/core/workers/SharedWorkerGlobalScope.h b/Source/core/workers/SharedWorkerGlobalScope.h
index 1d4a48f..be91077 100644
--- a/Source/core/workers/SharedWorkerGlobalScope.h
+++ b/Source/core/workers/SharedWorkerGlobalScope.h
@@ -33,6 +33,7 @@
 
 #include "core/page/ContentSecurityPolicy.h"
 #include "core/workers/WorkerGlobalScope.h"
+#include "core/workers/WorkerThreadStartupData.h"
 
 namespace WebCore {
 
@@ -42,7 +43,7 @@
     class SharedWorkerGlobalScope : public WorkerGlobalScope {
     public:
         typedef WorkerGlobalScope Base;
-        static PassRefPtr<SharedWorkerGlobalScope> create(const String& name, const KURL&, const String& userAgent, SharedWorkerThread*, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType);
+        static PassRefPtr<SharedWorkerGlobalScope> create(const String& name, SharedWorkerThread*, PassOwnPtr<WorkerThreadStartupData>);
         virtual ~SharedWorkerGlobalScope();
 
         virtual bool isSharedWorkerGlobalScope() const OVERRIDE { return true; }
@@ -57,8 +58,8 @@
         SharedWorkerThread* thread();
 
     private:
-        SharedWorkerGlobalScope(const String& name, const KURL&, const String& userAgent, SharedWorkerThread*);
-        virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) OVERRIDE;
+        SharedWorkerGlobalScope(const String& name, const KURL&, const String& userAgent, SharedWorkerThread*, PassOwnPtr<WorkerClients>);
+        virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) OVERRIDE;
 
         String m_name;
     };
diff --git a/Source/core/workers/SharedWorkerRepository.h b/Source/core/workers/SharedWorkerRepository.h
index 685d7b6..6a3927a 100644
--- a/Source/core/workers/SharedWorkerRepository.h
+++ b/Source/core/workers/SharedWorkerRepository.h
@@ -38,12 +38,11 @@
 namespace WebCore {
 
     class Document;
+    class ExceptionState;
     class KURL;
     class MessagePortChannel;
     class SharedWorker;
 
-    typedef int ExceptionCode;
-
     // Interface to a repository which manages references to the set of active shared workers.
     class SharedWorkerRepository {
     public:
@@ -51,7 +50,7 @@
         static bool isAvailable();
 
         // Connects the passed SharedWorker object with the specified worker thread, creating a new thread if necessary.
-        static void connect(PassRefPtr<SharedWorker>, PassOwnPtr<MessagePortChannel>, const KURL&, const String& name, ExceptionCode&);
+        static void connect(PassRefPtr<SharedWorker>, PassOwnPtr<MessagePortChannel>, const KURL&, const String& name, ExceptionState&);
 
         // Invoked when a document has been detached.
         static void documentDetached(Document*);
diff --git a/Source/core/workers/SharedWorkerThread.cpp b/Source/core/workers/SharedWorkerThread.cpp
index 3688eb1..117b583 100644
--- a/Source/core/workers/SharedWorkerThread.cpp
+++ b/Source/core/workers/SharedWorkerThread.cpp
@@ -33,16 +33,17 @@
 #include "core/workers/SharedWorkerThread.h"
 
 #include "core/workers/SharedWorkerGlobalScope.h"
+#include "core/workers/WorkerThreadStartupData.h"
 
 namespace WebCore {
 
-PassRefPtr<SharedWorkerThread> SharedWorkerThread::create(const String& name, const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
+PassRefPtr<SharedWorkerThread> SharedWorkerThread::create(const String& name, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, PassOwnPtr<WorkerThreadStartupData> startupData)
 {
-    return adoptRef(new SharedWorkerThread(name, scriptURL, userAgent, sourceCode, workerLoaderProxy, workerReportingProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType));
+    return adoptRef(new SharedWorkerThread(name, workerLoaderProxy, workerReportingProxy, startupData));
 }
 
-SharedWorkerThread::SharedWorkerThread(const String& name, const KURL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
-    : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerReportingProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType, 0)
+SharedWorkerThread::SharedWorkerThread(const String& name, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, PassOwnPtr<WorkerThreadStartupData> startupData)
+    : WorkerThread(workerLoaderProxy, workerReportingProxy, startupData)
     , m_name(name.isolatedCopy())
 {
 }
@@ -51,9 +52,9 @@
 {
 }
 
-PassRefPtr<WorkerGlobalScope> SharedWorkerThread::createWorkerGlobalScope(const KURL& url, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, PassRefPtr<SecurityOrigin>)
+PassRefPtr<WorkerGlobalScope> SharedWorkerThread::createWorkerGlobalScope(PassOwnPtr<WorkerThreadStartupData> startupData)
 {
-    return SharedWorkerGlobalScope::create(m_name, url, userAgent, this, contentSecurityPolicy, contentSecurityPolicyType);
+    return SharedWorkerGlobalScope::create(m_name, this, startupData);
 }
 
 } // namespace WebCore
diff --git a/Source/core/workers/SharedWorkerThread.h b/Source/core/workers/SharedWorkerThread.h
index 955ce4f..70a5d0e 100644
--- a/Source/core/workers/SharedWorkerThread.h
+++ b/Source/core/workers/SharedWorkerThread.h
@@ -35,19 +35,22 @@
 
 namespace WebCore {
 
-    class SharedWorkerThread : public WorkerThread {
-    public:
-        static PassRefPtr<SharedWorkerThread> create(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
-        virtual ~SharedWorkerThread();
+struct WorkerThreadStartupData;
 
-    protected:
-        virtual PassRefPtr<WorkerGlobalScope> createWorkerGlobalScope(const KURL&, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType, PassRefPtr<SecurityOrigin> topOrigin) OVERRIDE;
+class SharedWorkerThread : public WorkerThread {
+public:
+    static PassRefPtr<SharedWorkerThread> create(const String& name, WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtr<WorkerThreadStartupData>);
+    virtual ~SharedWorkerThread();
 
-    private:
-        SharedWorkerThread(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
+protected:
+    virtual PassRefPtr<WorkerGlobalScope> createWorkerGlobalScope(PassOwnPtr<WorkerThreadStartupData>) OVERRIDE;
 
-        String m_name;
-    };
+private:
+    SharedWorkerThread(const String& name, WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtr<WorkerThreadStartupData>);
+
+    String m_name;
+};
+
 } // namespace WebCore
 
 #endif // SharedWorkerThread_h
diff --git a/Source/core/workers/Worker.cpp b/Source/core/workers/Worker.cpp
index a5f8893..50e62b1 100644
--- a/Source/core/workers/Worker.cpp
+++ b/Source/core/workers/Worker.cpp
@@ -26,13 +26,12 @@
  */
 
 #include "config.h"
-
 #include "core/workers/Worker.h"
 
+#include "bindings/v8/ExceptionState.h"
 #include "core/dom/Document.h"
 #include "core/dom/EventListener.h"
 #include "core/dom/EventNames.h"
-#include "core/dom/ExceptionCode.h"
 #include "core/dom/MessageEvent.h"
 #include "core/inspector/InspectorInstrumentation.h"
 #include "core/loader/FrameLoader.h"
@@ -54,7 +53,7 @@
     ScriptWrappable::init(this);
 }
 
-PassRefPtr<Worker> Worker::create(ScriptExecutionContext* context, const String& url, ExceptionCode& ec)
+PassRefPtr<Worker> Worker::create(ScriptExecutionContext* context, const String& url, ExceptionState& es)
 {
     ASSERT(isMainThread());
     UseCounter::count(toDocument(context)->domWindow(), UseCounter::WorkerStart);
@@ -63,7 +62,7 @@
 
     worker->suspendIfNeeded();
 
-    KURL scriptURL = worker->resolveURL(url, ec);
+    KURL scriptURL = worker->resolveURL(url, es);
     if (scriptURL.isEmpty())
         return 0;
 
@@ -88,11 +87,11 @@
     return eventNames().interfaceForWorker;
 }
 
-void Worker::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionCode& ec)
+void Worker::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionState& es)
 {
     // Disentangle the port in preparation for sending it to the remote context.
-    OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, ec);
-    if (ec)
+    OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, es);
+    if (es.hadException())
         return;
     m_contextProxy->postMessageToWorkerGlobalScope(message, channels.release());
 }
diff --git a/Source/core/workers/Worker.h b/Source/core/workers/Worker.h
index b11bf48..8c6f7d2 100644
--- a/Source/core/workers/Worker.h
+++ b/Source/core/workers/Worker.h
@@ -41,42 +41,41 @@
 
 namespace WebCore {
 
-    class ScriptExecutionContext;
-    class WorkerGlobalScopeProxy;
-    class WorkerScriptLoader;
+class ExceptionState;
+class ScriptExecutionContext;
+class WorkerGlobalScopeProxy;
+class WorkerScriptLoader;
 
-    typedef int ExceptionCode;
+class Worker : public AbstractWorker, public ScriptWrappable, private WorkerScriptLoaderClient {
+public:
+    static PassRefPtr<Worker> create(ScriptExecutionContext*, const String& url, ExceptionState&);
+    virtual ~Worker();
 
-    class Worker : public AbstractWorker, public ScriptWrappable, private WorkerScriptLoaderClient {
-    public:
-        static PassRefPtr<Worker> create(ScriptExecutionContext*, const String& url, ExceptionCode&);
-        virtual ~Worker();
+    virtual const AtomicString& interfaceName() const OVERRIDE;
 
-        virtual const AtomicString& interfaceName() const OVERRIDE;
+    void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, ExceptionState&);
 
-        void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, ExceptionCode&);
+    void terminate();
 
-        void terminate();
+    virtual bool canSuspend() const OVERRIDE;
+    virtual void stop() OVERRIDE;
+    virtual bool hasPendingActivity() const OVERRIDE;
 
-        virtual bool canSuspend() const OVERRIDE;
-        virtual void stop() OVERRIDE;
-        virtual bool hasPendingActivity() const OVERRIDE;
+    DEFINE_ATTRIBUTE_EVENT_LISTENER(message);
 
-        DEFINE_ATTRIBUTE_EVENT_LISTENER(message);
+private:
+    explicit Worker(ScriptExecutionContext*);
 
-    private:
-        explicit Worker(ScriptExecutionContext*);
+    // WorkerScriptLoaderClient callbacks
+    virtual void didReceiveResponse(unsigned long identifier, const ResourceResponse&) OVERRIDE;
+    virtual void notifyFinished() OVERRIDE;
 
-        // WorkerScriptLoaderClient callbacks
-        virtual void didReceiveResponse(unsigned long identifier, const ResourceResponse&) OVERRIDE;
-        virtual void notifyFinished() OVERRIDE;
+    virtual void refEventTarget() OVERRIDE { ref(); }
+    virtual void derefEventTarget() OVERRIDE { deref(); }
 
-        virtual void refEventTarget() OVERRIDE { ref(); }
-        virtual void derefEventTarget() OVERRIDE { deref(); }
-
-        RefPtr<WorkerScriptLoader> m_scriptLoader;
-        WorkerGlobalScopeProxy* m_contextProxy; // The proxy outlives the worker to perform thread shutdown.
-    };
+    RefPtr<WorkerScriptLoader> m_scriptLoader;
+    WorkerGlobalScopeProxy* m_contextProxy; // The proxy outlives the worker to perform thread shutdown.
+};
 
 } // namespace WebCore
 
diff --git a/Source/core/workers/WorkerClients.h b/Source/core/workers/WorkerClients.h
new file mode 100644
index 0000000..b362662
--- /dev/null
+++ b/Source/core/workers/WorkerClients.h
@@ -0,0 +1,58 @@
+/*
+ * 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:
+ *
+ *     * 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 WorkerClients_h
+#define WorkerClients_h
+
+#include "core/platform/Supplementable.h"
+#include "wtf/Forward.h"
+
+namespace WebCore {
+
+// This is created on the main thread, passed to the worker thread and
+// attached to WorkerGlobalScope when it is created.
+// This class can be used to provide "client" implementations to Workers.
+class WorkerClients : public Supplementable<WorkerClients> {
+    WTF_MAKE_NONCOPYABLE(WorkerClients);
+public:
+    static PassOwnPtr<WorkerClients> create()
+    {
+        return adoptPtr(new WorkerClients());
+    }
+
+    virtual ~WorkerClients() { }
+
+private:
+    WorkerClients() { }
+};
+
+} // namespace WebCore
+
+#endif // WorkerClients_h
diff --git a/Source/core/workers/WorkerGlobalScope.cpp b/Source/core/workers/WorkerGlobalScope.cpp
index 2321ebf..72cc8f8 100644
--- a/Source/core/workers/WorkerGlobalScope.cpp
+++ b/Source/core/workers/WorkerGlobalScope.cpp
@@ -26,9 +26,9 @@
  */
 
 #include "config.h"
-
 #include "core/workers/WorkerGlobalScope.h"
 
+#include "bindings/v8/ExceptionState.h"
 #include "bindings/v8/ScheduledAction.h"
 #include "bindings/v8/ScriptSourceCode.h"
 #include "bindings/v8/ScriptValue.h"
@@ -36,6 +36,7 @@
 #include "core/dom/ContextLifecycleNotifier.h"
 #include "core/dom/ErrorEvent.h"
 #include "core/dom/Event.h"
+#include "core/dom/ExceptionCode.h"
 #include "core/dom/MessagePort.h"
 #include "core/html/DOMURL.h"
 #include "core/inspector/InspectorConsoleInstrumentation.h"
@@ -43,10 +44,10 @@
 #include "core/inspector/WorkerInspectorController.h"
 #include "core/loader/WorkerThreadableLoader.h"
 #include "core/page/ContentSecurityPolicy.h"
-#include "core/page/DOMTimer.h"
 #include "core/page/DOMWindow.h"
 #include "core/page/WorkerNavigator.h"
 #include "core/platform/NotImplemented.h"
+#include "core/workers/WorkerClients.h"
 #include "core/workers/WorkerLocation.h"
 #include "core/workers/WorkerObjectProxy.h"
 #include "core/workers/WorkerScriptLoader.h"
@@ -60,7 +61,7 @@
 #include "modules/notifications/NotificationCenter.h"
 #endif
 
-#include "core/dom/ExceptionCode.h"
+
 
 namespace WebCore {
 
@@ -81,7 +82,7 @@
     virtual bool isCleanupTask() const { return true; }
 };
 
-WorkerGlobalScope::WorkerGlobalScope(const KURL& url, const String& userAgent, WorkerThread* thread, PassRefPtr<SecurityOrigin> topOrigin, double timeOrigin)
+WorkerGlobalScope::WorkerGlobalScope(const KURL& url, const String& userAgent, WorkerThread* thread, PassRefPtr<SecurityOrigin> topOrigin, double timeOrigin, PassOwnPtr<WorkerClients> workerClients)
     : m_url(url)
     , m_userAgent(userAgent)
     , m_script(adoptPtr(new WorkerScriptController(this)))
@@ -91,9 +92,11 @@
     , m_eventQueue(WorkerEventQueue::create(this))
     , m_topOrigin(topOrigin)
     , m_timeOrigin(timeOrigin)
+    , m_workerClients(workerClients)
 {
     ScriptWrappable::init(this);
     setSecurityOrigin(SecurityOrigin::create(url));
+    m_workerClients->reattachThread();
 }
 
 WorkerGlobalScope::~WorkerGlobalScope()
@@ -179,41 +182,20 @@
     thread()->runLoop().postTask(task);
 }
 
-int WorkerGlobalScope::setTimeout(PassOwnPtr<ScheduledAction> action, int timeout)
-{
-    return DOMTimer::install(scriptExecutionContext(), action, timeout, true);
-}
-
-void WorkerGlobalScope::clearTimeout(int timeoutID)
-{
-    DOMTimer::removeByID(scriptExecutionContext(), timeoutID);
-}
-
 void WorkerGlobalScope::clearInspector()
 {
     m_workerInspectorController.clear();
 }
 
-int WorkerGlobalScope::setInterval(PassOwnPtr<ScheduledAction> action, int timeout)
-{
-    return DOMTimer::install(scriptExecutionContext(), action, timeout, false);
-}
-
-void WorkerGlobalScope::clearInterval(int timeoutID)
-{
-    DOMTimer::removeByID(scriptExecutionContext(), timeoutID);
-}
-
-void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionCode& ec)
+void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState& es)
 {
     ASSERT(contentSecurityPolicy());
-    ec = 0;
     Vector<String>::const_iterator urlsEnd = urls.end();
     Vector<KURL> completedURLs;
     for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it) {
         const KURL& url = scriptExecutionContext()->completeURL(*it);
         if (!url.isValid()) {
-            ec = SyntaxError;
+            es.throwDOMException(SyntaxError);
             return;
         }
         completedURLs.append(url);
@@ -227,7 +209,7 @@
 
         // If the fetching attempt failed, throw a NetworkError exception and abort all these steps.
         if (scriptLoader->failed()) {
-            ec = NetworkError;
+            es.throwDOMException(NetworkError);
             return;
         }
 
@@ -247,9 +229,9 @@
     return this;
 }
 
-void WorkerGlobalScope::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>)
+void WorkerGlobalScope::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>)
 {
-    thread()->workerReportingProxy().postExceptionToWorkerObject(errorMessage, lineNumber, sourceURL);
+    thread()->workerReportingProxy().postExceptionToWorkerObject(errorMessage, lineNumber, columnNumber, sourceURL);
 }
 
 void WorkerGlobalScope::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, unsigned long requestIdentifier)
@@ -349,6 +331,11 @@
     }
 }
 
+bool WorkerGlobalScope::idleNotification()
+{
+    return script()->idleNotification();
+}
+
 WorkerEventQueue* WorkerGlobalScope::eventQueue() const
 {
     return m_eventQueue.get();
diff --git a/Source/core/workers/WorkerGlobalScope.h b/Source/core/workers/WorkerGlobalScope.h
index d8826a5..8e764d4 100644
--- a/Source/core/workers/WorkerGlobalScope.h
+++ b/Source/core/workers/WorkerGlobalScope.h
@@ -47,7 +47,9 @@
 
     class Blob;
     class DOMURL;
+    class ExceptionState;
     class ScheduledAction;
+    class WorkerClients;
     class WorkerInspectorController;
     class WorkerLocation;
     class WorkerNavigator;
@@ -87,15 +89,9 @@
         DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
 
         // WorkerUtils
-        virtual void importScripts(const Vector<String>& urls, ExceptionCode&);
+        virtual void importScripts(const Vector<String>& urls, ExceptionState&);
         WorkerNavigator* navigator() const;
 
-        // Timers
-        int setTimeout(PassOwnPtr<ScheduledAction>, int timeout);
-        void clearTimeout(int timeoutId);
-        int setInterval(PassOwnPtr<ScheduledAction>, int timeout);
-        void clearInterval(int timeoutId);
-
         // ScriptExecutionContext
         virtual WorkerEventQueue* eventQueue() const OVERRIDE;
 
@@ -129,15 +125,19 @@
         void unregisterObserver(Observer*);
         void notifyObserversOfStop();
 
+        bool idleNotification();
+
         virtual const SecurityOrigin* topOrigin() const OVERRIDE { return m_topOrigin.get(); }
 
         double timeOrigin() const { return m_timeOrigin; }
 
+        WorkerClients* clients() { return m_workerClients.get(); }
+
     protected:
-        WorkerGlobalScope(const KURL&, const String& userAgent, WorkerThread*, PassRefPtr<SecurityOrigin> topOrigin, double timeOrigin);
+        WorkerGlobalScope(const KURL&, const String& userAgent, WorkerThread*, PassRefPtr<SecurityOrigin> topOrigin, double timeOrigin, PassOwnPtr<WorkerClients>);
         void applyContentSecurityPolicyFromString(const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
 
-        virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) OVERRIDE;
+        virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) OVERRIDE;
         void addMessageToWorkerConsole(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack>, ScriptState* = 0, unsigned long requestIdentifier = 0);
 
     private:
@@ -177,6 +177,8 @@
 
         RefPtr<SecurityOrigin> m_topOrigin;
 
+        OwnPtr<WorkerClients> m_workerClients;
+
         double m_timeOrigin;
     };
 
diff --git a/Source/core/workers/WorkerGlobalScope.idl b/Source/core/workers/WorkerGlobalScope.idl
index e709f70..1a65c31 100644
--- a/Source/core/workers/WorkerGlobalScope.idl
+++ b/Source/core/workers/WorkerGlobalScope.idl
@@ -44,5 +44,5 @@
     attribute URLConstructor webkitURL; // FIXME: deprecate this.
 };
 
+WorkerGlobalScope implements WindowBase64;
 WorkerGlobalScope implements WindowTimers;
-
diff --git a/Source/core/workers/WorkerMessagingProxy.cpp b/Source/core/workers/WorkerMessagingProxy.cpp
index 82a2727..9e51d50 100644
--- a/Source/core/workers/WorkerMessagingProxy.cpp
+++ b/Source/core/workers/WorkerMessagingProxy.cpp
@@ -32,7 +32,6 @@
 #include "core/dom/CrossThreadTask.h"
 #include "core/dom/Document.h"
 #include "core/dom/ErrorEvent.h"
-#include "core/dom/ExceptionCode.h"
 #include "core/dom/MessageEvent.h"
 #include "core/dom/ScriptExecutionContext.h"
 #include "core/inspector/InspectorInstrumentation.h"
@@ -48,6 +47,8 @@
 #include "core/workers/DedicatedWorkerGlobalScope.h"
 #include "core/workers/DedicatedWorkerThread.h"
 #include "core/workers/Worker.h"
+#include "core/workers/WorkerClients.h"
+#include "core/workers/WorkerThreadStartupData.h"
 #include <wtf/MainThread.h>
 
 namespace WebCore {
@@ -113,15 +114,16 @@
 
 class WorkerExceptionTask : public ScriptExecutionContext::Task {
 public:
-    static PassOwnPtr<WorkerExceptionTask> create(const String& errorMessage, int lineNumber, const String& sourceURL, WorkerMessagingProxy* messagingProxy)
+    static PassOwnPtr<WorkerExceptionTask> create(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, WorkerMessagingProxy* messagingProxy)
     {
-        return adoptPtr(new WorkerExceptionTask(errorMessage, lineNumber, sourceURL, messagingProxy));
+        return adoptPtr(new WorkerExceptionTask(errorMessage, lineNumber, columnNumber, sourceURL, messagingProxy));
     }
 
 private:
-    WorkerExceptionTask(const String& errorMessage, int lineNumber, const String& sourceURL, WorkerMessagingProxy* messagingProxy)
+    WorkerExceptionTask(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, WorkerMessagingProxy* messagingProxy)
         : m_errorMessage(errorMessage.isolatedCopy())
         , m_lineNumber(lineNumber)
+        , m_columnNumber(columnNumber)
         , m_sourceURL(sourceURL.isolatedCopy())
         , m_messagingProxy(messagingProxy)
     {
@@ -136,13 +138,14 @@
         // We don't bother checking the askedToTerminate() flag here, because exceptions should *always* be reported even if the thread is terminated.
         // This is intentionally different than the behavior in MessageWorkerTask, because terminated workers no longer deliver messages (section 4.6 of the WebWorker spec), but they do report exceptions.
 
-        bool errorHandled = !workerObject->dispatchEvent(ErrorEvent::create(m_errorMessage, m_sourceURL, m_lineNumber));
+        bool errorHandled = !workerObject->dispatchEvent(ErrorEvent::create(m_errorMessage, m_sourceURL, m_lineNumber, m_columnNumber));
         if (!errorHandled)
-            context->reportException(m_errorMessage, m_lineNumber, m_sourceURL, 0);
+            context->reportException(m_errorMessage, m_lineNumber, m_columnNumber, m_sourceURL, 0);
     }
 
     String m_errorMessage;
     int m_lineNumber;
+    int m_columnNumber;
     String m_sourceURL;
     WorkerMessagingProxy* m_messagingProxy;
 };
@@ -238,7 +241,7 @@
     String m_message;
 };
 
-WorkerMessagingProxy::WorkerMessagingProxy(Worker* workerObject)
+WorkerMessagingProxy::WorkerMessagingProxy(Worker* workerObject, PassOwnPtr<WorkerClients> workerClients)
     : m_scriptExecutionContext(workerObject->scriptExecutionContext())
     , m_workerObject(workerObject)
     , m_mayBeDestroyed(false)
@@ -246,6 +249,7 @@
     , m_workerThreadHadPendingActivity(false)
     , m_askedToTerminate(false)
     , m_pageInspector(0)
+    , m_workerClients(workerClients)
 {
     ASSERT(m_workerObject);
     ASSERT((m_scriptExecutionContext->isDocument() && isMainThread())
@@ -264,7 +268,11 @@
     // FIXME: This need to be revisited when we support nested worker one day
     ASSERT(m_scriptExecutionContext->isDocument());
     Document* document = toDocument(m_scriptExecutionContext.get());
-    RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, sourceCode, *this, *this, startMode, document->contentSecurityPolicy()->deprecatedHeader(), document->contentSecurityPolicy()->deprecatedHeaderType(), document->topOrigin(), document->loader() ? document->loader()->timing()->referenceMonotonicTime() : monotonicallyIncreasingTime());
+
+    OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::create(scriptURL, userAgent, sourceCode, startMode, document->contentSecurityPolicy()->deprecatedHeader(), document->contentSecurityPolicy()->deprecatedHeaderType(), document->topOrigin(), m_workerClients.release());
+    double originTime = document->loader() ? document->loader()->timing()->referenceMonotonicTime() : monotonicallyIncreasingTime();
+
+    RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(*this, *this, originTime, startupData.release());
     workerThreadCreated(thread);
     thread->start();
     InspectorInstrumentation::didStartWorkerGlobalScope(m_scriptExecutionContext.get(), this, scriptURL);
@@ -304,9 +312,9 @@
     m_scriptExecutionContext->postTask(task);
 }
 
-void WorkerMessagingProxy::postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL)
+void WorkerMessagingProxy::postExceptionToWorkerObject(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL)
 {
-    m_scriptExecutionContext->postTask(WorkerExceptionTask::create(errorMessage, lineNumber, sourceURL, this));
+    m_scriptExecutionContext->postTask(WorkerExceptionTask::create(errorMessage, lineNumber, columnNumber, sourceURL, this));
 }
 
 static void postConsoleMessageTask(ScriptExecutionContext* context, WorkerMessagingProxy* messagingProxy, MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL)
diff --git a/Source/core/workers/WorkerMessagingProxy.h b/Source/core/workers/WorkerMessagingProxy.h
index 3a12604..47882d8 100644
--- a/Source/core/workers/WorkerMessagingProxy.h
+++ b/Source/core/workers/WorkerMessagingProxy.h
@@ -43,11 +43,12 @@
     class DedicatedWorkerThread;
     class ScriptExecutionContext;
     class Worker;
+    class WorkerClients;
 
     class WorkerMessagingProxy : public WorkerGlobalScopeProxy, public WorkerObjectProxy, public WorkerLoaderProxy {
         WTF_MAKE_NONCOPYABLE(WorkerMessagingProxy); WTF_MAKE_FAST_ALLOCATED;
     public:
-        explicit WorkerMessagingProxy(Worker*);
+        WorkerMessagingProxy(Worker*, PassOwnPtr<WorkerClients>);
 
         // Implementations of WorkerGlobalScopeProxy.
         // (Only use these methods in the worker object thread.)
@@ -63,7 +64,7 @@
         // Implementations of WorkerObjectProxy.
         // (Only use these methods in the worker context thread.)
         virtual void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>) OVERRIDE;
-        virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL) OVERRIDE;
+        virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) OVERRIDE;
         virtual void postConsoleMessageToWorkerObject(MessageSource, MessageLevel, const String& message, int lineNumber, const String& sourceURL) OVERRIDE;
         virtual void postMessageToPageInspector(const String&) OVERRIDE;
         virtual void updateInspectorStateCookie(const String&) OVERRIDE;
@@ -110,6 +111,8 @@
 
         Vector<OwnPtr<ScriptExecutionContext::Task> > m_queuedEarlyTasks; // Tasks are queued here until there's a thread object created.
         WorkerGlobalScopeProxy::PageInspector* m_pageInspector;
+
+        OwnPtr<WorkerClients> m_workerClients;
     };
 
 } // namespace WebCore
diff --git a/Source/core/workers/WorkerReportingProxy.h b/Source/core/workers/WorkerReportingProxy.h
index 7ecc015..a42df14 100644
--- a/Source/core/workers/WorkerReportingProxy.h
+++ b/Source/core/workers/WorkerReportingProxy.h
@@ -41,7 +41,7 @@
     public:
         virtual ~WorkerReportingProxy() {}
 
-        virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL) = 0;
+        virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) = 0;
 
         virtual void postConsoleMessageToWorkerObject(MessageSource, MessageLevel, const String& message, int lineNumber, const String& sourceURL) = 0;
         virtual void postMessageToPageInspector(const String&) = 0;
diff --git a/Source/core/workers/WorkerRunLoop.cpp b/Source/core/workers/WorkerRunLoop.cpp
index 365d191..4d0c856 100644
--- a/Source/core/workers/WorkerRunLoop.cpp
+++ b/Source/core/workers/WorkerRunLoop.cpp
@@ -29,13 +29,13 @@
  */
  
 #include "config.h"
+#include "core/workers/WorkerRunLoop.h"
 
 #include "core/dom/ScriptExecutionContext.h"
 #include "core/platform/SharedTimer.h"
 #include "core/platform/ThreadGlobalData.h"
 #include "core/platform/ThreadTimers.h"
 #include "core/workers/WorkerGlobalScope.h"
-#include "core/workers/WorkerRunLoop.h"
 #include "core/workers/WorkerThread.h"
 #include <wtf/CurrentTime.h>
 
@@ -150,12 +150,31 @@
     ASSERT(context->thread()->isCurrentThread());
 
     double absoluteTime = 0.0;
-    if (waitMode == WaitForMessage)
+    bool nextTimeoutEventIsIdleWatchdog = false;
+    if (waitMode == WaitForMessage) {
         absoluteTime = (predicate.isDefaultMode() && m_sharedTimer->isActive()) ? m_sharedTimer->fireTime() : MessageQueue<Task>::infiniteTime();
+
+        // Do a script engine idle notification if the next event is distant enough.
+        const double kMinIdleTimespan = 0.3; // seconds
+        if (m_messageQueue.isEmpty() && absoluteTime > currentTime() + kMinIdleTimespan) {
+            bool hasMoreWork = !context->idleNotification();
+            if (hasMoreWork) {
+                // Schedule a watchdog, so if there are no events within a particular time interval
+                // idle notifications won't stop firing.
+                const double kWatchdogInterval = 3; // seconds
+                double nextWatchdogTime = currentTime() + kWatchdogInterval;
+                if (absoluteTime > nextWatchdogTime) {
+                    absoluteTime = nextWatchdogTime;
+                    nextTimeoutEventIsIdleWatchdog = true;
+                }
+            }
+        }
+    }
     MessageQueueWaitResult result;
     OwnPtr<WorkerRunLoop::Task> task = m_messageQueue.waitForMessageFilteredWithTimeout(result, predicate, absoluteTime);
 
-    // If the context is closing, don't execute any further JavaScript tasks (per section 4.1.1 of the Web Workers spec).  However, there may be implementation cleanup tasks in the queue, so keep running through it.
+    // If the context is closing, don't execute any further JavaScript tasks (per section 4.1.1 of the Web Workers spec).
+    // However, there may be implementation cleanup tasks in the queue, so keep running through it.
 
     switch (result) {
     case MessageQueueTerminated:
@@ -166,7 +185,7 @@
         break;
 
     case MessageQueueTimeout:
-        if (!context->isClosing())
+        if (!context->isClosing() && !nextTimeoutEventIsIdleWatchdog)
             m_sharedTimer->fire();
         break;
     }
@@ -194,9 +213,9 @@
     m_messageQueue.kill();
 }
 
-void WorkerRunLoop::postTask(PassOwnPtr<ScriptExecutionContext::Task> task)
+bool WorkerRunLoop::postTask(PassOwnPtr<ScriptExecutionContext::Task> task)
 {
-    postTaskForMode(task, defaultMode());
+    return postTaskForMode(task, defaultMode());
 }
 
 void WorkerRunLoop::postTaskAndTerminate(PassOwnPtr<ScriptExecutionContext::Task> task)
@@ -204,9 +223,9 @@
     m_messageQueue.appendAndKill(Task::create(task, defaultMode().isolatedCopy()));
 }
 
-void WorkerRunLoop::postTaskForMode(PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode)
+bool WorkerRunLoop::postTaskForMode(PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode)
 {
-    m_messageQueue.append(Task::create(task, mode.isolatedCopy()));
+    return m_messageQueue.append(Task::create(task, mode.isolatedCopy()));
 }
 
 PassOwnPtr<WorkerRunLoop::Task> WorkerRunLoop::Task::create(PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode)
diff --git a/Source/core/workers/WorkerRunLoop.h b/Source/core/workers/WorkerRunLoop.h
index 40e3e27..f0c2b20 100644
--- a/Source/core/workers/WorkerRunLoop.h
+++ b/Source/core/workers/WorkerRunLoop.h
@@ -58,9 +58,11 @@
         void terminate();
         bool terminated() const { return m_messageQueue.killed(); }
 
-        void postTask(PassOwnPtr<ScriptExecutionContext::Task>);
+        // Returns true if the loop is still alive, false if it has been terminated.
+        bool postTask(PassOwnPtr<ScriptExecutionContext::Task>);
         void postTaskAndTerminate(PassOwnPtr<ScriptExecutionContext::Task>);
-        void postTaskForMode(PassOwnPtr<ScriptExecutionContext::Task>, const String& mode);
+        // Returns true if the loop is still alive, false if it has been terminated.
+        bool postTaskForMode(PassOwnPtr<ScriptExecutionContext::Task>, const String& mode);
 
         unsigned long createUniqueId() { return ++m_uniqueId; }
 
diff --git a/Source/core/workers/WorkerThread.cpp b/Source/core/workers/WorkerThread.cpp
index d6d185b..801693c 100644
--- a/Source/core/workers/WorkerThread.cpp
+++ b/Source/core/workers/WorkerThread.cpp
@@ -29,10 +29,11 @@
 #include "core/workers/WorkerThread.h"
 
 #include "bindings/v8/ScriptSourceCode.h"
-#include "bindings/v8/ScriptValue.h"
 #include "core/inspector/InspectorInstrumentation.h"
 #include "core/platform/ThreadGlobalData.h"
 #include "core/workers/DedicatedWorkerGlobalScope.h"
+#include "core/workers/WorkerClients.h"
+#include "core/workers/WorkerThreadStartupData.h"
 #include "modules/webdatabase/DatabaseManager.h"
 #include "modules/webdatabase/DatabaseTask.h"
 #include "public/platform/Platform.h"
@@ -63,41 +64,11 @@
     return workerThreads().size();
 }
 
-struct WorkerThreadStartupData {
-    WTF_MAKE_NONCOPYABLE(WorkerThreadStartupData); WTF_MAKE_FAST_ALLOCATED;
-public:
-    static PassOwnPtr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin)
-    {
-        return adoptPtr(new WorkerThreadStartupData(scriptURL, userAgent, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin));
-    }
-
-    KURL m_scriptURL;
-    String m_userAgent;
-    String m_sourceCode;
-    WorkerThreadStartMode m_startMode;
-    String m_contentSecurityPolicy;
-    ContentSecurityPolicy::HeaderType m_contentSecurityPolicyType;
-    RefPtr<SecurityOrigin> m_topOrigin;
-private:
-    WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin);
-};
-
-WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin)
-    : m_scriptURL(scriptURL.copy())
-    , m_userAgent(userAgent.isolatedCopy())
-    , m_sourceCode(sourceCode.isolatedCopy())
-    , m_startMode(startMode)
-    , m_contentSecurityPolicy(contentSecurityPolicy.isolatedCopy())
-    , m_contentSecurityPolicyType(contentSecurityPolicyType)
-    , m_topOrigin(topOrigin ? topOrigin->isolatedCopy() : 0)
-{
-}
-
-WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin)
+WorkerThread::WorkerThread(WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, PassOwnPtr<WorkerThreadStartupData> startupData)
     : m_threadID(0)
     , m_workerLoaderProxy(workerLoaderProxy)
     , m_workerReportingProxy(workerReportingProxy)
-    , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin))
+    , m_startupData(startupData)
 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     , m_notificationClient(0)
 #endif
@@ -133,9 +104,14 @@
 
 void WorkerThread::workerThread()
 {
+    KURL scriptURL = m_startupData->m_scriptURL;
+    String sourceCode = m_startupData->m_sourceCode;
+    WorkerThreadStartMode startMode = m_startupData->m_startMode;
+
     {
         MutexLocker lock(m_threadCreationMutex);
-        m_workerGlobalScope = createWorkerGlobalScope(m_startupData->m_scriptURL, m_startupData->m_userAgent, m_startupData->m_contentSecurityPolicy, m_startupData->m_contentSecurityPolicyType, m_startupData->m_topOrigin.release());
+
+        m_workerGlobalScope = createWorkerGlobalScope(m_startupData.release());
 
         if (m_runLoop.terminated()) {
             // The worker was terminated before the thread had a chance to run. Since the context didn't exist yet,
@@ -148,12 +124,8 @@
     WebKit::Platform::current()->didStartWorkerRunLoop(WebKit::WebWorkerRunLoop(&m_runLoop));
 
     WorkerScriptController* script = m_workerGlobalScope->script();
-    InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), m_startupData->m_startMode);
-    script->evaluate(ScriptSourceCode(m_startupData->m_sourceCode, m_startupData->m_scriptURL));
-    // Free the startup data to cause its member variable deref's happen on the worker's thread (since
-    // all ref/derefs of these objects are happening on the thread at this point). Note that
-    // WorkerThread::~WorkerThread happens on a different thread where it was created.
-    m_startupData.clear();
+    InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), startMode);
+    script->evaluate(ScriptSourceCode(sourceCode, scriptURL));
 
     runEventLoop();
 
diff --git a/Source/core/workers/WorkerThread.h b/Source/core/workers/WorkerThread.h
index 92bd58a..246324c 100644
--- a/Source/core/workers/WorkerThread.h
+++ b/Source/core/workers/WorkerThread.h
@@ -68,10 +68,10 @@
 #endif
 
     protected:
-        WorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType, const SecurityOrigin* topOrigin);
+        WorkerThread(WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtr<WorkerThreadStartupData>);
 
         // Factory method for creating a new worker context for the thread.
-        virtual PassRefPtr<WorkerGlobalScope> createWorkerGlobalScope(const KURL&, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType, PassRefPtr<SecurityOrigin> topOrigin) = 0;
+        virtual PassRefPtr<WorkerGlobalScope> createWorkerGlobalScope(PassOwnPtr<WorkerThreadStartupData>) = 0;
 
         // Executes the event loop for the worker thread. Derived classes can override to perform actions before/after entering the event loop.
         virtual void runEventLoop();
@@ -102,4 +102,3 @@
 } // namespace WebCore
 
 #endif // WorkerThread_h
-
diff --git a/Source/core/workers/WorkerThreadStartupData.cpp b/Source/core/workers/WorkerThreadStartupData.cpp
new file mode 100644
index 0000000..b8ef129
--- /dev/null
+++ b/Source/core/workers/WorkerThreadStartupData.cpp
@@ -0,0 +1,55 @@
+/*
+ * 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:
+ *
+ *     * 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 "WorkerThreadStartupData.h"
+
+#include "core/workers/WorkerClients.h"
+#include "weborigin/SecurityOrigin.h"
+
+namespace WebCore {
+
+WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin, PassOwnPtr<WorkerClients> workerClients)
+    : m_scriptURL(scriptURL.copy())
+    , m_userAgent(userAgent.isolatedCopy())
+    , m_sourceCode(sourceCode.isolatedCopy())
+    , m_startMode(startMode)
+    , m_contentSecurityPolicy(contentSecurityPolicy.isolatedCopy())
+    , m_contentSecurityPolicyType(contentSecurityPolicyType)
+    , m_topOrigin(topOrigin ? topOrigin->isolatedCopy() : 0)
+    , m_workerClients(workerClients)
+{
+}
+
+WorkerThreadStartupData::~WorkerThreadStartupData()
+{
+}
+
+} // namespace WebCore
diff --git a/Source/core/workers/WorkerThreadStartupData.h b/Source/core/workers/WorkerThreadStartupData.h
new file mode 100644
index 0000000..ce1daa0
--- /dev/null
+++ b/Source/core/workers/WorkerThreadStartupData.h
@@ -0,0 +1,70 @@
+/*
+ * 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:
+ *
+ *     * 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 WorkerThreadStartupData_h
+#define WorkerThreadStartupData_h
+
+#include "core/page/ContentSecurityPolicy.h"
+#include "core/workers/WorkerClients.h"
+#include "core/workers/WorkerThread.h"
+#include "weborigin/KURL.h"
+#include "wtf/Forward.h"
+#include "wtf/Noncopyable.h"
+
+namespace WebCore {
+
+class WorkerClients;
+
+struct WorkerThreadStartupData {
+    WTF_MAKE_NONCOPYABLE(WorkerThreadStartupData); WTF_MAKE_FAST_ALLOCATED;
+public:
+    static PassOwnPtr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin, PassOwnPtr<WorkerClients> workerClients)
+    {
+        return adoptPtr(new WorkerThreadStartupData(scriptURL, userAgent, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin, workerClients));
+    }
+
+    ~WorkerThreadStartupData();
+
+    KURL m_scriptURL;
+    String m_userAgent;
+    String m_sourceCode;
+    WorkerThreadStartMode m_startMode;
+    String m_contentSecurityPolicy;
+    ContentSecurityPolicy::HeaderType m_contentSecurityPolicyType;
+    RefPtr<SecurityOrigin> m_topOrigin;
+    OwnPtr<WorkerClients> m_workerClients;
+
+private:
+    WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin, PassOwnPtr<WorkerClients>);
+};
+
+} // namespace WebCore
+
+#endif // WorkerThreadStartupData_h
diff --git a/Source/core/xml/XPathFunctions.cpp b/Source/core/xml/XPathFunctions.cpp
index 2132316..7dc106e 100644
--- a/Source/core/xml/XPathFunctions.cpp
+++ b/Source/core/xml/XPathFunctions.cpp
@@ -349,7 +349,7 @@
 
         // If there are several nodes with the same id, id() should return the first one.
         // In WebKit, getElementById behaves so, too, although its behavior in this case is formally undefined.
-        Node* node = contextScope->getElementById(idList.toStringPreserveCapacity().substring(startPos, endPos - startPos));
+        Node* node = contextScope->getElementById(idList.substring(startPos, endPos - startPos));
         if (node && resultSet.add(node).isNewEntry)
             result.append(node);
         
diff --git a/Source/core/xml/XSLTProcessor.cpp b/Source/core/xml/XSLTProcessor.cpp
index b3626f9..043fd8d 100644
--- a/Source/core/xml/XSLTProcessor.cpp
+++ b/Source/core/xml/XSLTProcessor.cpp
@@ -84,7 +84,6 @@
             result->setTransformSourceDocument(oldDocument);
             result->setSecurityOrigin(oldDocument->securityOrigin());
             result->setCookieURL(oldDocument->cookieURL());
-            result->setFirstPartyForCookies(oldDocument->firstPartyForCookies());
             result->contentSecurityPolicy()->copyStateFrom(oldDocument->contentSecurityPolicy());
         }
 
diff --git a/Source/core/xml/parser/CharacterReferenceParserInlines.h b/Source/core/xml/parser/CharacterReferenceParserInlines.h
index 3d7f765..9608be5 100644
--- a/Source/core/xml/parser/CharacterReferenceParserInlines.h
+++ b/Source/core/xml/parser/CharacterReferenceParserInlines.h
@@ -50,7 +50,7 @@
     return 0;
 }
 
-inline void unconsumeCharacters(SegmentedString& source, const StringBuilder& consumedCharacters)
+inline void unconsumeCharacters(SegmentedString& source, StringBuilder& consumedCharacters)
 {
     if (consumedCharacters.length() == 1)
         source.push(consumedCharacters[0]);
@@ -58,7 +58,7 @@
         source.push(consumedCharacters[0]);
         source.push(consumedCharacters[1]);
     } else
-        source.prepend(SegmentedString(consumedCharacters.toStringPreserveCapacity()));
+        source.prepend(SegmentedString(consumedCharacters.toString()));
 }
 
 template <typename ParserFunctions>
diff --git a/Source/core/xml/parser/XMLDocumentParser.cpp b/Source/core/xml/parser/XMLDocumentParser.cpp
index a55bd1a..fc75901 100644
--- a/Source/core/xml/parser/XMLDocumentParser.cpp
+++ b/Source/core/xml/parser/XMLDocumentParser.cpp
@@ -1438,10 +1438,9 @@
 
     XMLTreeViewer xmlTreeViewer(document());
     bool xmlViewerMode = !m_sawError && !m_sawCSS && !m_sawXSLTransform && xmlTreeViewer.hasNoStyleInformation();
-    if (xmlViewerMode)
+    if (xmlViewerMode) {
         xmlTreeViewer.transformDocumentToTreeView();
-
-    if (m_sawXSLTransform) {
+    } else if (m_sawXSLTransform) {
         xmlDocPtr doc = xmlDocPtrForString(document()->cachedResourceLoader(), m_originalSourceForTransform.toString(), document()->url().string());
         document()->setTransformSource(adoptPtr(new TransformSource(doc)));