Merge from Chromium at DEPS revision r200144

This commit was generated by merge_to_master.py.

Change-Id: I52995489013675af682cee321f417f624396b584
diff --git a/Source/core/html/BaseChooserOnlyDateAndTimeInputType.cpp b/Source/core/html/BaseChooserOnlyDateAndTimeInputType.cpp
index e164ef1..174bf3c 100644
--- a/Source/core/html/BaseChooserOnlyDateAndTimeInputType.cpp
+++ b/Source/core/html/BaseChooserOnlyDateAndTimeInputType.cpp
@@ -28,7 +28,7 @@
 #include "core/html/BaseChooserOnlyDateAndTimeInputType.h"
 
 #include "bindings/v8/ScriptController.h"
-#include "core/dom/ShadowRoot.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/HTMLDivElement.h"
 #include "core/html/HTMLInputElement.h"
 #include "core/page/Chrome.h"
diff --git a/Source/core/html/BaseMultipleFieldsDateAndTimeInputType.cpp b/Source/core/html/BaseMultipleFieldsDateAndTimeInputType.cpp
index 701fddf..8df8139 100644
--- a/Source/core/html/BaseMultipleFieldsDateAndTimeInputType.cpp
+++ b/Source/core/html/BaseMultipleFieldsDateAndTimeInputType.cpp
@@ -33,10 +33,10 @@
 #include "core/html/BaseMultipleFieldsDateAndTimeInputType.h"
 
 #include "CSSValueKeywords.h"
-#include "core/dom/ElementShadow.h"
 #include "core/dom/KeyboardEvent.h"
 #include "core/dom/NodeTraversal.h"
-#include "core/dom/ShadowRoot.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/DateTimeFieldsState.h"
 #include "core/html/FormController.h"
 #include "core/html/HTMLDataListElement.h"
diff --git a/Source/core/html/CollectionType.h b/Source/core/html/CollectionType.h
index c576c11..9db25d4 100644
--- a/Source/core/html/CollectionType.h
+++ b/Source/core/html/CollectionType.h
@@ -41,7 +41,7 @@
     DocumentNamedItems,
 
     // Unnamed HTMLCollection types cached in elements.
-    NodeChildren, // first-level children (IE)
+    NodeChildren, // first-level children (ParentNode DOM interface)
     TableTBodies, // all <tbody> elements in this table
     TSectionRows, // all row elements in this table section
     TableRows,
diff --git a/Source/core/html/ColorInputType.cpp b/Source/core/html/ColorInputType.cpp
index bffe778..7cb6070 100644
--- a/Source/core/html/ColorInputType.cpp
+++ b/Source/core/html/ColorInputType.cpp
@@ -34,9 +34,9 @@
 
 #include "CSSPropertyNames.h"
 #include "bindings/v8/ScriptController.h"
-#include "core/dom/ElementShadow.h"
 #include "core/dom/MouseEvent.h"
-#include "core/dom/ShadowRoot.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/HTMLDataListElement.h"
 #include "core/html/HTMLDivElement.h"
 #include "core/html/HTMLInputElement.h"
diff --git a/Source/core/html/DOMFormData.cpp b/Source/core/html/DOMFormData.cpp
index dbecd8b..cf4cbc4 100644
--- a/Source/core/html/DOMFormData.cpp
+++ b/Source/core/html/DOMFormData.cpp
@@ -42,11 +42,13 @@
 DOMFormData::DOMFormData(const WTF::TextEncoding& encoding)
     : FormDataList(encoding)
 {
+    ScriptWrappable::init(this);
 }
 
 DOMFormData::DOMFormData(HTMLFormElement* form)
     : FormDataList(UTF8Encoding())
 {
+    ScriptWrappable::init(this);
     if (!form)
         return;
 
diff --git a/Source/core/html/DOMFormData.h b/Source/core/html/DOMFormData.h
index fbf91e9..dfb2783 100644
--- a/Source/core/html/DOMFormData.h
+++ b/Source/core/html/DOMFormData.h
@@ -45,7 +45,7 @@
 class Blob;
 class HTMLFormElement;
 
-class DOMFormData : public FormDataList, public RefCounted<DOMFormData> {
+class DOMFormData : public FormDataList, public ScriptWrappable, public RefCounted<DOMFormData> {
 public:
     static PassRefPtr<DOMFormData> create(HTMLFormElement* form) { return adoptRef(new DOMFormData(form)); }
     static PassRefPtr<DOMFormData> create(const WTF::TextEncoding& encoding) { return adoptRef(new DOMFormData(encoding)); }
diff --git a/Source/core/html/DOMSettableTokenList.cpp b/Source/core/html/DOMSettableTokenList.cpp
index 4b34dba..a1dcafb 100644
--- a/Source/core/html/DOMSettableTokenList.cpp
+++ b/Source/core/html/DOMSettableTokenList.cpp
@@ -31,6 +31,7 @@
     : m_value()
     , m_tokens()
 {
+    ScriptWrappable::init(this);
 }
 
 DOMSettableTokenList::~DOMSettableTokenList()
diff --git a/Source/core/html/DOMTokenList.h b/Source/core/html/DOMTokenList.h
index 31fc342..400a830 100644
--- a/Source/core/html/DOMTokenList.h
+++ b/Source/core/html/DOMTokenList.h
@@ -25,8 +25,9 @@
 #ifndef DOMTokenList_h
 #define DOMTokenList_h
 
-#include <wtf/text/AtomicString.h>
-#include <wtf/Vector.h>
+#include "bindings/v8/ScriptWrappable.h"
+#include "wtf/Vector.h"
+#include "wtf/text/AtomicString.h"
 
 namespace WebCore {
 
@@ -34,10 +35,13 @@
 
 typedef int ExceptionCode;
 
-class DOMTokenList {
+class DOMTokenList : public ScriptWrappable {
     WTF_MAKE_NONCOPYABLE(DOMTokenList); WTF_MAKE_FAST_ALLOCATED;
 public:
-    DOMTokenList() { }
+    DOMTokenList()
+    {
+        ScriptWrappable::init(this);
+    }
     virtual ~DOMTokenList() {};
 
     virtual void ref() = 0;
diff --git a/Source/core/html/DOMURL.cpp b/Source/core/html/DOMURL.cpp
index 499baea..1087079 100644
--- a/Source/core/html/DOMURL.cpp
+++ b/Source/core/html/DOMURL.cpp
@@ -39,15 +39,15 @@
 #include "core/loader/cache/MemoryCache.h"
 #include "core/platform/KURL.h"
 #include "core/platform/network/ResourceRequest.h"
-#include "modules/mediasource/MediaSource.h"
 #include "modules/mediasource/MediaSourceRegistry.h"
+#include "modules/mediasource/WebKitMediaSource.h"
 #include "modules/mediastream/MediaStream.h"
 #include "modules/mediastream/MediaStreamRegistry.h"
-#include "origin/SecurityOrigin.h"
+#include "weborigin/SecurityOrigin.h"
 
 namespace WebCore {
 
-String DOMURL::createObjectURL(ScriptExecutionContext* scriptExecutionContext, MediaSource* source)
+String DOMURL::createObjectURL(ScriptExecutionContext* scriptExecutionContext, WebKitMediaSource* source)
 {
     // Since WebWorkers cannot obtain MediaSource objects, we should be on the main thread.
     ASSERT(isMainThread());
diff --git a/Source/core/html/DOMURL.h b/Source/core/html/DOMURL.h
index 8a59b24..d88bb07 100644
--- a/Source/core/html/DOMURL.h
+++ b/Source/core/html/DOMURL.h
@@ -36,7 +36,7 @@
 namespace WebCore {
 
 class Blob;
-class MediaSource;
+class WebKitMediaSource;
 class MediaStream;
 class ScriptExecutionContext;
 
@@ -49,7 +49,7 @@
 
     static String createObjectURL(ScriptExecutionContext*, Blob*);
     static void revokeObjectURL(ScriptExecutionContext*, const String&);
-    static String createObjectURL(ScriptExecutionContext*, MediaSource*);
+    static String createObjectURL(ScriptExecutionContext*, WebKitMediaSource*);
     static String createObjectURL(ScriptExecutionContext*, MediaStream*);
 };
 
diff --git a/Source/core/html/DateTimeInputType.cpp b/Source/core/html/DateTimeInputType.cpp
deleted file mode 100644
index 45e45b3..0000000
--- a/Source/core/html/DateTimeInputType.cpp
+++ /dev/null
@@ -1,184 +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.
- *     * 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"
-#if ENABLE(INPUT_TYPE_DATETIME_INCOMPLETE)
-#include "core/html/DateTimeInputType.h"
-
-#include "HTMLNames.h"
-#include "core/html/HTMLInputElement.h"
-#include "core/html/InputTypeNames.h"
-#include "core/platform/DateComponents.h"
-#include <wtf/CurrentTime.h>
-#include <wtf/PassOwnPtr.h>
-
-#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
-#include "core/html/DateTimeFieldsState.h"
-#include "core/platform/LocalizedStrings.h"
-#include "core/platform/text/PlatformLocale.h"
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/WTFString.h>
-#endif
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-static const int dateTimeDefaultStep = 60;
-static const int dateTimeDefaultStepBase = 0;
-static const int dateTimeStepScaleFactor = 1000;
-
-PassOwnPtr<InputType> DateTimeInputType::create(HTMLInputElement* element)
-{
-    return adoptPtr(new DateTimeInputType(element));
-}
-
-void DateTimeInputType::attach()
-{
-    observeFeatureIfVisible(UseCounter::InputTypeDateTime);
-}
-
-const AtomicString& DateTimeInputType::formControlType() const
-{
-    return InputTypeNames::datetime();
-}
-
-DateComponents::Type DateTimeInputType::dateType() const
-{
-    return DateComponents::DateTime;
-}
-
-Decimal DateTimeInputType::defaultValueForStepUp() const
-{
-    return Decimal::fromDouble(currentTimeMS());
-}
-
-StepRange DateTimeInputType::createStepRange(AnyStepHandling anyStepHandling) const
-{
-    DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (dateTimeDefaultStep, dateTimeDefaultStepBase, dateTimeStepScaleFactor, StepRange::ScaledStepValueShouldBeInteger));
-
-    const Decimal stepBase = parseToNumber(element()->fastGetAttribute(minAttr), 0);
-    const Decimal minimum = parseToNumber(element()->fastGetAttribute(minAttr), Decimal::fromDouble(DateComponents::minimumDateTime()));
-    const Decimal maximum = parseToNumber(element()->fastGetAttribute(maxAttr), Decimal::fromDouble(DateComponents::maximumDateTime()));
-    const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
-    return StepRange(stepBase, minimum, maximum, step, stepDescription);
-}
-
-bool DateTimeInputType::parseToDateComponentsInternal(const UChar* characters, unsigned length, DateComponents* out) const
-{
-    ASSERT(out);
-    unsigned end;
-    return out->parseDateTime(characters, length, 0, end) && end == length;
-}
-
-bool DateTimeInputType::setMillisecondToDateComponents(double value, DateComponents* date) const
-{
-    ASSERT(date);
-    return date->setMillisecondsSinceEpochForDateTime(value);
-}
-
-bool DateTimeInputType::isDateTimeField() const
-{
-    return true;
-}
-
-#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
-// FIXME: It is better to share code for DateTimeInputType::formatDateTimeFieldsState()
-// and DateTimeInputLocalType::formatDateTimeFieldsState().
-String DateTimeInputType::formatDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState) const
-{
-    if (!dateTimeFieldsState.hasDayOfMonth() || !dateTimeFieldsState.hasMonth() || !dateTimeFieldsState.hasYear()
-        || !dateTimeFieldsState.hasHour() || !dateTimeFieldsState.hasMinute() || !dateTimeFieldsState.hasAMPM())
-        return emptyString();
-
-    if (dateTimeFieldsState.hasMillisecond() && dateTimeFieldsState.millisecond()) {
-        return String::format("%04u-%02u-%02uT%02u:%02u:%02u.%03uZ",
-            dateTimeFieldsState.year(),
-            dateTimeFieldsState.month(),
-            dateTimeFieldsState.dayOfMonth(),
-            dateTimeFieldsState.hour23(),
-            dateTimeFieldsState.minute(),
-            dateTimeFieldsState.hasSecond() ? dateTimeFieldsState.second() : 0,
-            dateTimeFieldsState.millisecond());
-    }
-
-    if (dateTimeFieldsState.hasSecond() && dateTimeFieldsState.second()) {
-        return String::format("%04u-%02u-%02uT%02u:%02u:%02uZ",
-            dateTimeFieldsState.year(),
-            dateTimeFieldsState.month(),
-            dateTimeFieldsState.dayOfMonth(),
-            dateTimeFieldsState.hour23(),
-            dateTimeFieldsState.minute(),
-            dateTimeFieldsState.second());
-    }
-
-    return String::format("%04u-%02u-%02uT%02u:%02uZ",
-        dateTimeFieldsState.year(),
-        dateTimeFieldsState.month(),
-        dateTimeFieldsState.dayOfMonth(),
-        dateTimeFieldsState.hour23(),
-        dateTimeFieldsState.minute());
-}
-
-void DateTimeInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters& layoutParameters, const DateComponents& date) const
-{
-    if (shouldHaveSecondField(date)) {
-        layoutParameters.dateTimeFormat = layoutParameters.locale.dateTimeFormatWithSeconds();
-        layoutParameters.fallbackDateTimeFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'";
-    } else {
-        layoutParameters.dateTimeFormat = layoutParameters.locale.dateTimeFormatWithoutSeconds();
-        layoutParameters.fallbackDateTimeFormat = "yyyy-MM-dd'T'HH:mm'Z'";
-    }
-    if (!parseToDateComponents(element()->fastGetAttribute(minAttr), &layoutParameters.minimum))
-        layoutParameters.minimum = DateComponents();
-    if (!parseToDateComponents(element()->fastGetAttribute(maxAttr), &layoutParameters.maximum))
-        layoutParameters.maximum = DateComponents();
-    layoutParameters.placeholderForDay = placeholderForDayOfMonthField();
-    layoutParameters.placeholderForMonth = placeholderForMonthField();
-    layoutParameters.placeholderForYear = placeholderForYearField();
-}
-
-bool DateTimeInputType::isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const
-{
-    return hasYear && hasMonth && hasDay && hasAMPM && hasHour && hasMinute;
-}
-#endif
-
-String DateTimeInputType::sanitizeValue(const String& proposedValue) const
-{
-    DateComponents date;
-    if (!parseToDateComponents(proposedValue, &date))
-        return String();
-    return date.toString();
-}
-
-} // namespace WebCore
-
-#endif
diff --git a/Source/core/html/DateTimeInputType.h b/Source/core/html/DateTimeInputType.h
deleted file mode 100644
index 78c15d5..0000000
--- a/Source/core/html/DateTimeInputType.h
+++ /dev/null
@@ -1,74 +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.
- *     * 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 DateTimeInputType_h
-#define DateTimeInputType_h
-
-#if ENABLE(INPUT_TYPE_DATETIME_INCOMPLETE)
-#include "core/html/BaseChooserOnlyDateAndTimeInputType.h"
-#include "core/html/BaseDateAndTimeInputType.h"
-#include "core/html/BaseMultipleFieldsDateAndTimeInputType.h"
-
-namespace WebCore {
-
-#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
-typedef BaseMultipleFieldsDateAndTimeInputType BaseDateTimeInputType;
-#else
-typedef BaseChooserOnlyDateAndTimeInputType BaseDateTimeInputType;
-#endif
-
-class DateTimeInputType : public BaseDateTimeInputType {
-public:
-    static PassOwnPtr<InputType> create(HTMLInputElement*);
-
-private:
-    DateTimeInputType(HTMLInputElement* element) : BaseDateTimeInputType(element) { }
-    virtual void attach() OVERRIDE;
-    virtual const AtomicString& formControlType() const OVERRIDE;
-    virtual DateComponents::Type dateType() const OVERRIDE;
-    virtual StepRange createStepRange(AnyStepHandling) const OVERRIDE;
-    virtual Decimal defaultValueForStepUp() const OVERRIDE;
-    virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const OVERRIDE;
-    virtual bool setMillisecondToDateComponents(double, DateComponents*) const OVERRIDE;
-    virtual bool isDateTimeField() const OVERRIDE;
-    virtual String sanitizeValue(const String&) const OVERRIDE;
-
-#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
-    // BaseMultipleFieldsDateAndTimeInputType functions
-    virtual String formatDateTimeFieldsState(const DateTimeFieldsState&) const OVERRIDE FINAL;
-    virtual void setupLayoutParameters(DateTimeEditElement::LayoutParameters&, const DateComponents&) const OVERRIDE FINAL;
-    virtual bool isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const;
-#endif
-};
-
-} // namespace WebCore
-
-#endif
-#endif // DateTimeInputType_h
diff --git a/Source/core/html/FileInputType.cpp b/Source/core/html/FileInputType.cpp
index b61e2cb..0fbc3f9 100644
--- a/Source/core/html/FileInputType.cpp
+++ b/Source/core/html/FileInputType.cpp
@@ -24,9 +24,9 @@
 
 #include "HTMLNames.h"
 #include "bindings/v8/ScriptController.h"
-#include "core/dom/ElementShadow.h"
 #include "core/dom/Event.h"
-#include "core/dom/ShadowRoot.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/fileapi/File.h"
 #include "core/fileapi/FileList.h"
 #include "core/html/FormController.h"
diff --git a/Source/core/html/DOMFormData.idl b/Source/core/html/FormData.idl
similarity index 97%
rename from Source/core/html/DOMFormData.idl
rename to Source/core/html/FormData.idl
index 25d9ed1..1c03b25 100644
--- a/Source/core/html/DOMFormData.idl
+++ b/Source/core/html/FormData.idl
@@ -30,9 +30,9 @@
 
 [
     CustomConstructor(optional HTMLFormElement form),
-    InterfaceName=FormData,
+    ImplementedAs=DOMFormData,
     ImplementationLacksVTable
-] interface DOMFormData {
+] interface FormData {
     // void append(DOMString name, DOMString value);
     // void append(DOMString name, Blob value, optional DOMString filename);
     [Custom] void append([Default=Undefined] optional DOMString name, 
diff --git a/Source/core/html/HTMLAnchorElement.cpp b/Source/core/html/HTMLAnchorElement.cpp
index 43abdc5..ad25243 100644
--- a/Source/core/html/HTMLAnchorElement.cpp
+++ b/Source/core/html/HTMLAnchorElement.cpp
@@ -47,8 +47,9 @@
 #include "core/platform/network/DNS.h"
 #include "core/platform/network/ResourceRequest.h"
 #include "core/rendering/RenderImage.h"
-#include "origin/SecurityOrigin.h"
-#include "origin/SecurityPolicy.h"
+#include "weborigin/KnownPorts.h"
+#include "weborigin/SecurityOrigin.h"
+#include "weborigin/SecurityPolicy.h"
 
 namespace WebCore {
 
@@ -64,13 +65,19 @@
 private:
     PrefetchEventHandler();
 
+    void reset();
+
     void handleMouseOver(Event* event);
     void handleMouseOut(Event* event);
     void handleLeftMouseDown(Event* event);
+    void handleGestureTapUnconfirmed(Event*);
+    void handleGestureTapDown(Event*);
     void handleClick(Event* event);
 
     double m_mouseOverTimestamp;
     double m_mouseDownTimestamp;
+    double m_tapDownTimestamp;
+    bool m_hadTapUnconfirmed;
 };
 
 using namespace HTMLNames;
@@ -647,9 +654,16 @@
 }
 
 HTMLAnchorElement::PrefetchEventHandler::PrefetchEventHandler()
-    : m_mouseOverTimestamp(0.0)
-    , m_mouseDownTimestamp(0.0)
 {
+    reset();
+}
+
+void HTMLAnchorElement::PrefetchEventHandler::reset()
+{
+    m_mouseOverTimestamp = 0;
+    m_mouseDownTimestamp = 0;
+    m_hadTapUnconfirmed = false;
+    m_tapDownTimestamp = 0;
 }
 
 void HTMLAnchorElement::PrefetchEventHandler::handleEvent(Event* event)
@@ -660,6 +674,10 @@
         handleMouseOut(event);
     else if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton)
         handleLeftMouseDown(event);
+    else if (event->type() == eventNames().gesturetapdownEvent)
+        handleGestureTapDown(event);
+    else if (event->type() == eventNames().gesturetapunconfirmedEvent)
+        handleGestureTapUnconfirmed(event);
     else if (isLinkClick(event))
         handleClick(event);
 }
@@ -690,6 +708,20 @@
     HistogramSupport::histogramEnumeration("MouseEventPrefetch.MouseDowns", 0, 2);
 }
 
+void HTMLAnchorElement::PrefetchEventHandler::handleGestureTapUnconfirmed(Event* event)
+{
+    m_hadTapUnconfirmed = true;
+
+    HistogramSupport::histogramEnumeration("MouseEventPrefetch.TapUnconfirmeds", 0, 2);
+}
+
+void HTMLAnchorElement::PrefetchEventHandler::handleGestureTapDown(Event* event)
+{
+    m_tapDownTimestamp = event->timeStamp();
+
+    HistogramSupport::histogramEnumeration("MouseEventPrefetch.TapDowns", 0, 2);
+}
+
 void HTMLAnchorElement::PrefetchEventHandler::handleClick(Event* event)
 {
     bool capturedMouseOver = (m_mouseOverTimestamp > 0.0);
@@ -708,8 +740,17 @@
         HistogramSupport::histogramCustomCounts("MouseEventPrefetch.MouseDownDuration_Click", mouseDownDuration * 1000, 0, 10000, 100);
     }
 
-    m_mouseOverTimestamp = 0;
-    m_mouseDownTimestamp = 0;
+    bool capturedTapDown = (m_tapDownTimestamp > 0.0);
+    if (capturedTapDown) {
+        double tapDownDuration = convertDOMTimeStampToSeconds(event->timeStamp() - m_tapDownTimestamp);
+
+        HistogramSupport::histogramCustomCounts("MouseEventPrefetch.TapDownDuration_Click", tapDownDuration * 1000, 0, 10000, 100);
+    }
+
+    int flags = (m_hadTapUnconfirmed ? 2 : 0) | (capturedTapDown ? 1 : 0);
+    HistogramSupport::histogramEnumeration("MouseEventPrefetch.PreTapEventsFollowedByClick", flags, 4);
+
+    reset();
 }
 
 }
diff --git a/Source/core/html/HTMLAppletElement.cpp b/Source/core/html/HTMLAppletElement.cpp
index 4367d19..ed9e85f 100644
--- a/Source/core/html/HTMLAppletElement.cpp
+++ b/Source/core/html/HTMLAppletElement.cpp
@@ -33,7 +33,7 @@
 #include "core/page/Settings.h"
 #include "core/platform/Widget.h"
 #include "core/rendering/RenderApplet.h"
-#include "origin/SecurityOrigin.h"
+#include "weborigin/SecurityOrigin.h"
 
 namespace WebCore {
 
diff --git a/Source/core/html/HTMLDetailsElement.cpp b/Source/core/html/HTMLDetailsElement.cpp
index 2118ef9..04af44e 100644
--- a/Source/core/html/HTMLDetailsElement.cpp
+++ b/Source/core/html/HTMLDetailsElement.cpp
@@ -24,8 +24,8 @@
 #include "HTMLNames.h"
 #include "core/dom/MouseEvent.h"
 #include "core/dom/NodeRenderingContext.h"
-#include "core/dom/ShadowRoot.h"
 #include "core/dom/Text.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/HTMLSummaryElement.h"
 #include "core/html/shadow/HTMLContentElement.h"
 #include "core/platform/LocalizedStrings.h"
diff --git a/Source/core/html/HTMLDialogElement.cpp b/Source/core/html/HTMLDialogElement.cpp
index 52718b3..6533aa2 100644
--- a/Source/core/html/HTMLDialogElement.cpp
+++ b/Source/core/html/HTMLDialogElement.cpp
@@ -92,13 +92,10 @@
     // FIXME: Figure out what to do in vertical writing mode.
     FrameView* frameView = document()->view();
     int scrollTop = frameView->scrollOffset().height();
-    FloatPoint absolutePoint(0, scrollTop);
     int visibleHeight = frameView->visibleContentRect(ScrollableArea::IncludeScrollbars).height();
+    m_top = scrollTop;
     if (box->height() < visibleHeight)
-        absolutePoint.move(0, (visibleHeight - box->height()) / 2);
-    FloatPoint localPoint = box->containingBlock()->absoluteToLocal(absolutePoint);
-
-    m_top = localPoint.y();
+        m_top += (visibleHeight - box->height()) / 2;
     m_topIsValid = true;
 
     // FIXME: It's inefficient to reattach here. We could do better by mutating style directly and forcing another layout.
@@ -134,4 +131,11 @@
     return HTMLElement::isPresentationAttribute(name);
 }
 
+bool HTMLDialogElement::shouldBeReparentedUnderRenderView(const RenderStyle* style) const
+{
+    if (style && style->position() == AbsolutePosition)
+        return true;
+    return Element::shouldBeReparentedUnderRenderView(style);
+}
+
 } // namespace WebCore
diff --git a/Source/core/html/HTMLDialogElement.h b/Source/core/html/HTMLDialogElement.h
index 7cdb739..7dcbed6 100644
--- a/Source/core/html/HTMLDialogElement.h
+++ b/Source/core/html/HTMLDialogElement.h
@@ -46,6 +46,7 @@
 
     virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
     virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
+    virtual bool shouldBeReparentedUnderRenderView(const RenderStyle*) const OVERRIDE;
     void positionAndReattach();
 
     bool m_topIsValid;
diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp
index 67c66ba..080e4fd 100644
--- a/Source/core/html/HTMLElement.cpp
+++ b/Source/core/html/HTMLElement.cpp
@@ -726,12 +726,6 @@
     setAttribute(translateAttr, enable ? "yes" : "no");
 }
 
-
-PassRefPtr<HTMLCollection> HTMLElement::children()
-{
-    return ensureCachedHTMLCollection(NodeChildren);
-}
-
 bool HTMLElement::rendererIsNeeded(const NodeRenderingContext& context)
 {
     if (hasLocalName(noscriptTag)) {
diff --git a/Source/core/html/HTMLElement.h b/Source/core/html/HTMLElement.h
index 7a344d6..3f93fc2 100644
--- a/Source/core/html/HTMLElement.h
+++ b/Source/core/html/HTMLElement.h
@@ -41,8 +41,6 @@
 public:
     static PassRefPtr<HTMLElement> create(const QualifiedName& tagName, Document*);
 
-    PassRefPtr<HTMLCollection> children();
-
     virtual String title() const OVERRIDE FINAL;
 
     virtual short tabIndex() const;
diff --git a/Source/core/html/HTMLElement.idl b/Source/core/html/HTMLElement.idl
index a9de148..986942c 100644
--- a/Source/core/html/HTMLElement.idl
+++ b/Source/core/html/HTMLElement.idl
@@ -50,7 +50,6 @@
                             [Default=Undefined] optional DOMString text);
 
     [EnabledAtRuntime=imeAPI] InputMethodContext getInputContext();
-    readonly attribute HTMLCollection children;
 
              [TreatNullAs=NullString, SetterRaisesException] attribute DOMString contentEditable;
     readonly attribute boolean isContentEditable;
diff --git a/Source/core/html/HTMLFormControlElement.cpp b/Source/core/html/HTMLFormControlElement.cpp
index b121575..0520578 100644
--- a/Source/core/html/HTMLFormControlElement.cpp
+++ b/Source/core/html/HTMLFormControlElement.cpp
@@ -27,9 +27,9 @@
 
 #include "bindings/v8/ScriptEventListener.h"
 #include "core/dom/Attribute.h"
-#include "core/dom/ElementShadow.h"
 #include "core/dom/Event.h"
 #include "core/dom/EventNames.h"
+#include "core/dom/shadow/ElementShadow.h"
 #include "core/html/HTMLFieldSetElement.h"
 #include "core/html/HTMLFormElement.h"
 #include "core/html/HTMLInputElement.h"
diff --git a/Source/core/html/HTMLFormElement.idl b/Source/core/html/HTMLFormElement.idl
index fdb1468..ba2674d 100644
--- a/Source/core/html/HTMLFormElement.idl
+++ b/Source/core/html/HTMLFormElement.idl
@@ -19,7 +19,6 @@
  */
 
 [
-    CustomIndexedGetter,
     CustomNamedGetter
 ] interface HTMLFormElement : HTMLElement {
     [Reflect=accept_charset] attribute DOMString acceptCharset;
@@ -34,6 +33,7 @@
 
     readonly attribute HTMLCollection elements;
     readonly attribute long length;
+    [ImplementedAs=item] getter Node(unsigned long index);
 
     [ImplementedAs=submitFromJavaScript] void submit();
     void reset();
diff --git a/Source/core/html/HTMLInputElement.cpp b/Source/core/html/HTMLInputElement.cpp
index 9188895..315c4b9 100644
--- a/Source/core/html/HTMLInputElement.cpp
+++ b/Source/core/html/HTMLInputElement.cpp
@@ -37,15 +37,16 @@
 #include "core/css/resolver/StyleResolver.h"
 #include "core/dom/BeforeTextInsertedEvent.h"
 #include "core/dom/Document.h"
-#include "core/dom/ElementShadow.h"
 #include "core/dom/EventNames.h"
 #include "core/dom/ExceptionCode.h"
 #include "core/dom/IdTargetObserver.h"
 #include "core/dom/KeyboardEvent.h"
 #include "core/dom/MouseEvent.h"
 #include "core/dom/ScopedEventQueue.h"
-#include "core/dom/ShadowRoot.h"
 #include "core/dom/TouchEvent.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/InsertionPoint.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/editing/Editor.h"
 #include "core/editing/FrameSelection.h"
 #include "core/fileapi/FileList.h"
@@ -59,7 +60,6 @@
 #include "core/html/InputType.h"
 #include "core/html/SearchInputType.h"
 #include "core/html/parser/HTMLParserIdioms.h"
-#include "core/html/shadow/InsertionPoint.h"
 #include "core/page/Frame.h"
 #include "core/page/FrameView.h"
 #include "RuntimeEnabledFeatures.h"
@@ -1628,11 +1628,6 @@
     return m_inputType->isDateField();
 }
 
-bool HTMLInputElement::isDateTimeField() const
-{
-    return m_inputType->isDateTimeField();
-}
-
 bool HTMLInputElement::isDateTimeLocalField() const
 {
     return m_inputType->isDateTimeLocalField();
diff --git a/Source/core/html/HTMLInputElement.h b/Source/core/html/HTMLInputElement.h
index d98f710..ebc4e54 100644
--- a/Source/core/html/HTMLInputElement.h
+++ b/Source/core/html/HTMLInputElement.h
@@ -115,7 +115,6 @@
     bool isTelephoneField() const;
     bool isURLField() const;
     bool isDateField() const;
-    bool isDateTimeField() const;
     bool isDateTimeLocalField() const;
     bool isMonthField() const;
     bool isTimeField() const;
diff --git a/Source/core/html/HTMLKeygenElement.cpp b/Source/core/html/HTMLKeygenElement.cpp
index 8ffd99f..9ddd013 100644
--- a/Source/core/html/HTMLKeygenElement.cpp
+++ b/Source/core/html/HTMLKeygenElement.cpp
@@ -28,9 +28,9 @@
 #include "HTMLNames.h"
 #include "core/dom/Attribute.h"
 #include "core/dom/Document.h"
-#include "core/dom/ElementShadow.h"
-#include "core/dom/ShadowRoot.h"
 #include "core/dom/Text.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/FormDataList.h"
 #include "core/html/HTMLOptionElement.h"
 #include "core/html/HTMLSelectElement.h"
diff --git a/Source/core/html/HTMLLinkElement.cpp b/Source/core/html/HTMLLinkElement.cpp
index 0c5c868..c9844f2 100644
--- a/Source/core/html/HTMLLinkElement.cpp
+++ b/Source/core/html/HTMLLinkElement.cpp
@@ -49,7 +49,7 @@
 #include "core/page/FrameView.h"
 #include "core/page/Page.h"
 #include "core/page/Settings.h"
-#include "origin/SecurityOrigin.h"
+#include "weborigin/SecurityOrigin.h"
 
 namespace WebCore {
 
@@ -193,7 +193,14 @@
     String type = m_type.lower();
     KURL url = getNonEmptyURLAttribute(hrefAttr);
 
-    if (!m_linkLoader.loadLink(m_relAttribute, type, m_sizes->toString(), url, document()))
+    if (m_relAttribute.iconType() != InvalidIcon && url.isValid() && !url.isEmpty()) {
+        if (!shouldLoadLink())
+            return;
+        if (document()->frame())
+            document()->frame()->loader()->didChangeIcons(m_relAttribute.iconType());
+    }
+
+    if (!m_linkLoader.loadLink(m_relAttribute, type, url, document()))
         return;
 
     if ((m_disabledState != Disabled) && m_relAttribute.isStyleSheet()
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index d927d74..69884e7 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -43,15 +43,15 @@
 #include "core/dom/Attribute.h"
 #include "core/dom/ClientRect.h"
 #include "core/dom/ClientRectList.h"
-#include "core/dom/ElementShadow.h"
 #include "core/dom/Event.h"
 #include "core/dom/EventNames.h"
 #include "core/dom/ExceptionCode.h"
 #include "core/dom/ExceptionCodePlaceholder.h"
 #include "core/dom/MouseEvent.h"
 #include "core/dom/NodeRenderingContext.h"
-#include "core/dom/ShadowRoot.h"
 #include "core/dom/WebCoreMemoryInstrumentation.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/HTMLDocument.h"
 #include "core/html/HTMLSourceElement.h"
 #include "core/html/HTMLVideoElement.h"
@@ -85,11 +85,11 @@
 #include "core/rendering/RenderLayerCompositor.h"
 #include "core/rendering/RenderVideo.h"
 #include "core/rendering/RenderView.h"
-#include "modules/mediasource/MediaSource.h"
 #include "modules/mediasource/MediaSourceRegistry.h"
+#include "modules/mediasource/WebKitMediaSource.h"
 #include "modules/mediastream/MediaStreamRegistry.h"
-#include "origin/SecurityOrigin.h"
-#include "origin/SecurityPolicy.h"
+#include "weborigin/SecurityOrigin.h"
+#include "weborigin/SecurityPolicy.h"
 
 #include "RuntimeEnabledFeatures.h"
 #include "core/html/HTMLTrackElement.h"
@@ -109,10 +109,6 @@
 #include "MediaKeys.h"
 #endif
 
-#if USE(PLATFORM_TEXT_TRACK_MENU)
-#include "core/platform/graphics/PlatformTextTrack.h"
-#endif
-
 using namespace std;
 
 namespace WebCore {
@@ -296,7 +292,7 @@
     if (m_mediaController)
         m_mediaController->removeMediaElement(this);
 
-    setSourceState(MediaSource::closedKeyword());
+    closeMediaSource();
 
 #if ENABLE(ENCRYPTED_MEDIA_V2)
     setMediaKeys(0);
@@ -642,7 +638,7 @@
     if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE)
         scheduleEvent(eventNames().abortEvent);
 
-    setSourceState(MediaSource::closedKeyword());
+    closeMediaSource();
 
     createMediaPlayer();
 
@@ -1353,7 +1349,7 @@
     // 7 - Queue a task to fire a simple event named error at the media element.
     scheduleEvent(eventNames().errorEvent);
 
-    setSourceState(MediaSource::closedKeyword());
+    closeMediaSource();
 
     // 8 - Set the element's delaying-the-load-event flag to false. This stops delaying the load event.
     setShouldDelayLoadEvent(false);
@@ -1382,7 +1378,7 @@
     // 3 - Queue a task to fire a simple event named error at the media element.
     scheduleEvent(eventNames().errorEvent);
 
-    setSourceState(MediaSource::closedKeyword());
+    closeMediaSource();
 
     // 4 - Set the element's networkState attribute to the NETWORK_EMPTY value and queue a
     // task to fire a simple event called emptied at the element.
@@ -1882,7 +1878,7 @@
 
     // Always notify the media engine of a seek if the source is not closed. This ensures that the source is
     // always in a flushed state when the 'seeking' event fires.
-    if (m_mediaSource && m_mediaSource->readyState() != MediaSource::closedKeyword())
+    if (m_mediaSource && m_mediaSource->readyState() != WebKitMediaSource::closedKeyword())
         noSeekRequired = false;
 
     if (noSeekRequired) {
@@ -2245,14 +2241,13 @@
     updatePlayState();
 }
 
-void HTMLMediaElement::setSourceState(const String& state)
+void HTMLMediaElement::closeMediaSource()
 {
     if (!m_mediaSource)
-         return;
+        return;
 
-    m_mediaSource->setReadyState(state);
-    if (state == MediaSource::closedKeyword())
-        m_mediaSource = 0;
+    m_mediaSource->setReadyState(WebKitMediaSource::closedKeyword());
+    m_mediaSource = 0;
 }
 
 #if ENABLE(ENCRYPTED_MEDIA)
@@ -2588,80 +2583,10 @@
     removeTrack(textTrack.get());
 }
 
-#if USE(PLATFORM_TEXT_TRACK_MENU)
-void HTMLMediaElement::setSelectedTextTrack(PassRefPtr<PlatformTextTrack> platformTrack)
-{
-    if (!m_textTracks)
-        return;
-
-    TrackDisplayUpdateScope scope(this);
-
-    if (!platformTrack) {
-        setSelectedTextTrack(0);
-        return;
-    }
-
-    TextTrack* textTrack;
-    size_t i;
-    for (i = 0; i < m_textTracks->length(); ++i) {
-        textTrack = m_textTracks->item(i);
-
-        if (textTrack->platformTextTrack() == platformTrack)
-            break;
-    }
-
-    if (i == m_textTracks->length())
-        return;
-    setSelectedTextTrack(textTrack);
-}
-
-Vector<RefPtr<PlatformTextTrack> > HTMLMediaElement::platformTextTracks()
-{
-    if (!m_textTracks || !m_textTracks->length())
-        return Vector<RefPtr<PlatformTextTrack> >();
-
-    Vector<RefPtr<PlatformTextTrack> > platformTracks;
-    for (size_t i = 0; i < m_textTracks->length(); ++i)
-        platformTracks.append(m_textTracks->item(i)->platformTextTrack());
-
-    return platformTracks;
-}
-
-void HTMLMediaElement::notifyMediaPlayerOfTextTrackChanges()
-{
-    if (!m_textTracks || !m_textTracks->length() || !platformTextTrackMenu())
-        return;
-
-    m_platformMenu->tracksDidChange();
-}
-
-PlatformTextTrackMenuInterface* HTMLMediaElement::platformTextTrackMenu()
-{
-    if (m_platformMenu)
-        return m_platformMenu.get();
-
-    if (!m_player->implementsTextTrackControls())
-        return 0;
-
-    m_platformMenu = m_player->textTrackMenu();
-    if (!m_platformMenu)
-        return 0;
-
-    m_platformMenu->setClient(this);
-
-    return m_platformMenu.get();
-}
-#endif // #if USE(PLATFORM_TEXT_TRACK_MENU)
-
 void HTMLMediaElement::closeCaptionTracksChanged()
 {
     if (hasMediaControls())
         mediaControls()->closedCaptionTracksChanged();
-
-#if USE(PLATFORM_TEXT_TRACK_MENU)
-    if (m_player->implementsTextTrackControls())
-        scheduleDelayedAction(TextTrackChangesNotification);
-#endif
 }
 
 void HTMLMediaElement::addTrack(TextTrack* track)
@@ -3609,7 +3534,7 @@
     // 3 - Queue a task to fire a simple event named error at the media element.
     scheduleEvent(eventNames().abortEvent);
 
-    setSourceState(MediaSource::closedKeyword());
+    closeMediaSource();
 
     // 4 - If the media element's readyState attribute has a value equal to HAVE_NOTHING, set the
     // element's networkState attribute to the NETWORK_EMPTY value and queue a task to fire a
@@ -3646,7 +3571,7 @@
 
     removeAllInbandTracks();
 
-    setSourceState(MediaSource::closedKeyword());
+    closeMediaSource();
 
     m_player.clear();
     stopPeriodicTimers();
@@ -3767,11 +3692,6 @@
         mediaControls()->exitedFullscreen();
 }
 
-PlatformMedia HTMLMediaElement::platformMedia() const
-{
-    return m_player ? m_player->platformMedia() : NoPlatformMedia;
-}
-
 PlatformLayer* HTMLMediaElement::platformLayer() const
 {
     return m_player ? m_player->platformLayer() : 0;
@@ -4010,7 +3930,7 @@
 #endif
 
     if (m_mediaSource)
-        m_mediaSource->setReadyState(MediaSource::closedKeyword());
+        closeMediaSource();
 
     m_player = MediaPlayer::create(this);
 
diff --git a/Source/core/html/HTMLMediaElement.h b/Source/core/html/HTMLMediaElement.h
index eedbc78..63e122e 100644
--- a/Source/core/html/HTMLMediaElement.h
+++ b/Source/core/html/HTMLMediaElement.h
@@ -67,9 +67,6 @@
 
 class HTMLMediaElement : public HTMLElement, public MediaPlayerClient, public ActiveDOMObject, public MediaControllerInterface
     , private TextTrackClient
-#if USE(PLATFORM_TEXT_TRACK_MENU)
-    , public PlatformTextTrackMenuClient
-#endif
 {
 public:
     MediaPlayer* player() const { return m_player.get(); }
@@ -87,7 +84,6 @@
     virtual bool supportsSave() const;
     virtual bool supportsScanning() const;
     
-    PlatformMedia platformMedia() const;
     PlatformLayer* platformLayer() const;
 
     enum DelayedActionType {
@@ -157,7 +153,7 @@
     unsigned webkitVideoDecodedByteCount() const;
 
 //  Media Source.
-    void setSourceState(const String&);
+    void closeMediaSource();
 
 #if ENABLE(ENCRYPTED_MEDIA)
     void webkitGenerateKeyRequest(const String& keySystem, PassRefPtr<Uint8Array> initData, ExceptionCode&);
@@ -214,12 +210,6 @@
     virtual void mediaPlayerDidAddTrack(PassRefPtr<InbandTextTrackPrivate>) OVERRIDE;
     virtual void mediaPlayerDidRemoveTrack(PassRefPtr<InbandTextTrackPrivate>) OVERRIDE;
 
-#if USE(PLATFORM_TEXT_TRACK_MENU)
-    virtual void setSelectedTextTrack(PassRefPtr<PlatformTextTrack>) OVERRIDE;
-    virtual Vector<RefPtr<PlatformTextTrack> > platformTextTracks() OVERRIDE;
-    PlatformTextTrackMenuInterface* platformTextTrackMenu();
-#endif
-
     struct TrackGroup {
         enum GroupKind { CaptionsAndSubtitles, Description, Chapter, Metadata, Other };
 
@@ -565,7 +555,7 @@
     // calling the media engine recursively.
     int m_processingMediaPlayerCallback;
 
-    RefPtr<MediaSource> m_mediaSource;
+    RefPtr<WebKitMediaSource> m_mediaSource;
 
     mutable double m_cachedTime;
     mutable double m_cachedTimeWallClockUpdateTime;
@@ -635,10 +625,6 @@
 #if ENABLE(ENCRYPTED_MEDIA_V2)
     RefPtr<MediaKeys> m_mediaKeys;
 #endif
-
-#if USE(PLATFORM_TEXT_TRACK_MENU)
-    RefPtr<PlatformTextTrackMenuInterface> m_platformMenu;
-#endif
 };
 
 #ifndef NDEBUG
diff --git a/Source/core/html/HTMLMeterElement.cpp b/Source/core/html/HTMLMeterElement.cpp
index f9e89c4..bbdb139 100644
--- a/Source/core/html/HTMLMeterElement.cpp
+++ b/Source/core/html/HTMLMeterElement.cpp
@@ -27,7 +27,7 @@
 #include "core/dom/EventNames.h"
 #include "core/dom/ExceptionCode.h"
 #include "core/dom/NodeRenderingContext.h"
-#include "core/dom/ShadowRoot.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/FormDataList.h"
 #include "core/html/HTMLFormElement.h"
 #include "core/html/parser/HTMLParserIdioms.h"
diff --git a/Source/core/html/HTMLOptionsCollection.idl b/Source/core/html/HTMLOptionsCollection.idl
index f5ee73d..5422e0a 100644
--- a/Source/core/html/HTMLOptionsCollection.idl
+++ b/Source/core/html/HTMLOptionsCollection.idl
@@ -22,11 +22,11 @@
     CustomIndexedSetter,
     CustomNamedGetter,
     GenerateIsReachable=ImplOwnerNodeRoot,
-    CustomIndexedGetter,
     DependentLifetime,
 ] interface HTMLOptionsCollection : HTMLCollection {
     attribute long selectedIndex;
     [CustomSetter, SetterRaisesException] attribute unsigned long length;
+    [ImplementedAs=item] getter Node(unsigned long index);
 
     [Custom] Node namedItem([Default=Undefined] optional DOMString name);
 
diff --git a/Source/core/html/HTMLPlugInImageElement.cpp b/Source/core/html/HTMLPlugInImageElement.cpp
index 7ac8711..c561283 100644
--- a/Source/core/html/HTMLPlugInImageElement.cpp
+++ b/Source/core/html/HTMLPlugInImageElement.cpp
@@ -28,8 +28,8 @@
 #include "core/dom/NodeList.h"
 #include "core/dom/NodeRenderStyle.h"
 #include "core/dom/NodeRenderingContext.h"
-#include "core/dom/ShadowRoot.h"
 #include "core/dom/Text.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/HTMLDivElement.h"
 #include "core/html/HTMLImageLoader.h"
 #include "core/loader/FrameLoader.h"
@@ -39,7 +39,6 @@
 #include "core/page/Frame.h"
 #include "core/page/FrameView.h"
 #include "core/page/Page.h"
-#include "core/page/PlugInClient.h"
 #include "core/page/Settings.h"
 #include "core/platform/LocalizedStrings.h"
 #include "core/platform/Logging.h"
@@ -47,8 +46,8 @@
 #include "core/platform/graphics/Image.h"
 #include "core/rendering/RenderEmbeddedObject.h"
 #include "core/rendering/RenderImage.h"
-#include "origin/SchemeRegistry.h"
-#include "origin/SecurityOrigin.h"
+#include "weborigin/SchemeRegistry.h"
+#include "weborigin/SecurityOrigin.h"
 
 namespace WebCore {
 
diff --git a/Source/core/html/HTMLProgressElement.cpp b/Source/core/html/HTMLProgressElement.cpp
index 5f7cef6..f3325b7 100644
--- a/Source/core/html/HTMLProgressElement.cpp
+++ b/Source/core/html/HTMLProgressElement.cpp
@@ -27,7 +27,7 @@
 #include "core/dom/EventNames.h"
 #include "core/dom/ExceptionCode.h"
 #include "core/dom/NodeRenderingContext.h"
-#include "core/dom/ShadowRoot.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/HTMLDivElement.h"
 #include "core/html/parser/HTMLParserIdioms.h"
 #include "core/html/shadow/ProgressShadowElement.h"
diff --git a/Source/core/html/HTMLStyleElement.cpp b/Source/core/html/HTMLStyleElement.cpp
index 0d9a635..ab44bd8 100644
--- a/Source/core/html/HTMLStyleElement.cpp
+++ b/Source/core/html/HTMLStyleElement.cpp
@@ -34,7 +34,7 @@
 #include "core/dom/Event.h"
 #include "core/dom/EventSender.h"
 #include "core/dom/ScriptableDocumentParser.h"
-#include "core/dom/ShadowRoot.h"
+#include "core/dom/shadow/ShadowRoot.h"
 
 namespace WebCore {
 
diff --git a/Source/core/html/HTMLSummaryElement.cpp b/Source/core/html/HTMLSummaryElement.cpp
index 5f396a4..8ba9862 100644
--- a/Source/core/html/HTMLSummaryElement.cpp
+++ b/Source/core/html/HTMLSummaryElement.cpp
@@ -25,7 +25,7 @@
 #include "core/dom/KeyboardEvent.h"
 #include "core/dom/MouseEvent.h"
 #include "core/dom/NodeRenderingContext.h"
-#include "core/dom/ShadowRoot.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/HTMLDetailsElement.h"
 #include "core/html/shadow/DetailsMarkerControl.h"
 #include "core/html/shadow/HTMLContentElement.h"
diff --git a/Source/core/html/HTMLTextAreaElement.cpp b/Source/core/html/HTMLTextAreaElement.cpp
index 6b5b5f1..21ebe40 100644
--- a/Source/core/html/HTMLTextAreaElement.cpp
+++ b/Source/core/html/HTMLTextAreaElement.cpp
@@ -31,13 +31,13 @@
 #include "core/dom/Attribute.h"
 #include "core/dom/BeforeTextInsertedEvent.h"
 #include "core/dom/Document.h"
-#include "core/dom/ElementShadow.h"
 #include "core/dom/Event.h"
 #include "core/dom/EventNames.h"
 #include "core/dom/ExceptionCode.h"
 #include "core/dom/ExceptionCodePlaceholder.h"
-#include "core/dom/ShadowRoot.h"
 #include "core/dom/Text.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/editing/Editor.h"
 #include "core/editing/FrameSelection.h"
 #include "core/editing/TextIterator.h"
diff --git a/Source/core/html/InputType.cpp b/Source/core/html/InputType.cpp
index bc82ef2..95cbd12 100644
--- a/Source/core/html/InputType.cpp
+++ b/Source/core/html/InputType.cpp
@@ -32,18 +32,17 @@
 #include "HTMLNames.h"
 #include "core/accessibility/AXObjectCache.h"
 #include "core/dom/BeforeTextInsertedEvent.h"
-#include "core/dom/ElementShadow.h"
 #include "core/dom/ExceptionCode.h"
 #include "core/dom/ExceptionCodePlaceholder.h"
 #include "core/dom/KeyboardEvent.h"
 #include "core/dom/NodeRenderStyle.h"
-#include "core/dom/ShadowRoot.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/fileapi/FileList.h"
 #include "core/html/ButtonInputType.h"
 #include "core/html/CheckboxInputType.h"
 #include "core/html/ColorInputType.h"
 #include "core/html/DateInputType.h"
-#include "core/html/DateTimeInputType.h"
 #include "core/html/DateTimeLocalInputType.h"
 #include "core/html/EmailInputType.h"
 #include "core/html/FileInputType.h"
@@ -97,10 +96,6 @@
     map->add(InputTypeNames::color(), ColorInputType::create);
 #endif
     map->add(InputTypeNames::date(), DateInputType::create);
-#if ENABLE(INPUT_TYPE_DATETIME_INCOMPLETE)
-    if (RuntimeEnabledFeatures::inputTypeDateTimeEnabled())
-        map->add(InputTypeNames::datetime(), DateTimeInputType::create);
-#endif
     map->add(InputTypeNames::datetimelocal(), DateTimeLocalInputType::create);
     map->add(InputTypeNames::email(), EmailInputType::create);
     map->add(InputTypeNames::file(), FileInputType::create);
@@ -799,11 +794,6 @@
     return false;
 }
 
-bool InputType::isDateTimeField() const
-{
-    return false;
-}
-
 bool InputType::isDateTimeLocalField() const
 {
     return false;
diff --git a/Source/core/html/InputType.h b/Source/core/html/InputType.h
index 7179120..0e0347b 100644
--- a/Source/core/html/InputType.h
+++ b/Source/core/html/InputType.h
@@ -106,7 +106,6 @@
 #endif
     virtual bool isCheckbox() const;
     virtual bool isDateField() const;
-    virtual bool isDateTimeField() const;
     virtual bool isDateTimeLocalField() const;
     virtual bool isEmailField() const;
     virtual bool isFileUpload() const;
diff --git a/Source/core/html/PublicURLManager.h b/Source/core/html/PublicURLManager.h
index dfdf533..63349ab 100644
--- a/Source/core/html/PublicURLManager.h
+++ b/Source/core/html/PublicURLManager.h
@@ -33,7 +33,6 @@
 
 #include "modules/mediastream/MediaStream.h"
 #include "modules/mediastream/MediaStreamRegistry.h"
-#include "modules/mediasource/MediaSource.h"
 #include "modules/mediasource/MediaSourceRegistry.h"
 
 namespace WebCore {
diff --git a/Source/core/html/RangeInputType.cpp b/Source/core/html/RangeInputType.cpp
index 75ebd80..14032a9 100644
--- a/Source/core/html/RangeInputType.cpp
+++ b/Source/core/html/RangeInputType.cpp
@@ -35,15 +35,15 @@
 #include <limits>
 #include "HTMLNames.h"
 #include "core/accessibility/AXObjectCache.h"
-#include "core/dom/ElementShadow.h"
 #include "core/dom/ExceptionCodePlaceholder.h"
 #include "core/dom/KeyboardEvent.h"
 #include "core/dom/MouseEvent.h"
 #include "core/dom/ScopedEventQueue.h"
-#include "core/dom/ShadowRoot.h"
 #include "core/dom/Touch.h"
 #include "core/dom/TouchEvent.h"
 #include "core/dom/TouchList.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/HTMLDivElement.h"
 #include "core/html/HTMLInputElement.h"
 #include "core/html/InputTypeNames.h"
diff --git a/Source/core/html/SearchInputType.cpp b/Source/core/html/SearchInputType.cpp
index 87be461..08ad365 100644
--- a/Source/core/html/SearchInputType.cpp
+++ b/Source/core/html/SearchInputType.cpp
@@ -33,7 +33,7 @@
 
 #include "HTMLNames.h"
 #include "core/dom/KeyboardEvent.h"
-#include "core/dom/ShadowRoot.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/HTMLInputElement.h"
 #include "core/html/InputTypeNames.h"
 #include "core/html/shadow/TextControlInnerElements.h"
diff --git a/Source/core/html/TextFieldInputType.cpp b/Source/core/html/TextFieldInputType.cpp
index 60e1ec6..4bb5857 100644
--- a/Source/core/html/TextFieldInputType.cpp
+++ b/Source/core/html/TextFieldInputType.cpp
@@ -34,12 +34,12 @@
 
 #include "HTMLNames.h"
 #include "core/dom/BeforeTextInsertedEvent.h"
-#include "core/dom/ElementShadow.h"
 #include "core/dom/KeyboardEvent.h"
 #include "core/dom/NodeRenderStyle.h"
-#include "core/dom/ShadowRoot.h"
 #include "core/dom/TextEvent.h"
 #include "core/dom/WheelEvent.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/editing/Editor.h"
 #include "core/editing/FrameSelection.h"
 #include "core/editing/TextIterator.h"
diff --git a/Source/core/html/DOMURL.idl b/Source/core/html/URL.idl
similarity index 89%
rename from Source/core/html/DOMURL.idl
rename to Source/core/html/URL.idl
index c9fdd0a..399e664 100644
--- a/Source/core/html/DOMURL.idl
+++ b/Source/core/html/URL.idl
@@ -26,10 +26,10 @@
 
 [
     Constructor,
-    InterfaceName=URL,
+    ImplementedAs=DOMURL,
     ImplementationLacksVTable
-] interface DOMURL {
-    [CallWith=ScriptExecutionContext,TreatReturnedNullStringAs=Null] static DOMString createObjectURL(MediaSource? source);
+] interface URL {
+    [EnabledAtRuntime=webKitMediaSource,CallWith=ScriptExecutionContext,TreatReturnedNullStringAs=Null] static DOMString createObjectURL(WebKitMediaSource? source);
     [CallWith=ScriptExecutionContext,TreatReturnedNullStringAs=Null] static DOMString createObjectURL(MediaStream? stream);
     [CallWith=ScriptExecutionContext,TreatReturnedNullStringAs=Null] static DOMString createObjectURL(Blob? blob);
     [CallWith=ScriptExecutionContext] static void revokeObjectURL(DOMString url);
diff --git a/Source/core/html/ValidationMessage.cpp b/Source/core/html/ValidationMessage.cpp
index 5149203..22ca12d 100644
--- a/Source/core/html/ValidationMessage.cpp
+++ b/Source/core/html/ValidationMessage.cpp
@@ -35,10 +35,10 @@
 #include "CSSValueKeywords.h"
 #include "HTMLNames.h"
 #include "core/css/resolver/StyleResolver.h"
-#include "core/dom/ElementShadow.h"
 #include "core/dom/ExceptionCodePlaceholder.h"
-#include "core/dom/ShadowRoot.h"
 #include "core/dom/Text.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/HTMLBRElement.h"
 #include "core/html/HTMLDivElement.h"
 #include "core/html/HTMLFormControlElement.h"
diff --git a/Source/core/html/ValidityState.idl b/Source/core/html/ValidityState.idl
index 3e45c2c..963c830 100644
--- a/Source/core/html/ValidityState.idl
+++ b/Source/core/html/ValidityState.idl
@@ -21,7 +21,6 @@
  */
 
 [
-    NoInterfaceObject,
     ImplementationLacksVTable
 ] interface ValidityState {
     readonly attribute boolean         valueMissing;
diff --git a/Source/core/html/canvas/CanvasRenderingContext.cpp b/Source/core/html/canvas/CanvasRenderingContext.cpp
index b637639..8aac89a 100644
--- a/Source/core/html/canvas/CanvasRenderingContext.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext.cpp
@@ -32,7 +32,7 @@
 #include "core/html/canvas/CanvasPattern.h"
 #include "core/loader/cache/CachedImage.h"
 #include "core/platform/KURL.h"
-#include "origin/SecurityOrigin.h"
+#include "weborigin/SecurityOrigin.h"
 
 namespace WebCore {
 
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
index a986d81..3dd9e56 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -67,7 +67,7 @@
 #include "core/platform/graphics/transforms/AffineTransform.h"
 #include "core/rendering/RenderHTMLCanvas.h"
 #include "core/rendering/RenderLayer.h"
-#include "origin/SecurityOrigin.h"
+#include "weborigin/SecurityOrigin.h"
 
 #include <wtf/CheckedArithmetic.h>
 #include <wtf/MathExtras.h>
@@ -1031,7 +1031,7 @@
     if (shouldDrawShadows()) {
         context->save();
         saved = true;
-        context->setLegacyShadow(FloatSize(), 0, Color::transparent, ColorSpaceDeviceRGB);
+        context->clearShadow();
     }
     if (state().m_globalAlpha != 1) {
         if (!saved) {
@@ -1093,15 +1093,8 @@
 {
     if (!validateRectForCanvas(x, y, width, height))
         return;
-    strokeRect(x, y, width, height, state().m_lineWidth);
-}
 
-void CanvasRenderingContext2D::strokeRect(float x, float y, float width, float height, float lineWidth)
-{
-    if (!validateRectForCanvas(x, y, width, height))
-        return;
-
-    if (!(lineWidth >= 0))
+    if (!(state().m_lineWidth >= 0))
         return;
 
     GraphicsContext* c = drawingContext();
@@ -1118,9 +1111,9 @@
     FloatRect rect(x, y, width, height);
 
     FloatRect boundingRect = rect;
-    boundingRect.inflate(lineWidth / 2);
+    boundingRect.inflate(state().m_lineWidth / 2);
 
-    c->strokeRect(rect, lineWidth);
+    c->strokeRect(rect, state().m_lineWidth);
     didDraw(boundingRect);
 }
 
@@ -1190,12 +1183,10 @@
     if (!c)
         return;
 
-    if (shouldDrawShadows()) {
-        float width = state().m_shadowOffset.width();
-        float height = state().m_shadowOffset.height();
-        c->setLegacyShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
-    } else
-        c->setLegacyShadow(FloatSize(), 0, Color::transparent, ColorSpaceDeviceRGB);
+    if (shouldDrawShadows())
+        c->setShadow(state().m_shadowOffset, state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
+    else
+        c->clearShadow();
 }
 
 bool CanvasRenderingContext2D::shouldDrawShadows() const
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.h b/Source/core/html/canvas/CanvasRenderingContext2D.h
index cafba65..5873205 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.h
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.h
@@ -149,7 +149,6 @@
     void clearRect(float x, float y, float width, float height);
     void fillRect(float x, float y, float width, float height);
     void strokeRect(float x, float y, float width, float height);
-    void strokeRect(float x, float y, float width, float height, float lineWidth);
 
     void setShadow(float width, float height, float blur);
     void setShadow(float width, float height, float blur, const String& color);
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.idl b/Source/core/html/canvas/CanvasRenderingContext2D.idl
index 4d9e147..7e3d07f 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.idl
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.idl
@@ -65,7 +65,7 @@
 
     void beginPath();
 
-    attribute DOMPath currentPath;
+    attribute Path currentPath;
 
     // FIXME: These methods should be shared with CanvasRenderingContext2D in the CanvasPathMethods interface.
     void closePath();
@@ -115,7 +115,7 @@
     void setFillColor(float r, float g, float b, float a);
     void setFillColor(float c, float m, float y, float k, float a);
 
-    void strokeRect(float x, float y, float width, float height, optional float lineWidth);
+    void strokeRect(float x, float y, float width, float height);
 
     [RaisesException] void drawImage(HTMLImageElement? image, float x, float y);
     [RaisesException] void drawImage(HTMLImageElement? image, float x, float y, float width, float height);
diff --git a/Source/core/html/canvas/DOMPath.idl b/Source/core/html/canvas/Path.idl
similarity index 97%
rename from Source/core/html/canvas/DOMPath.idl
rename to Source/core/html/canvas/Path.idl
index 9a68c72..14ed146 100644
--- a/Source/core/html/canvas/DOMPath.idl
+++ b/Source/core/html/canvas/Path.idl
@@ -29,12 +29,12 @@
 [
     EnabledAtRuntime=canvasPath,
     Constructor,
-    Constructor(DOMPath path),
+    Constructor(Path path),
 #if defined(ENABLE_SVG) && ENABLE_SVG
     Constructor(DOMString text),
 #endif
-    InterfaceName=Path
-] interface DOMPath {
+    ImplementedAs=DOMPath
+] interface Path {
 
     // FIXME: These methods should be shared with CanvasRenderingContext2D in the CanvasPathMethods interface.
     void closePath();
diff --git a/Source/core/html/canvas/WebGLRenderingContext.cpp b/Source/core/html/canvas/WebGLRenderingContext.cpp
index d29ad0b..37deadc 100644
--- a/Source/core/html/canvas/WebGLRenderingContext.cpp
+++ b/Source/core/html/canvas/WebGLRenderingContext.cpp
@@ -450,6 +450,17 @@
             break;
         }
     }
+
+    GraphicsContext3D::Attributes adjustAttributes(const GraphicsContext3D::Attributes& attributes, Settings* settings)
+    {
+        GraphicsContext3D::Attributes adjustedAttributes = attributes;
+        if (adjustedAttributes.antialias) {
+            if (settings && !settings->openGLMultisamplingEnabled())
+                adjustedAttributes.antialias = false;
+        }
+
+        return adjustedAttributes;
+    }
 } // namespace anonymous
 
 class WebGLRenderingContextLostCallback : public GraphicsContext3D::ContextLostCallback {
@@ -491,17 +502,13 @@
         return nullptr;
     }
 
-    GraphicsContext3D::Attributes attributes = attrs ? attrs->attributes() : GraphicsContext3D::Attributes();
+    GraphicsContext3D::Attributes requestedAttributes = attrs ? attrs->attributes() : GraphicsContext3D::Attributes();
+    requestedAttributes.noExtensions = true;
+    requestedAttributes.shareResources = true;
+    requestedAttributes.preferDiscreteGPU = true;
+    requestedAttributes.topDocumentURL = document->topDocument()->url();
 
-    if (attributes.antialias) {
-        if (settings && !settings->openGLMultisamplingEnabled())
-            attributes.antialias = false;
-    }
-
-    attributes.noExtensions = true;
-    attributes.shareResources = true;
-    attributes.preferDiscreteGPU = true;
-    attributes.topDocumentURL = document->topDocument()->url();
+    GraphicsContext3D::Attributes attributes = adjustAttributes(requestedAttributes, settings);
 
     RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(attributes));
 
@@ -514,7 +521,7 @@
     if (extensions->supports("GL_EXT_debug_marker"))
         extensions->pushGroupMarkerEXT("WebGLRenderingContext");
 
-    OwnPtr<WebGLRenderingContext> renderingContext = adoptPtr(new WebGLRenderingContext(canvas, context, attributes));
+    OwnPtr<WebGLRenderingContext> renderingContext = adoptPtr(new WebGLRenderingContext(canvas, context, attributes, requestedAttributes));
     renderingContext->suspendIfNeeded();
 
     if (renderingContext->m_drawingBuffer->isZeroSized()) {
@@ -525,8 +532,7 @@
     return renderingContext.release();
 }
 
-WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, PassRefPtr<GraphicsContext3D> context,
-                                             GraphicsContext3D::Attributes attributes)
+WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, PassRefPtr<GraphicsContext3D> context, GraphicsContext3D::Attributes attributes, GraphicsContext3D::Attributes requestedAttributes)
     : CanvasRenderingContext(passedCanvas)
     , ActiveDOMObject(passedCanvas->document())
     , m_context(context)
@@ -538,8 +544,11 @@
     , m_contextLost(false)
     , m_contextLostMode(SyntheticLostContext)
     , m_attributes(attributes)
+    , m_requestedAttributes(requestedAttributes)
     , m_synthesizedErrorsToConsole(true)
     , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole)
+    , m_multisamplingAllowed(false)
+    , m_multisamplingObserverRegistered(false)
 {
     ASSERT(m_context);
     ScriptWrappable::init(this);
@@ -645,9 +654,16 @@
     ASSERT(m_context);
 
     Page* p = canvas()->document()->page();
-    if (p)
+    if (p) {
         m_synthesizedErrorsToConsole = p->settings()->webGLErrorsToConsoleEnabled();
 
+        if (!m_multisamplingObserverRegistered && m_requestedAttributes.antialias) {
+            m_multisamplingAllowed = m_drawingBuffer->multisample();
+            p->addMultisamplingChangedObserver(this);
+            m_multisamplingObserverRegistered = true;
+        }
+    }
+
     m_isGLES2NPOTStrict = !m_context->getExtensions()->isEnabled("GL_OES_texture_npot");
     m_isDepthStencilSupported = m_context->getExtensions()->isEnabled("GL_OES_packed_depth_stencil");
     m_isRobustnessEXTSupported = m_context->getExtensions()->isEnabled("GL_EXT_robustness");
@@ -691,6 +707,12 @@
     destroyGraphicsContext3D();
     m_contextGroup->removeContext(this);
 
+    if (m_multisamplingObserverRegistered) {
+        Page* page = canvas()->document()->page();
+        if (page)
+            page->removeMultisamplingChangedObserver(this);
+    }
+
     willDestroyContext(this);
 }
 
@@ -3463,6 +3485,12 @@
     // Otherwise, it will fall back to the normal SW path.
     WebGLTexture* texture = validateTextureBinding("texImage2D", target, true);
     if (GraphicsContext3D::TEXTURE_2D == target && texture) {
+        // FIXME: Currently we must make sure the target texture has the correct size before copying
+        // because of crbug.com/225781. Remove this once that bug is fixed.
+        if (texture->getWidth(target, level) != video->videoWidth() || texture->getHeight(target, level) != video->videoHeight()) {
+            m_context->texImage2D(target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, 0);
+            texture->setLevelInfo(target, level, internalformat, video->videoWidth(), video->videoHeight(), type);
+        }
         if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->object(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
             texture->setLevelInfo(target, level, internalformat, video->videoWidth(), video->videoHeight(), type);
             return;
@@ -5233,7 +5261,7 @@
     canvas()->dispatchEvent(event);
     m_restoreAllowed = event->defaultPrevented();
     deactivateContext(this, m_contextLostMode != RealLostContext && m_restoreAllowed);
-    if (m_contextLostMode == RealLostContext && m_restoreAllowed)
+    if ((m_contextLostMode == RealLostContext || m_contextLostMode == AutoRecoverSyntheticLostContext) && m_restoreAllowed)
         m_restoreTimer.startOneShot(0);
 }
 
@@ -5257,10 +5285,16 @@
     if (!frame)
         return;
 
-    if (!frame->loader()->client()->allowWebGL(frame->settings() && frame->settings()->webGLEnabled()))
+    Settings* settings = frame->settings();
+
+    if (!frame->loader()->client()->allowWebGL(settings && settings->webGLEnabled()))
         return;
 
+    // Reset the context attributes back to the requested attributes and re-apply restrictions
+    m_attributes = adjustAttributes(m_requestedAttributes, settings);
+
     RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(m_attributes));
+
     if (!context) {
         if (m_contextLostMode == RealLostContext)
             m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts);
@@ -5450,4 +5484,12 @@
     bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get(), ec);
 }
 
+void WebGLRenderingContext::multisamplingChanged(bool enabled)
+{
+    if (m_multisamplingAllowed != enabled) {
+        m_multisamplingAllowed = enabled;
+        forceLostContext(WebGLRenderingContext::AutoRecoverSyntheticLostContext);
+    }
+}
+
 } // namespace WebCore
diff --git a/Source/core/html/canvas/WebGLRenderingContext.h b/Source/core/html/canvas/WebGLRenderingContext.h
index 5314306..16c7fb7 100644
--- a/Source/core/html/canvas/WebGLRenderingContext.h
+++ b/Source/core/html/canvas/WebGLRenderingContext.h
@@ -29,6 +29,7 @@
 #include "core/dom/ActiveDOMObject.h"
 #include "core/html/canvas/CanvasRenderingContext.h"
 #include "core/html/canvas/WebGLGetInfo.h"
+#include "core/page/Page.h"
 #include "core/platform/Timer.h"
 #include "core/platform/graphics/GraphicsContext3D.h"
 #include "core/platform/graphics/ImageBuffer.h"
@@ -80,7 +81,7 @@
 
 typedef int ExceptionCode;
 
-class WebGLRenderingContext : public CanvasRenderingContext, public ActiveDOMObject {
+class WebGLRenderingContext : public CanvasRenderingContext, public ActiveDOMObject, private Page::MultisamplingChangedObserver {
 public:
     static PassOwnPtr<WebGLRenderingContext> create(HTMLCanvasElement*, WebGLContextAttributes*);
     virtual ~WebGLRenderingContext();
@@ -294,7 +295,10 @@
         RealLostContext,
 
         // Lost context provoked by WEBKIT_lose_context.
-        SyntheticLostContext
+        SyntheticLostContext,
+
+        // A synthetic lost context that should attempt to recover automatically
+        AutoRecoverSyntheticLostContext
     };
     void forceLostContext(LostContextMode);
     void forceRestoreContext();
@@ -331,7 +335,7 @@
     friend class WebGLRenderingContextErrorMessageCallback;
     friend class WebGLVertexArrayObjectOES;
 
-    WebGLRenderingContext(HTMLCanvasElement*, PassRefPtr<GraphicsContext3D>, GraphicsContext3D::Attributes);
+    WebGLRenderingContext(HTMLCanvasElement*, PassRefPtr<GraphicsContext3D>, GraphicsContext3D::Attributes, GraphicsContext3D::Attributes);
     void initializeNewContext();
     void setupFlags();
 
@@ -493,6 +497,7 @@
     bool m_contextLost;
     LostContextMode m_contextLostMode;
     GraphicsContext3D::Attributes m_attributes;
+    GraphicsContext3D::Attributes m_requestedAttributes;
 
     bool m_layerCleared;
     GC3Dfloat m_clearColor[4];
@@ -769,6 +774,10 @@
     void restoreCurrentFramebuffer();
     void restoreCurrentTexture2D();
 
+    virtual void multisamplingChanged(bool);
+    bool m_multisamplingAllowed;
+    bool m_multisamplingObserverRegistered;
+
     friend class WebGLStateRestorer;
     friend class WebGLRenderingContextEvictionManager;
 
diff --git a/Source/core/html/parser/BackgroundHTMLParser.cpp b/Source/core/html/parser/BackgroundHTMLParser.cpp
index d14adf8..dfeea54 100644
--- a/Source/core/html/parser/BackgroundHTMLParser.cpp
+++ b/Source/core/html/parser/BackgroundHTMLParser.cpp
@@ -145,7 +145,7 @@
 
     while (true) {
         m_sourceTracker.start(m_input.current(), m_tokenizer.get(), *m_token);
-        if (!m_tokenizer->nextToken(m_input.current(), *m_token.get())) {
+        if (!m_tokenizer->nextToken(m_input.current(), *m_token)) {
             // We've reached the end of our current input.
             sendTokensToMainThread();
             break;
diff --git a/Source/core/html/parser/HTMLDocumentParser.cpp b/Source/core/html/parser/HTMLDocumentParser.cpp
index 863f038..01b8b20 100644
--- a/Source/core/html/parser/HTMLDocumentParser.cpp
+++ b/Source/core/html/parser/HTMLDocumentParser.cpp
@@ -404,13 +404,6 @@
     for (Vector<CompactHTMLToken>::const_iterator it = tokens->begin(); it != tokens->end(); ++it) {
         ASSERT(!isWaitingForScripts());
 
-        m_textPosition = it->textPosition();
-
-        constructTreeFromCompactHTMLToken(*it);
-
-        if (isStopped())
-            break;
-
         if (!isParsingFragment()
             && document()->frame() && document()->frame()->navigationScheduler()->locationChangePending()) {
 
@@ -423,6 +416,13 @@
             break;
         }
 
+        m_textPosition = it->textPosition();
+
+        constructTreeFromCompactHTMLToken(*it);
+
+        if (isStopped())
+            break;
+
         if (isWaitingForScripts()) {
             ASSERT(it + 1 == tokens->end()); // The </script> is assumed to be the last token of this bunch.
             runScriptsForPausedTreeBuilder();
diff --git a/Source/core/html/parser/HTMLDocumentParser.h b/Source/core/html/parser/HTMLDocumentParser.h
index 38aa2a9..69130d5 100644
--- a/Source/core/html/parser/HTMLDocumentParser.h
+++ b/Source/core/html/parser/HTMLDocumentParser.h
@@ -170,7 +170,7 @@
     bool inPumpSession() const { return m_pumpSessionNestingLevel > 0; }
     bool shouldDelayEnd() const { return inPumpSession() || isWaitingForScripts() || isScheduledForResume() || isExecutingScript(); }
 
-    HTMLToken& token() { return *m_token.get(); }
+    HTMLToken& token() { return *m_token; }
 
     HTMLParserOptions m_options;
     HTMLInputStream m_input;
diff --git a/Source/core/html/parser/HTMLTreeBuilder.h b/Source/core/html/parser/HTMLTreeBuilder.h
index 61138ac..bb98d37 100644
--- a/Source/core/html/parser/HTMLTreeBuilder.h
+++ b/Source/core/html/parser/HTMLTreeBuilder.h
@@ -27,14 +27,10 @@
 #ifndef HTMLTreeBuilder_h
 #define HTMLTreeBuilder_h
 
-#include "core/dom/FragmentScriptingPermission.h"
 #include "core/html/parser/HTMLConstructionSite.h"
 #include "core/html/parser/HTMLElementStack.h"
-#include "core/html/parser/HTMLFormattingElementList.h"
 #include "core/html/parser/HTMLParserOptions.h"
-#include "core/html/parser/HTMLTokenizer.h"
 #include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
diff --git a/Source/core/html/parser/InputStreamPreprocessor.h b/Source/core/html/parser/InputStreamPreprocessor.h
index 0d6ee30..a35711d 100644
--- a/Source/core/html/parser/InputStreamPreprocessor.h
+++ b/Source/core/html/parser/InputStreamPreprocessor.h
@@ -53,7 +53,6 @@
     // characters in |source| (after collapsing \r\n, etc).
     ALWAYS_INLINE bool peek(SegmentedString& source)
     {
-    PeekAgain:
         m_nextInputCharacter = source.currentChar();
 
         // Every branch in this function is expensive, so we have a
@@ -65,6 +64,31 @@
             m_skipNextNewLine = false;
             return true;
         }
+        return processNextInputCharacter(source);
+    }
+
+    // Returns whether there are more characters in |source| after advancing.
+    ALWAYS_INLINE bool advance(SegmentedString& source)
+    {
+        source.advanceAndUpdateLineNumber();
+        if (source.isEmpty())
+            return false;
+        return peek(source);
+    }
+
+    bool skipNextNewLine() const { return m_skipNextNewLine; }
+
+    void reset(bool skipNextNewLine = false)
+    {
+        m_nextInputCharacter = '\0';
+        m_skipNextNewLine = skipNextNewLine;
+    }
+
+private:
+    bool processNextInputCharacter(SegmentedString& source)
+    {
+    ProcessAgain:
+        ASSERT(m_nextInputCharacter == source.currentChar());
 
         if (m_nextInputCharacter == '\n' && m_skipNextNewLine) {
             m_skipNextNewLine = false;
@@ -87,7 +111,8 @@
                     source.advancePastNonNewline();
                     if (source.isEmpty())
                         return false;
-                    goto PeekAgain;
+                    m_nextInputCharacter = source.currentChar();
+                    goto ProcessAgain;
                 }
                 m_nextInputCharacter = 0xFFFD;
             }
@@ -95,24 +120,6 @@
         return true;
     }
 
-    // Returns whether there are more characters in |source| after advancing.
-    ALWAYS_INLINE bool advance(SegmentedString& source)
-    {
-        source.advanceAndUpdateLineNumber();
-        if (source.isEmpty())
-            return false;
-        return peek(source);
-    }
-
-    bool skipNextNewLine() const { return m_skipNextNewLine; }
-
-    void reset(bool skipNextNewLine = false)
-    {
-        m_nextInputCharacter = '\0';
-        m_skipNextNewLine = skipNextNewLine;
-    }
-
-private:
     bool shouldTreatNullAsEndOfFileMarker(SegmentedString& source) const
     {
         return source.isClosed() && source.length() == 1;
diff --git a/Source/core/html/parser/XSSAuditor.cpp b/Source/core/html/parser/XSSAuditor.cpp
index c879930..86fe66a 100644
--- a/Source/core/html/parser/XSSAuditor.cpp
+++ b/Source/core/html/parser/XSSAuditor.cpp
@@ -50,7 +50,7 @@
 #include "core/platform/KURL.h"
 #include "core/platform/network/FormData.h"
 #include "core/platform/text/DecodeEscapeSequences.h"
-#include "origin/SecurityOrigin.h"
+#include "weborigin/SecurityOrigin.h"
 #include "wtf/Functional.h"
 #include "wtf/MainThread.h"
 #include "wtf/text/CString.h"
diff --git a/Source/core/html/parser/XSSAuditorDelegate.cpp b/Source/core/html/parser/XSSAuditorDelegate.cpp
index 38ec60a..8e870a9 100644
--- a/Source/core/html/parser/XSSAuditorDelegate.cpp
+++ b/Source/core/html/parser/XSSAuditorDelegate.cpp
@@ -38,7 +38,7 @@
 #include "core/page/DOMWindow.h"
 #include "core/page/Frame.h"
 #include "core/platform/network/FormData.h"
-#include "origin/SecurityOrigin.h"
+#include "weborigin/SecurityOrigin.h"
 
 namespace WebCore {
 
diff --git a/Source/core/html/shadow/ContentDistributor.cpp b/Source/core/html/shadow/ContentDistributor.cpp
deleted file mode 100644
index fac9537..0000000
--- a/Source/core/html/shadow/ContentDistributor.cpp
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * 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/html/shadow/ContentDistributor.h"
-
-#include "core/dom/ElementShadow.h"
-#include "core/dom/NodeTraversal.h"
-#include "core/dom/ShadowRoot.h"
-#include "core/html/shadow/ContentSelectorQuery.h"
-#include "core/html/shadow/HTMLContentElement.h"
-#include "core/html/shadow/HTMLShadowElement.h"
-
-
-namespace WebCore {
-
-void ContentDistribution::swap(ContentDistribution& other)
-{
-    m_nodes.swap(other.m_nodes);
-    m_indices.swap(other.m_indices);
-}
-
-void ContentDistribution::append(PassRefPtr<Node> node)
-{
-    size_t size = m_nodes.size();
-    m_indices.set(node.get(), size);
-    m_nodes.append(node);
-}
-
-size_t ContentDistribution::find(const Node* node) const
-{
-    HashMap<const Node*, size_t>::const_iterator it = m_indices.find(node);
-    if (it == m_indices.end())
-        return notFound;
-
-    return it.get()->value;
-}
-
-Node* ContentDistribution::nextTo(const Node* node) const
-{
-    size_t index = find(node);
-    if (index == notFound || index + 1 == size())
-        return 0;
-    return at(index + 1).get();
-}
-
-Node* ContentDistribution::previousTo(const Node* node) const
-{
-    size_t index = find(node);
-    if (index == notFound || !index)
-        return 0;
-    return at(index - 1).get();
-}
-
-
-ScopeContentDistribution::ScopeContentDistribution()
-    : m_insertionPointAssignedTo(0)
-    , m_numberOfShadowElementChildren(0)
-    , m_numberOfContentElementChildren(0)
-    , m_numberOfElementShadowChildren(0)
-    , m_insertionPointListIsValid(false)
-{
-}
-
-void ScopeContentDistribution::invalidateInsertionPointList()
-{
-    m_insertionPointListIsValid = false;
-    m_insertionPointList.clear();
-}
-
-const Vector<RefPtr<InsertionPoint> >& ScopeContentDistribution::ensureInsertionPointList(ShadowRoot* shadowRoot)
-{
-    if (m_insertionPointListIsValid)
-        return m_insertionPointList;
-
-    m_insertionPointListIsValid = true;
-    ASSERT(m_insertionPointList.isEmpty());
-
-    if (!hasInsertionPoint(shadowRoot))
-        return m_insertionPointList;
-
-    for (Element* element = ElementTraversal::firstWithin(shadowRoot); element; element = ElementTraversal::next(element, shadowRoot)) {
-        if (element->isInsertionPoint())
-            m_insertionPointList.append(toInsertionPoint(element));
-    }
-
-    return m_insertionPointList;
-}
-
-void ScopeContentDistribution::registerInsertionPoint(InsertionPoint* point)
-{
-    switch (point->insertionPointType()) {
-    case InsertionPoint::ShadowInsertionPoint:
-        ++m_numberOfShadowElementChildren;
-        break;
-    case InsertionPoint::ContentInsertionPoint:
-        ++m_numberOfContentElementChildren;
-        break;
-    }
-
-    invalidateInsertionPointList();
-}
-
-void ScopeContentDistribution::unregisterInsertionPoint(InsertionPoint* point)
-{
-    switch (point->insertionPointType()) {
-    case InsertionPoint::ShadowInsertionPoint:
-        ASSERT(m_numberOfShadowElementChildren > 0);
-        --m_numberOfShadowElementChildren;
-        break;
-    case InsertionPoint::ContentInsertionPoint:
-        ASSERT(m_numberOfContentElementChildren > 0);
-        --m_numberOfContentElementChildren;
-        break;
-    }
-
-    invalidateInsertionPointList();
-}
-
-bool ScopeContentDistribution::hasShadowElement(const ShadowRoot* holder)
-{
-    if (!holder->scopeDistribution())
-        return false;
-
-    return holder->scopeDistribution()->hasShadowElementChildren();
-}
-
-bool ScopeContentDistribution::hasContentElement(const ShadowRoot* holder)
-{
-    if (!holder->scopeDistribution())
-        return false;
-
-    return holder->scopeDistribution()->hasContentElementChildren();
-}
-
-unsigned ScopeContentDistribution::countElementShadow(const ShadowRoot* holder)
-{
-    if (!holder->scopeDistribution())
-        return 0;
-
-    return holder->scopeDistribution()->numberOfElementShadowChildren();
-}
-
-bool ScopeContentDistribution::hasInsertionPoint(const ShadowRoot* holder)
-{
-    return hasShadowElement(holder) || hasContentElement(holder);
-}
-
-InsertionPoint* ScopeContentDistribution::assignedTo(const ShadowRoot* holder)
-{
-    if (!holder->scopeDistribution())
-        return 0;
-
-    return holder->scopeDistribution()->insertionPointAssignedTo();
-}
-
-ContentDistributor::ContentDistributor()
-    : m_needsSelectFeatureSet(false)
-    , m_validity(Undetermined)
-{
-}
-
-ContentDistributor::~ContentDistributor()
-{
-}
-
-InsertionPoint* ContentDistributor::findInsertionPointFor(const Node* key) const
-{
-    return m_nodeToInsertionPoint.get(key);
-}
-
-void ContentDistributor::populate(Node* node, ContentDistribution& pool)
-{
-    if (!isActiveInsertionPoint(node)) {
-        pool.append(node);
-        return;
-    }
-
-    InsertionPoint* insertionPoint = toInsertionPoint(node);
-    if (insertionPoint->hasDistribution()) {
-        for (size_t i = 0; i < insertionPoint->size(); ++i)
-            populate(insertionPoint->at(i), pool);
-    } else {
-        for (Node* fallbackNode = insertionPoint->firstChild(); fallbackNode; fallbackNode = fallbackNode->nextSibling())
-            pool.append(fallbackNode);
-    }
-}
-
-void ContentDistributor::distribute(Element* host)
-{
-    ASSERT(needsDistribution());
-    ASSERT(m_nodeToInsertionPoint.isEmpty());
-    ASSERT(!host->containingShadowRoot() || host->containingShadowRoot()->owner()->distributor().isValid());
-
-    m_validity = Valid;
-
-    ContentDistribution pool;
-    for (Node* node = host->firstChild(); node; node = node->nextSibling())
-        populate(node, pool);
-
-    Vector<bool> distributed(pool.size());
-    distributed.fill(false);
-
-    Vector<HTMLShadowElement*, 8> activeShadowInsertionPoints;
-    for (ShadowRoot* root = host->youngestShadowRoot(); root; root = root->olderShadowRoot()) {
-        HTMLShadowElement* firstActiveShadowInsertionPoint = 0;
-
-        if (ScopeContentDistribution* scope = root->scopeDistribution()) {
-            const Vector<RefPtr<InsertionPoint> >& insertionPoints = scope->ensureInsertionPointList(root);
-            for (size_t i = 0; i < insertionPoints.size(); ++i) {
-                InsertionPoint* point = insertionPoints[i].get();
-                if (!point->isActive())
-                    continue;
-
-                if (isHTMLShadowElement(point)) {
-                    if (!firstActiveShadowInsertionPoint)
-                        firstActiveShadowInsertionPoint = toHTMLShadowElement(point);
-                } else {
-                    distributeSelectionsTo(point, pool, distributed);
-                    if (ElementShadow* shadow = point->parentNode()->isElementNode() ? toElement(point->parentNode())->shadow() : 0)
-                        shadow->invalidateDistribution();
-                }
-            }
-        }
-
-        if (firstActiveShadowInsertionPoint)
-            activeShadowInsertionPoints.append(firstActiveShadowInsertionPoint);
-    }
-
-    for (size_t i = activeShadowInsertionPoints.size(); i > 0; --i) {
-        HTMLShadowElement* shadowElement = activeShadowInsertionPoints[i - 1];
-        ShadowRoot* root = shadowElement->containingShadowRoot();
-        ASSERT(root);
-        if (root->olderShadowRoot()) {
-            distributeNodeChildrenTo(shadowElement, root->olderShadowRoot());
-            root->olderShadowRoot()->ensureScopeDistribution()->setInsertionPointAssignedTo(shadowElement);
-        } else {
-            distributeSelectionsTo(shadowElement, pool, distributed);
-            if (ElementShadow* shadow = shadowElement->parentNode()->isElementNode() ? toElement(shadowElement->parentNode())->shadow() : 0)
-                shadow->invalidateDistribution();
-        }
-    }
-}
-
-bool ContentDistributor::invalidate(Element* host)
-{
-    ASSERT(needsInvalidation());
-    bool needsReattach = (m_validity == Undetermined) || !m_nodeToInsertionPoint.isEmpty();
-
-    for (ShadowRoot* root = host->youngestShadowRoot(); root; root = root->olderShadowRoot()) {
-        if (ScopeContentDistribution* scope = root->scopeDistribution()) {
-            scope->setInsertionPointAssignedTo(0);
-            const Vector<RefPtr<InsertionPoint> >& insertionPoints = scope->ensureInsertionPointList(root);
-            for (size_t i = 0; i < insertionPoints.size(); ++i) {
-                needsReattach = needsReattach || true;
-                insertionPoints[i]->clearDistribution();
-
-                // After insertionPoint's distribution is invalidated, its reprojection should also be invalidated.
-                if (!insertionPoints[i]->isActive())
-                    continue;
-
-                if (Element* parent = insertionPoints[i]->parentElement()) {
-                    if (ElementShadow* shadow = parent->shadow())
-                        shadow->invalidateDistribution();
-                }
-            }
-        }
-    }
-
-    m_validity = Invalidating;
-    m_nodeToInsertionPoint.clear();
-    return needsReattach;
-}
-
-void ContentDistributor::distributeSelectionsTo(InsertionPoint* insertionPoint, const ContentDistribution& pool, Vector<bool>& distributed)
-{
-    ContentDistribution distribution;
-    ContentSelectorQuery query(insertionPoint);
-
-    for (size_t i = 0; i < pool.size(); ++i) {
-        if (distributed[i])
-            continue;
-
-        if (!query.matches(pool.nodes(), i))
-            continue;
-
-        Node* child = pool.at(i).get();
-        distribution.append(child);
-        m_nodeToInsertionPoint.add(child, insertionPoint);
-        distributed[i] = true;
-    }
-
-    insertionPoint->setDistribution(distribution);
-}
-
-void ContentDistributor::distributeNodeChildrenTo(InsertionPoint* insertionPoint, ContainerNode* containerNode)
-{
-    ContentDistribution distribution;
-    for (Node* node = containerNode->firstChild(); node; node = node->nextSibling()) {
-        if (isActiveInsertionPoint(node)) {
-            InsertionPoint* innerInsertionPoint = toInsertionPoint(node);
-            if (innerInsertionPoint->hasDistribution()) {
-                for (size_t i = 0; i < innerInsertionPoint->size(); ++i) {
-                    distribution.append(innerInsertionPoint->at(i));
-                    if (!m_nodeToInsertionPoint.contains(innerInsertionPoint->at(i)))
-                        m_nodeToInsertionPoint.add(innerInsertionPoint->at(i), insertionPoint);
-                }
-            } else {
-                for (Node* child = innerInsertionPoint->firstChild(); child; child = child->nextSibling()) {
-                    distribution.append(child);
-                    m_nodeToInsertionPoint.add(child, insertionPoint);
-                }
-            }
-        } else {
-            distribution.append(node);
-            if (!m_nodeToInsertionPoint.contains(node))
-                m_nodeToInsertionPoint.add(node, insertionPoint);
-        }
-    }
-
-    insertionPoint->setDistribution(distribution);
-}
-
-void ContentDistributor::ensureDistribution(ShadowRoot* shadowRoot)
-{
-    ASSERT(shadowRoot);
-
-    Vector<ElementShadow*, 8> elementShadows;
-    for (Element* current = shadowRoot->host(); current; current = current->shadowHost()) {
-        ElementShadow* elementShadow = current->shadow();
-        if (!elementShadow->distributor().needsDistribution())
-            break;
-
-        elementShadows.append(elementShadow);
-    }
-
-    for (size_t i = elementShadows.size(); i > 0; --i)
-        elementShadows[i - 1]->distributor().distribute(elementShadows[i - 1]->host());
-}
-
-
-void ContentDistributor::invalidateDistribution(Element* host)
-{
-    bool didNeedInvalidation = needsInvalidation();
-    bool needsReattach = didNeedInvalidation ? invalidate(host) : false;
-
-    if (needsReattach && host->attached()) {
-        for (Node* n = host->firstChild(); n; n = n->nextSibling())
-            n->lazyReattach();
-        host->setNeedsStyleRecalc();
-    }
-
-    if (didNeedInvalidation) {
-        ASSERT(m_validity == Invalidating);
-        m_validity = Invalidated;
-    }
-}
-
-const SelectRuleFeatureSet& ContentDistributor::ensureSelectFeatureSet(ElementShadow* shadow)
-{
-    if (!m_needsSelectFeatureSet)
-        return m_selectFeatures;
-
-    m_selectFeatures.clear();
-    for (ShadowRoot* root = shadow->oldestShadowRoot(); root; root = root->youngerShadowRoot())
-        collectSelectFeatureSetFrom(root);
-    m_needsSelectFeatureSet = false;
-    return m_selectFeatures;
-}
-
-void ContentDistributor::collectSelectFeatureSetFrom(ShadowRoot* root)
-{
-    if (ScopeContentDistribution::hasElementShadow(root)) {
-        for (Element* element = ElementTraversal::firstWithin(root); element; element = ElementTraversal::next(element)) {
-            if (ElementShadow* elementShadow = element->shadow())
-                m_selectFeatures.add(elementShadow->distributor().ensureSelectFeatureSet(elementShadow));
-        }
-    }
-
-    if (ScopeContentDistribution::hasContentElement(root)) {
-        for (Element* element = ElementTraversal::firstWithin(root); element; element = ElementTraversal::next(element)) {
-            if (!isHTMLContentElement(element))
-                continue;
-            const CSSSelectorList& list = toHTMLContentElement(element)->selectorList();
-            for (const CSSSelector* selector = list.first(); selector; selector = CSSSelectorList::next(selector)) {
-                for (const CSSSelector* component = selector; component; component = component->tagHistory())
-                    m_selectFeatures.collectFeaturesFromSelector(component);
-            }
-        }
-    }
-}
-
-void ContentDistributor::didAffectSelector(Element* host, AffectedSelectorMask mask)
-{
-    if (ensureSelectFeatureSet(host->shadow()).hasSelectorFor(mask))
-        invalidateDistribution(host);
-}
-
-void ContentDistributor::willAffectSelector(Element* host)
-{
-    for (ElementShadow* shadow = host->shadow(); shadow; shadow = shadow->containingShadow()) {
-        if (shadow->distributor().needsSelectFeatureSet())
-            break;
-        shadow->distributor().setNeedsSelectFeatureSet();
-    }
-
-    invalidateDistribution(host);
-}
-
-void ContentDistributor::didShadowBoundaryChange(Element* host)
-{
-    setValidity(Undetermined);
-    invalidateDistribution(host);
-}
-
-}
diff --git a/Source/core/html/shadow/ContentDistributor.h b/Source/core/html/shadow/ContentDistributor.h
deleted file mode 100644
index 1d3e657..0000000
--- a/Source/core/html/shadow/ContentDistributor.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ContentDistributor_h
-#define ContentDistributor_h
-
-#include "core/html/shadow/SelectRuleFeatureSet.h"
-#include <wtf/Forward.h>
-#include <wtf/HashMap.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class ContainerNode;
-class Element;
-class InsertionPoint;
-class Node;
-class ShadowRoot;
-
-class ContentDistribution {
-public:
-    PassRefPtr<Node> first() const { return m_nodes.first(); }
-    PassRefPtr<Node> last() const { return m_nodes.last(); }
-    PassRefPtr<Node> at(size_t index) const { return m_nodes.at(index); }
-
-    size_t size() const { return m_nodes.size(); }
-    bool isEmpty() const { return m_nodes.isEmpty(); }
-
-    void append(PassRefPtr<Node>);
-    void clear() { m_nodes.clear(); m_indices.clear(); }
-
-    bool contains(const Node* node) const { return m_indices.contains(node); }
-    size_t find(const Node*) const;
-    Node* nextTo(const Node*) const;
-    Node* previousTo(const Node*) const;
-
-    void swap(ContentDistribution& other);
-
-    const Vector<RefPtr<Node> >& nodes() const { return m_nodes; }
-
-private:
-    Vector<RefPtr<Node> > m_nodes;
-    HashMap<const Node*, size_t> m_indices;
-};
-
-class ScopeContentDistribution {
-public:
-    ScopeContentDistribution();
-
-    InsertionPoint* insertionPointAssignedTo() const { return m_insertionPointAssignedTo; }
-    void setInsertionPointAssignedTo(InsertionPoint* insertionPoint) { m_insertionPointAssignedTo = insertionPoint; }
-
-    void registerInsertionPoint(InsertionPoint*);
-    void unregisterInsertionPoint(InsertionPoint*);
-    bool hasShadowElementChildren() const { return m_numberOfShadowElementChildren > 0; }
-    bool hasContentElementChildren() const { return m_numberOfContentElementChildren > 0; }
-
-    void registerElementShadow() { ++m_numberOfElementShadowChildren; }
-    void unregisterElementShadow() { ASSERT(m_numberOfElementShadowChildren > 0); --m_numberOfElementShadowChildren; }
-    unsigned numberOfElementShadowChildren() const { return m_numberOfElementShadowChildren; }
-    bool hasElementShadowChildren() const { return m_numberOfElementShadowChildren > 0; }
-
-    void invalidateInsertionPointList();
-    const Vector<RefPtr<InsertionPoint> >& ensureInsertionPointList(ShadowRoot*);
-
-    bool isUsedForRendering() const;
-
-    static bool hasShadowElement(const ShadowRoot*);
-    static bool hasContentElement(const ShadowRoot*);
-    static bool hasInsertionPoint(const ShadowRoot*);
-    static bool hasElementShadow(const ShadowRoot* holder) { return countElementShadow(holder); }
-    static unsigned countElementShadow(const ShadowRoot*);
-    static InsertionPoint* assignedTo(const ShadowRoot*);
-
-private:
-    InsertionPoint* m_insertionPointAssignedTo;
-    unsigned m_numberOfShadowElementChildren;
-    unsigned m_numberOfContentElementChildren;
-    unsigned m_numberOfElementShadowChildren;
-    bool m_insertionPointListIsValid;
-    Vector<RefPtr<InsertionPoint> > m_insertionPointList;
-};
-
-class ContentDistributor {
-    WTF_MAKE_NONCOPYABLE(ContentDistributor);
-public:
-    enum Validity {
-        Valid = 0,
-        Invalidated = 1,
-        Invalidating = 2,
-        Undetermined = 3
-    };
-
-    ContentDistributor();
-    ~ContentDistributor();
-
-    InsertionPoint* findInsertionPointFor(const Node* key) const;
-    const SelectRuleFeatureSet& ensureSelectFeatureSet(ElementShadow*);
-
-    void distributeSelectionsTo(InsertionPoint*, const ContentDistribution& pool, Vector<bool>& distributed);
-    void distributeNodeChildrenTo(InsertionPoint*, ContainerNode*);
-
-    void invalidateDistribution(Element* host);
-    void didShadowBoundaryChange(Element* host);
-    void didAffectSelector(Element* host, AffectedSelectorMask);
-    void willAffectSelector(Element* host);
-
-    static void ensureDistribution(ShadowRoot*);
-
-private:
-    void distribute(Element* host);
-    bool invalidate(Element* host);
-    void populate(Node*, ContentDistribution&);
-
-    void collectSelectFeatureSetFrom(ShadowRoot*);
-    bool needsSelectFeatureSet() const { return m_needsSelectFeatureSet; }
-    void setNeedsSelectFeatureSet() { m_needsSelectFeatureSet = true; }
-
-    void setValidity(Validity validity) { m_validity = validity; }
-    bool isValid() const { return m_validity == Valid; }
-    bool needsDistribution() const;
-    bool needsInvalidation() const { return m_validity != Invalidated; }
-
-    HashMap<const Node*, RefPtr<InsertionPoint> > m_nodeToInsertionPoint;
-    SelectRuleFeatureSet m_selectFeatures;
-    bool m_needsSelectFeatureSet : 1;
-    unsigned m_validity : 2;
-};
-
-inline bool ContentDistributor::needsDistribution() const
-{
-    // During the invalidation, re-distribution should be supressed.
-    return m_validity != Valid && m_validity != Invalidating;
-}
-
-}
-
-#endif
diff --git a/Source/core/html/shadow/ContentSelectorQuery.cpp b/Source/core/html/shadow/ContentSelectorQuery.cpp
deleted file mode 100644
index 418e159..0000000
--- a/Source/core/html/shadow/ContentSelectorQuery.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * 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/html/shadow/ContentSelectorQuery.h"
-
-#include "core/css/CSSSelectorList.h"
-#include "core/css/SelectorChecker.h"
-#include "core/css/SiblingTraversalStrategies.h"
-#include "core/dom/ShadowRoot.h"
-#include "core/html/shadow/InsertionPoint.h"
-
-namespace WebCore {
-
-bool ContentSelectorDataList::checkContentSelector(const CSSSelector* selector, const Vector<RefPtr<Node> >& siblings, int nth)
-{
-    Element* element = toElement(siblings[nth].get());
-    SelectorChecker selectorChecker(element->document(), SelectorChecker::CollectingRules);
-    SelectorChecker::SelectorCheckingContext context(selector, element, SelectorChecker::VisitedMatchEnabled);
-    ShadowDOMSiblingTraversalStrategy strategy(siblings, nth);
-    PseudoId ignoreDynamicPseudo = NOPSEUDO;
-    return selectorChecker.match(context, ignoreDynamicPseudo, strategy) == SelectorChecker::SelectorMatches;
-}
-
-void ContentSelectorDataList::initialize(const CSSSelectorList& selectors)
-{
-    for (const CSSSelector* selector = selectors.first(); selector; selector = CSSSelectorList::next(selector))
-        m_selectors.append(selector);
-}
-
-bool ContentSelectorDataList::matches(const Vector<RefPtr<Node> >& siblings, int nth) const
-{
-    unsigned selectorCount = m_selectors.size();
-    for (unsigned i = 0; i < selectorCount; ++i) {
-        if (checkContentSelector(m_selectors[i], siblings, nth))
-            return true;
-    }
-    return false;
-}
-
-ContentSelectorQuery::ContentSelectorQuery(InsertionPoint* insertionPoint)
-    : m_insertionPoint(insertionPoint)
-{
-    m_selectors.initialize(insertionPoint->selectorList());
-}
-
-bool ContentSelectorQuery::matches(const Vector<RefPtr<Node> >& siblings, int nth) const
-{
-    Node* node = siblings[nth].get();
-    ASSERT(node);
-
-    switch (m_insertionPoint->matchTypeFor(node)) {
-    case InsertionPoint::AlwaysMatches:
-        return true;
-    case InsertionPoint::NeverMatches:
-        return false;
-    case InsertionPoint::HasToMatchSelector:
-        return node->isElementNode() && m_selectors.matches(siblings, nth);
-    default:
-        ASSERT_NOT_REACHED();
-        return false;
-    }
-}
-
-}
diff --git a/Source/core/html/shadow/ContentSelectorQuery.h b/Source/core/html/shadow/ContentSelectorQuery.h
deleted file mode 100644
index b86098d..0000000
--- a/Source/core/html/shadow/ContentSelectorQuery.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ContentSelectorQuery_h
-#define ContentSelectorQuery_h
-
-#include "core/css/CSSSelectorList.h"
-#include "core/css/SelectorChecker.h"
-#include "core/dom/SelectorQuery.h"
-#include <wtf/Forward.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class Document;
-class Node;
-class InsertionPoint;
-
-class ContentSelectorDataList {
-public:
-    void initialize(const CSSSelectorList&);
-    bool matches(const Vector<RefPtr<Node> >& siblings, int nthNode) const;
-
-private:
-    static bool checkContentSelector(const CSSSelector*, const Vector<RefPtr<Node> >& siblings, int nthNode);
-
-    Vector<const CSSSelector*> m_selectors;
-};
-
-class ContentSelectorQuery {
-    WTF_MAKE_NONCOPYABLE(ContentSelectorQuery);
-public:
-    explicit ContentSelectorQuery(InsertionPoint*);
-
-    bool matches(const Vector<RefPtr<Node> >& siblings, int nthNode) const;
-
-private:
-    InsertionPoint* m_insertionPoint;
-    ContentSelectorDataList m_selectors;
-};
-
-}
-
-#endif
diff --git a/Source/core/html/shadow/DateTimeEditElement.cpp b/Source/core/html/shadow/DateTimeEditElement.cpp
index 678f58e..f17244d 100644
--- a/Source/core/html/shadow/DateTimeEditElement.cpp
+++ b/Source/core/html/shadow/DateTimeEditElement.cpp
@@ -94,9 +94,7 @@
     , m_secondRange(0, 59)
     , m_millisecondRange(0, 999)
 {
-    if (m_dateValue.type() == DateComponents::Date
-        || m_dateValue.type() == DateComponents::DateTimeLocal
-        || m_dateValue.type() == DateComponents::DateTime) {
+    if (m_dateValue.type() == DateComponents::Date || m_dateValue.type() == DateComponents::DateTimeLocal) {
         if (m_parameters.minimum.type() != DateComponents::Invalid
             && m_parameters.maximum.type() != DateComponents::Invalid
             && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear()
@@ -352,7 +350,7 @@
 
     if (m_dateValue.type() == DateComponents::Time)
         return false;
-    ASSERT(m_dateValue.type() == DateComponents::DateTimeLocal || m_dateValue.type() == DateComponents::DateTime);
+    ASSERT(m_dateValue.type() == DateComponents::DateTimeLocal);
 
     if (shouldDayOfMonthFieldDisabled()) {
         ASSERT(m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear());
diff --git a/Source/core/html/shadow/DateTimeFieldElement.cpp b/Source/core/html/shadow/DateTimeFieldElement.cpp
index 46e0868..16abc5e 100644
--- a/Source/core/html/shadow/DateTimeFieldElement.cpp
+++ b/Source/core/html/shadow/DateTimeFieldElement.cpp
@@ -224,7 +224,7 @@
     if (textNode->wholeText() == newVisibleValue)
         return;
 
-    textNode->replaceWholeText(newVisibleValue, ASSERT_NO_EXCEPTION);
+    textNode->replaceWholeText(newVisibleValue);
     if (hasValue()) {
         setAttribute(aria_valuetextAttr, newVisibleValue);
         setAttribute(aria_valuenowAttr, String::number(valueForARIAValueNow()));
diff --git a/Source/core/html/shadow/HTMLContentElement.cpp b/Source/core/html/shadow/HTMLContentElement.cpp
index 90c50eb..79cf9ef 100644
--- a/Source/core/html/shadow/HTMLContentElement.cpp
+++ b/Source/core/html/shadow/HTMLContentElement.cpp
@@ -28,12 +28,12 @@
 #include "core/html/shadow/HTMLContentElement.h"
 
 #include "HTMLNames.h"
+#include "RuntimeEnabledFeatures.h"
 #include "core/css/CSSParser.h"
 #include "core/dom/QualifiedName.h"
-#include "core/dom/ShadowRoot.h"
-#include "core/html/shadow/ContentDistributor.h"
-#include "core/html/shadow/ContentSelectorQuery.h"
-#include "RuntimeEnabledFeatures.h"
+#include "core/dom/shadow/ContentDistributor.h"
+#include "core/dom/shadow/ContentSelectorQuery.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include <wtf/StdLibExtras.h>
 
 namespace WebCore {
diff --git a/Source/core/html/shadow/HTMLContentElement.h b/Source/core/html/shadow/HTMLContentElement.h
index a03e00b..6f30076 100644
--- a/Source/core/html/shadow/HTMLContentElement.h
+++ b/Source/core/html/shadow/HTMLContentElement.h
@@ -32,7 +32,7 @@
 #define HTMLContentElement_h
 
 #include "core/css/CSSSelectorList.h"
-#include "core/html/shadow/InsertionPoint.h"
+#include "core/dom/shadow/InsertionPoint.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
diff --git a/Source/core/html/shadow/HTMLShadowElement.cpp b/Source/core/html/shadow/HTMLShadowElement.cpp
index ad304ea..7c1383f 100644
--- a/Source/core/html/shadow/HTMLShadowElement.cpp
+++ b/Source/core/html/shadow/HTMLShadowElement.cpp
@@ -32,7 +32,7 @@
 #include "core/html/shadow/HTMLShadowElement.h"
 
 #include "HTMLNames.h"
-#include "core/dom/ShadowRoot.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include <wtf/text/AtomicString.h>
 
 namespace WebCore {
diff --git a/Source/core/html/shadow/HTMLShadowElement.h b/Source/core/html/shadow/HTMLShadowElement.h
index 4ea0b66..20fd615 100644
--- a/Source/core/html/shadow/HTMLShadowElement.h
+++ b/Source/core/html/shadow/HTMLShadowElement.h
@@ -31,7 +31,7 @@
 #ifndef HTMLShadowElement_h
 #define HTMLShadowElement_h
 
-#include "core/html/shadow/InsertionPoint.h"
+#include "core/dom/shadow/InsertionPoint.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
diff --git a/Source/core/html/shadow/InsertionPoint.cpp b/Source/core/html/shadow/InsertionPoint.cpp
deleted file mode 100644
index b3608d6..0000000
--- a/Source/core/html/shadow/InsertionPoint.cpp
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * 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/html/shadow/InsertionPoint.h"
-
-#include "HTMLNames.h"
-#include "core/dom/ElementShadow.h"
-#include "core/dom/QualifiedName.h"
-#include "core/dom/ShadowRoot.h"
-#include "core/dom/StaticNodeList.h"
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document* document)
-    : HTMLElement(tagName, document, CreateInsertionPoint)
-    , m_registeredWithShadowRoot(false)
-{
-}
-
-InsertionPoint::~InsertionPoint()
-{
-}
-
-void InsertionPoint::attach()
-{
-    if (ShadowRoot* shadowRoot = containingShadowRoot())
-        ContentDistributor::ensureDistribution(shadowRoot);
-    for (size_t i = 0; i < m_distribution.size(); ++i) {
-        if (!m_distribution.at(i)->attached())
-            m_distribution.at(i)->attach();
-    }
-
-    HTMLElement::attach();
-}
-
-void InsertionPoint::detach()
-{
-    if (ShadowRoot* shadowRoot = containingShadowRoot())
-        ContentDistributor::ensureDistribution(shadowRoot);
-
-    for (size_t i = 0; i < m_distribution.size(); ++i)
-        m_distribution.at(i)->detach();
-
-    HTMLElement::detach();
-}
-
-bool InsertionPoint::shouldUseFallbackElements() const
-{
-    return isActive() && !hasDistribution();
-}
-
-bool InsertionPoint::isShadowBoundary() const
-{
-    return treeScope()->rootNode()->isShadowRoot() && isActive();
-}
-
-bool InsertionPoint::isActive() const
-{
-    if (!containingShadowRoot())
-        return false;
-    const Node* node = parentNode();
-    while (node) {
-        if (node->isInsertionPoint())
-            return false;
-
-        node = node->parentNode();
-    }
-    return true;
-}
-
-PassRefPtr<NodeList> InsertionPoint::getDistributedNodes() const
-{
-    if (ShadowRoot* shadowRoot = containingShadowRoot())
-        ContentDistributor::ensureDistribution(shadowRoot);
-
-    Vector<RefPtr<Node> > nodes;
-
-    for (size_t i = 0; i < m_distribution.size(); ++i)
-        nodes.append(m_distribution.at(i));
-
-    return StaticNodeList::adopt(nodes);
-}
-
-bool InsertionPoint::rendererIsNeeded(const NodeRenderingContext& context)
-{
-    return !isShadowBoundary() && HTMLElement::rendererIsNeeded(context);
-}
-
-void InsertionPoint::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
-{
-    HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
-    if (ShadowRoot* root = containingShadowRoot())
-        if (ElementShadow* rootOwner = root->owner())
-            rootOwner->invalidateDistribution();
-}
-
-Node::InsertionNotificationRequest InsertionPoint::insertedInto(ContainerNode* insertionPoint)
-{
-    HTMLElement::insertedInto(insertionPoint);
-
-    if (ShadowRoot* root = containingShadowRoot()) {
-        if (ElementShadow* rootOwner = root->owner()) {
-            rootOwner->distributor().didShadowBoundaryChange(root->host());
-            if (isActive() && !m_registeredWithShadowRoot && insertionPoint->treeScope()->rootNode() == root) {
-                m_registeredWithShadowRoot = true;
-                root->ensureScopeDistribution()->registerInsertionPoint(this);
-                if (canAffectSelector())
-                    rootOwner->willAffectSelector();
-            }
-        }
-    }
-
-    return InsertionDone;
-}
-
-void InsertionPoint::removedFrom(ContainerNode* insertionPoint)
-{
-    ShadowRoot* root = containingShadowRoot();
-    if (!root)
-        root = insertionPoint->containingShadowRoot();
-
-    // host can be null when removedFrom() is called from ElementShadow destructor.
-    ElementShadow* rootOwner = root ? root->owner() : 0;
-    if (rootOwner)
-        rootOwner->invalidateDistribution();
-
-    // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up.
-    clearDistribution();
-
-    if (m_registeredWithShadowRoot && insertionPoint->treeScope()->rootNode() == root) {
-        ASSERT(root);
-        m_registeredWithShadowRoot = false;
-        root->ensureScopeDistribution()->unregisterInsertionPoint(this);
-        if (rootOwner && canAffectSelector())
-            rootOwner->willAffectSelector();
-    }
-
-    HTMLElement::removedFrom(insertionPoint);
-}
-
-void InsertionPoint::parseAttribute(const QualifiedName& name, const AtomicString& value)
-{
-    if (name == reset_style_inheritanceAttr) {
-        if (!inDocument() || !attached() || !isActive())
-            return;
-        containingShadowRoot()->host()->setNeedsStyleRecalc();
-    } else
-        HTMLElement::parseAttribute(name, value);
-}
-
-bool InsertionPoint::resetStyleInheritance() const
-{
-    return fastHasAttribute(reset_style_inheritanceAttr);
-}
-
-void InsertionPoint::setResetStyleInheritance(bool value)
-{
-    setBooleanAttribute(reset_style_inheritanceAttr, value);
-}
-
-bool InsertionPoint::contains(const Node* node) const
-{
-    return m_distribution.contains(const_cast<Node*>(node)) || (node->isShadowRoot() && ScopeContentDistribution::assignedTo(toShadowRoot(node)) == this);
-}
-
-const CSSSelectorList& InsertionPoint::emptySelectorList()
-{
-    DEFINE_STATIC_LOCAL(CSSSelectorList, selectorList, (CSSSelectorList()));
-    return selectorList;
-}
-
-InsertionPoint* resolveReprojection(const Node* projectedNode)
-{
-    InsertionPoint* insertionPoint = 0;
-    const Node* current = projectedNode;
-
-    while (current) {
-        if (ElementShadow* shadow = shadowOfParentForDistribution(current)) {
-            if (ShadowRoot* root = current->containingShadowRoot())
-                ContentDistributor::ensureDistribution(root);
-            if (InsertionPoint* insertedTo = shadow->distributor().findInsertionPointFor(projectedNode)) {
-                current = insertedTo;
-                insertionPoint = insertedTo;
-                continue;
-            }
-        }
-
-        if (Node* parent = parentNodeForDistribution(current)) {
-            if (InsertionPoint* insertedTo = parent->isShadowRoot() ? ScopeContentDistribution::assignedTo(toShadowRoot(parent)) : 0) {
-                current = insertedTo;
-                insertionPoint = insertedTo;
-                continue;
-            }
-        }
-
-        break;
-    }
-
-    return insertionPoint;
-}
-
-void collectInsertionPointsWhereNodeIsDistributed(const Node* node, Vector<InsertionPoint*, 8>& results)
-{
-    const Node* current = node;
-    while (true) {
-        if (ElementShadow* shadow = shadowOfParentForDistribution(current)) {
-            if (ShadowRoot* root = current->containingShadowRoot())
-                ContentDistributor::ensureDistribution(root);
-            if (InsertionPoint* insertedTo = shadow->distributor().findInsertionPointFor(node)) {
-                current = insertedTo;
-                results.append(insertedTo);
-                continue;
-            }
-        }
-        if (Node* parent = parentNodeForDistribution(current)) {
-            if (InsertionPoint* insertedTo = parent->isShadowRoot() ? ScopeContentDistribution::assignedTo(toShadowRoot(parent)) : 0) {
-                current = insertedTo;
-                results.append(insertedTo);
-                continue;
-            }
-        }
-        return;
-    }
-}
-
-} // namespace WebCore
diff --git a/Source/core/html/shadow/InsertionPoint.h b/Source/core/html/shadow/InsertionPoint.h
deleted file mode 100644
index 587ef2e..0000000
--- a/Source/core/html/shadow/InsertionPoint.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * 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 InsertionPoint_h
-#define InsertionPoint_h
-
-#include "HTMLNames.h"
-#include "core/css/CSSSelectorList.h"
-#include "core/dom/ElementShadow.h"
-#include "core/dom/ShadowRoot.h"
-#include "core/html/HTMLElement.h"
-#include "core/html/shadow/ContentDistributor.h"
-#include <wtf/Forward.h>
-
-namespace WebCore {
-
-class InsertionPoint : public HTMLElement {
-public:
-    enum Type {
-        ShadowInsertionPoint,
-        ContentInsertionPoint
-    };
-
-    enum MatchType {
-        AlwaysMatches,
-        NeverMatches,
-        HasToMatchSelector
-    };
-
-    virtual ~InsertionPoint();
-
-    bool hasDistribution() const { return !m_distribution.isEmpty(); }
-    void setDistribution(ContentDistribution& distribution) { m_distribution.swap(distribution); }
-    void clearDistribution() { m_distribution.clear(); }
-    bool isShadowBoundary() const;
-    bool isActive() const;
-
-    PassRefPtr<NodeList> getDistributedNodes() const;
-
-    virtual MatchType matchTypeFor(Node*) { return AlwaysMatches; }
-    virtual const CSSSelectorList& selectorList() { return emptySelectorList(); }
-    virtual Type insertionPointType() const = 0;
-    virtual bool canAffectSelector() const { return false; }
-
-    bool resetStyleInheritance() const;
-    void setResetStyleInheritance(bool);
-
-    virtual void attach();
-    virtual void detach();
-
-    bool shouldUseFallbackElements() const;
-
-    size_t indexOf(Node* node) const { return m_distribution.find(node); }
-    bool contains(const Node*) const;
-    size_t size() const { return m_distribution.size(); }
-    Node* at(size_t index)  const { return m_distribution.at(index).get(); }
-    Node* first() const { return m_distribution.isEmpty() ? 0 : m_distribution.first().get(); }
-    Node* last() const { return m_distribution.isEmpty() ? 0 : m_distribution.last().get(); }
-    Node* nextTo(const Node* node) const { return m_distribution.nextTo(node); }
-    Node* previousTo(const Node* node) const { return m_distribution.previousTo(node); }
-
-    static const CSSSelectorList& emptySelectorList();
-
-protected:
-    InsertionPoint(const QualifiedName&, Document*);
-    virtual bool rendererIsNeeded(const NodeRenderingContext&) OVERRIDE;
-    virtual void childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) OVERRIDE;
-    virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
-    virtual void removedFrom(ContainerNode*) OVERRIDE;
-    virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
-    virtual bool isInsertionPointNode() const OVERRIDE { return true; }
-
-private:
-
-    ContentDistribution m_distribution;
-    bool m_registeredWithShadowRoot;
-};
-
-inline InsertionPoint* toInsertionPoint(Node* node)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isInsertionPoint());
-    return static_cast<InsertionPoint*>(node);
-}
-
-inline const InsertionPoint* toInsertionPoint(const Node* node)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isInsertionPoint());
-    return static_cast<const InsertionPoint*>(node);
-}
-
-inline bool isActiveInsertionPoint(const Node* node)
-{
-    return node->isInsertionPoint() && toInsertionPoint(node)->isActive();
-}
-
-inline bool isLowerEncapsulationBoundary(Node* node)
-{
-    if (!node || !node->isInsertionPoint())
-        return false;
-    return toInsertionPoint(node)->isShadowBoundary();
-}
-
-inline Node* parentNodeForDistribution(const Node* node)
-{
-    ASSERT(node);
-
-    if (Node* parent = node->parentNode()) {
-        if (parent->isInsertionPoint() && toInsertionPoint(parent)->shouldUseFallbackElements())
-            return parent->parentNode();
-        return parent;
-    }
-
-    return 0;
-}
-
-inline Element* parentElementForDistribution(const Node* node)
-{
-    if (Node* parent = parentNodeForDistribution(node)) {
-        if (parent->isElementNode())
-            return toElement(parent);
-    }
-
-    return 0;
-}
-
-inline ElementShadow* shadowOfParentForDistribution(const Node* node)
-{
-    ASSERT(node);
-    if (Element* parent = parentElementForDistribution(node))
-        return parent->shadow();
-
-    return 0;
-}
-
-InsertionPoint* resolveReprojection(const Node*);
-
-void collectInsertionPointsWhereNodeIsDistributed(const Node*, Vector<InsertionPoint*, 8>& results);
-
-} // namespace WebCore
-
-#endif // InsertionPoint_h
diff --git a/Source/core/html/shadow/MeterShadowElement.cpp b/Source/core/html/shadow/MeterShadowElement.cpp
index 826bf93..2a3951d 100644
--- a/Source/core/html/shadow/MeterShadowElement.cpp
+++ b/Source/core/html/shadow/MeterShadowElement.cpp
@@ -35,7 +35,7 @@
 #include "CSSPropertyNames.h"
 #include "HTMLNames.h"
 #include "core/css/StylePropertySet.h"
-#include "core/dom/ShadowRoot.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/HTMLMeterElement.h"
 #include "core/rendering/RenderMeter.h"
 #include "core/rendering/RenderTheme.h"
diff --git a/Source/core/html/shadow/SelectRuleFeatureSet.cpp b/Source/core/html/shadow/SelectRuleFeatureSet.cpp
deleted file mode 100644
index 2a38adc..0000000
--- a/Source/core/html/shadow/SelectRuleFeatureSet.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * 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/html/shadow/SelectRuleFeatureSet.h"
-
-#include "core/css/CSSSelector.h"
-
-namespace WebCore {
-
-SelectRuleFeatureSet::SelectRuleFeatureSet()
-    : m_featureFlags(0)
-{
-}
-
-void SelectRuleFeatureSet::add(const SelectRuleFeatureSet& featureSet)
-{
-    m_cssRuleFeatureSet.add(featureSet.m_cssRuleFeatureSet);
-    m_featureFlags |= featureSet.m_featureFlags;
-}
-
-void SelectRuleFeatureSet::clear()
-{
-    m_cssRuleFeatureSet.clear();
-    m_featureFlags = 0;
-}
-
-void SelectRuleFeatureSet::collectFeaturesFromSelector(const CSSSelector* selector)
-{
-    m_cssRuleFeatureSet.collectFeaturesFromSelector(selector);
-
-    switch (selector->pseudoType()) {
-    case CSSSelector::PseudoChecked:
-        setSelectRuleFeature(AffectedSelectorChecked);
-        break;
-    case CSSSelector::PseudoEnabled:
-        setSelectRuleFeature(AffectedSelectorEnabled);
-        break;
-    case CSSSelector::PseudoDisabled:
-        setSelectRuleFeature(AffectedSelectorDisabled);
-        break;
-    case CSSSelector::PseudoIndeterminate:
-        setSelectRuleFeature(AffectedSelectorIndeterminate);
-        break;
-    case CSSSelector::PseudoLink:
-        setSelectRuleFeature(AffectedSelectorLink);
-        break;
-    case CSSSelector::PseudoTarget:
-        setSelectRuleFeature(AffectedSelectorTarget);
-        break;
-    case CSSSelector::PseudoVisited:
-        setSelectRuleFeature(AffectedSelectorVisited);
-        break;
-    default:
-        break;
-    }
-}
-
-}
-
diff --git a/Source/core/html/shadow/SelectRuleFeatureSet.h b/Source/core/html/shadow/SelectRuleFeatureSet.h
deleted file mode 100644
index 7292b12..0000000
--- a/Source/core/html/shadow/SelectRuleFeatureSet.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * 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 SelectRuleFeatureSet_h
-#define SelectRuleFeatureSet_h
-
-#include "core/css/RuleFeature.h"
-#include "core/dom/Element.h"
-
-namespace WebCore {
-
-class SelectRuleFeatureSet {
-public:
-    SelectRuleFeatureSet();
-
-    void add(const SelectRuleFeatureSet&);
-    void clear();
-    void collectFeaturesFromSelector(const CSSSelector*);
-
-    bool hasSelectorForId(const AtomicString&) const;
-    bool hasSelectorForClass(const AtomicString&) const;
-    bool hasSelectorForAttribute(const AtomicString&) const;
-
-    bool hasSelectorForChecked() const { return hasSelectorFor(AffectedSelectorChecked); }
-    bool hasSelectorForEnabled() const { return hasSelectorFor(AffectedSelectorEnabled); }
-    bool hasSelectorForDisabled() const { return hasSelectorFor(AffectedSelectorDisabled); }
-    bool hasSelectorForIndeterminate() const { return hasSelectorFor(AffectedSelectorIndeterminate); }
-    bool hasSelectorForLink() const { return hasSelectorFor(AffectedSelectorLink); }
-    bool hasSelectorForTarget() const { return hasSelectorFor(AffectedSelectorTarget); }
-    bool hasSelectorForVisited() const { return hasSelectorFor(AffectedSelectorVisited); }
-
-    bool hasSelectorFor(AffectedSelectorMask features) const { return m_featureFlags & features; }
-
-private:
-    void setSelectRuleFeature(AffectedSelectorType feature) { m_featureFlags |= feature; }
-
-    RuleFeatureSet m_cssRuleFeatureSet;
-    int m_featureFlags;
-};
-
-inline bool SelectRuleFeatureSet::hasSelectorForId(const AtomicString& idValue) const
-{
-    ASSERT(!idValue.isEmpty());
-    return m_cssRuleFeatureSet.idsInRules.contains(idValue.impl());
-}
-
-inline bool SelectRuleFeatureSet::hasSelectorForClass(const AtomicString& classValue) const
-{
-    ASSERT(!classValue.isEmpty());
-    return m_cssRuleFeatureSet.classesInRules.contains(classValue.impl());
-}
-
-inline bool SelectRuleFeatureSet::hasSelectorForAttribute(const AtomicString& attributeName) const
-{
-    ASSERT(!attributeName.isEmpty());
-    return m_cssRuleFeatureSet.attrsInRules.contains(attributeName.impl());
-}
-
-}
-
-#endif
diff --git a/Source/core/html/shadow/SliderThumbElement.cpp b/Source/core/html/shadow/SliderThumbElement.cpp
index 775deb3..2b0cf5f 100644
--- a/Source/core/html/shadow/SliderThumbElement.cpp
+++ b/Source/core/html/shadow/SliderThumbElement.cpp
@@ -34,10 +34,10 @@
 #include "core/html/shadow/SliderThumbElement.h"
 
 #include "CSSValueKeywords.h"
-#include "core/dom/ElementShadow.h"
 #include "core/dom/Event.h"
 #include "core/dom/MouseEvent.h"
-#include "core/dom/ShadowRoot.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/HTMLInputElement.h"
 #include "core/html/StepRange.h"
 #include "core/html/parser/HTMLParserIdioms.h"
diff --git a/Source/core/html/shadow/TextFieldDecorationElement.cpp b/Source/core/html/shadow/TextFieldDecorationElement.cpp
index 86d709c..138142a 100644
--- a/Source/core/html/shadow/TextFieldDecorationElement.cpp
+++ b/Source/core/html/shadow/TextFieldDecorationElement.cpp
@@ -34,10 +34,10 @@
 #include "CSSPropertyNames.h"
 #include "CSSValueKeywords.h"
 #include "core/css/resolver/StyleResolver.h"
-#include "core/dom/ElementShadow.h"
 #include "core/dom/Event.h"
 #include "core/dom/NodeRenderStyle.h"
-#include "core/dom/ShadowRoot.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/ShadowRoot.h"
 #include "core/html/HTMLInputElement.h"
 #include "core/html/shadow/HTMLShadowElement.h"
 #include "core/rendering/RenderImage.h"
diff --git a/Source/core/html/track/InbandTextTrack.h b/Source/core/html/track/InbandTextTrack.h
index 01add05..db73064 100644
--- a/Source/core/html/track/InbandTextTrack.h
+++ b/Source/core/html/track/InbandTextTrack.h
@@ -56,10 +56,6 @@
     virtual void addGenericCue(InbandTextTrackPrivate*, GenericCueData*) OVERRIDE;
     virtual void addWebVTTCue(InbandTextTrackPrivate*, double, double, const String&, const String&, const String&) OVERRIDE;
 
-#if USE(PLATFORM_TEXT_TRACK_MENU)
-    virtual InbandTextTrackPrivate* privateTrack() OVERRIDE { return m_private.get(); }
-#endif
-
     RefPtr<InbandTextTrackPrivate> m_private;
 };
 
diff --git a/Source/core/html/track/TextTrack.cpp b/Source/core/html/track/TextTrack.cpp
index 0e86b91..7ff21ee 100644
--- a/Source/core/html/track/TextTrack.cpp
+++ b/Source/core/html/track/TextTrack.cpp
@@ -482,38 +482,6 @@
     return false;
 }
 
-#if USE(PLATFORM_TEXT_TRACK_MENU)
-PassRefPtr<PlatformTextTrack> TextTrack::platformTextTrack()
-{
-    if (m_platformTextTrack)
-        return m_platformTextTrack;
-
-    PlatformTextTrack::TrackKind kind = PlatformTextTrack::Caption;
-    if (m_kind == subtitlesKeyword())
-        kind = PlatformTextTrack::Subtitle;
-    else if (m_kind == captionsKeyword())
-        kind = PlatformTextTrack::Caption;
-    else if (m_kind == descriptionsKeyword())
-        kind = PlatformTextTrack::Description;
-    else if (m_kind == chaptersKeyword())
-        kind = PlatformTextTrack::Chapter;
-    else if (m_kind == metadataKeyword())
-        kind = PlatformTextTrack::MetaData;
-
-    PlatformTextTrack::TrackType type = PlatformTextTrack::OutOfBand;
-    if (m_trackType == TrackElement)
-        type = PlatformTextTrack::OutOfBand;
-    else if (m_trackType == AddTrack)
-        type = PlatformTextTrack::Script;
-    else if (m_trackType == InBand)
-        type = PlatformTextTrack::InBand;
-
-    m_platformTextTrack = PlatformTextTrack::create(this, m_label, m_language, kind, type);
-
-    return m_platformTextTrack;
-}
-#endif
-
 bool TextTrack::isMainProgramContent() const
 {
     // "Main program" content is intrinsic to the presentation of the media file, regardless of locale. Content such as
diff --git a/Source/core/html/track/TextTrack.h b/Source/core/html/track/TextTrack.h
index ba8734f..767c2f9 100644
--- a/Source/core/html/track/TextTrack.h
+++ b/Source/core/html/track/TextTrack.h
@@ -33,10 +33,6 @@
 #include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
 
-#if USE(PLATFORM_TEXT_TRACK_MENU)
-#include "core/platform/graphics/PlatformTextTrack.h"
-#endif
-
 namespace WebCore {
 
 class HTMLMediaElement;
@@ -59,11 +55,7 @@
     virtual void textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue>) = 0;
 };
 
-class TextTrack : public TrackBase
-#if USE(PLATFORM_TEXT_TRACK_MENU)
-    , public PlatformTextTrackClient
-#endif
-    {
+class TextTrack : public TrackBase {
 public:
     static PassRefPtr<TextTrack> create(ScriptExecutionContext* context, TextTrackClient* client, const AtomicString& kind, const AtomicString& label, const AtomicString& language)
     {
@@ -145,10 +137,6 @@
 
     void removeAllCues();
 
-#if USE(PLATFORM_TEXT_TRACK_MENU)
-    PassRefPtr<PlatformTextTrack> platformTextTrack();
-#endif
-
 protected:
     TextTrack(ScriptExecutionContext*, TextTrackClient*, const AtomicString& kind, const AtomicString& label, const AtomicString& language, TextTrackType);
 #if ENABLE(WEBVTT_REGIONS)
@@ -164,12 +152,6 @@
     RefPtr<TextTrackRegionList> m_regions;
 #endif
 
-#if USE(PLATFORM_TEXT_TRACK_MENU)
-    virtual TextTrack* publicTrack() OVERRIDE { return this; }
-
-    RefPtr<PlatformTextTrack> m_platformTextTrack;
-#endif
-
     TextTrackCueList* ensureTextTrackCueList();
 
     HTMLMediaElement* m_mediaElement;