Merge from Chromium at DEPS revision 237746

This commit was generated by merge_to_master.py.

Change-Id: Ia99affe6e2cf9342843aa38fa1d75355fd5c71f7
diff --git a/Source/core/page/AutoscrollController.cpp b/Source/core/page/AutoscrollController.cpp
index 4a5f7cc..6c46028 100644
--- a/Source/core/page/AutoscrollController.cpp
+++ b/Source/core/page/AutoscrollController.cpp
@@ -171,8 +171,7 @@
 #if OS(WIN)
 void AutoscrollController::handleMouseReleaseForPanScrolling(Frame* frame, const PlatformMouseEvent& mouseEvent)
 {
-    Page* page = frame->page();
-    if (!page || page->mainFrame() != frame)
+    if (!frame->isMainFrame())
         return;
     switch (m_autoscrollType) {
     case AutoscrollForPan:
diff --git a/Source/core/page/Chrome.cpp b/Source/core/page/Chrome.cpp
index d5e8867..a7ae353 100644
--- a/Source/core/page/Chrome.cpp
+++ b/Source/core/page/Chrome.cpp
@@ -91,7 +91,7 @@
     return m_client->rootViewToScreen(rect);
 }
 
-WebKit::WebScreenInfo Chrome::screenInfo() const
+blink::WebScreenInfo Chrome::screenInfo() const
 {
     return m_client->screenInfo();
 }
diff --git a/Source/core/page/Chrome.h b/Source/core/page/Chrome.h
index 304f518..2f10b72 100644
--- a/Source/core/page/Chrome.h
+++ b/Source/core/page/Chrome.h
@@ -66,7 +66,7 @@
     virtual void scroll(const IntSize&, const IntRect&, const IntRect&) OVERRIDE;
     virtual IntPoint screenToRootView(const IntPoint&) const OVERRIDE;
     virtual IntRect rootViewToScreen(const IntRect&) const OVERRIDE;
-    virtual WebKit::WebScreenInfo screenInfo() const OVERRIDE;
+    virtual blink::WebScreenInfo screenInfo() const OVERRIDE;
 
     virtual void scheduleAnimation() OVERRIDE;
 
diff --git a/Source/core/page/ChromeClient.h b/Source/core/page/ChromeClient.h
index 14834e8..7c795e0 100644
--- a/Source/core/page/ChromeClient.h
+++ b/Source/core/page/ChromeClient.h
@@ -29,12 +29,12 @@
 #include "core/frame/ConsoleTypes.h"
 #include "core/page/FocusDirection.h"
 #include "core/platform/Cursor.h"
-#include "core/platform/PopupMenu.h"
 #include "core/platform/PopupMenuClient.h"
 #include "core/platform/graphics/GraphicsContext.h"
 #include "core/rendering/RenderEmbeddedObject.h"
 #include "modules/webdatabase/DatabaseDetails.h"
 #include "platform/HostWindow.h"
+#include "platform/PopupMenu.h"
 #include "platform/scroll/ScrollTypes.h"
 #include "wtf/Forward.h"
 #include "wtf/PassOwnPtr.h"
@@ -104,7 +104,7 @@
     // created Page has its show method called.
     // The FrameLoadRequest parameter is only for ChromeClient to check if the
     // request could be fulfilled. The ChromeClient should not load the request.
-    virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, NavigationPolicy = NavigationPolicyIgnore) = 0;
+    virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, NavigationPolicy, ShouldSendReferrer) = 0;
     virtual void show(NavigationPolicy) = 0;
 
     virtual bool canRunModal() = 0;
@@ -148,7 +148,7 @@
     virtual void scroll(const IntSize&, const IntRect&, const IntRect&) = 0;
     virtual IntPoint screenToRootView(const IntPoint&) const = 0;
     virtual IntRect rootViewToScreen(const IntRect&) const = 0;
-    virtual WebKit::WebScreenInfo screenInfo() const = 0;
+    virtual blink::WebScreenInfo screenInfo() const = 0;
     virtual void setCursor(const Cursor&) = 0;
     virtual void scheduleAnimation() = 0;
     // End methods used by HostWindow.
@@ -261,6 +261,13 @@
     virtual bool isChromeClientImpl() const { return false; }
 
     virtual void didAssociateFormControls(const Vector<RefPtr<Element> >&) { };
+    virtual void didChangeValueInTextField(HTMLInputElement&) { }
+    virtual void didEndEditingOnTextField(HTMLInputElement&) { }
+    virtual void handleKeyboardEventOnTextField(HTMLInputElement&, KeyboardEvent&) { }
+
+    // Input mehtod editor related functions.
+    virtual void didCancelCompositionOnSelectionChange() { }
+    virtual void willSetInputMethodState() { }
 
     // Notifies the client of a new popup widget.  The client should place
     // and size the widget with the given bounds, relative to the screen.
diff --git a/Source/core/page/ContextMenuController.cpp b/Source/core/page/ContextMenuController.cpp
index cd6cb8a..104dc4a 100644
--- a/Source/core/page/ContextMenuController.cpp
+++ b/Source/core/page/ContextMenuController.cpp
@@ -35,9 +35,9 @@
 #include "core/page/ContextMenuProvider.h"
 #include "core/page/EventHandler.h"
 #include "core/frame/Frame.h"
-#include "core/platform/ContextMenu.h"
-#include "core/platform/ContextMenuItem.h"
 #include "core/rendering/HitTestResult.h"
+#include "platform/ContextMenu.h"
+#include "platform/ContextMenuItem.h"
 
 namespace WebCore {
 
diff --git a/Source/core/page/CreateWindow.cpp b/Source/core/page/CreateWindow.cpp
index 0cd7ee0..1a76d57 100644
--- a/Source/core/page/CreateWindow.cpp
+++ b/Source/core/page/CreateWindow.cpp
@@ -36,17 +36,17 @@
 #include "core/page/Settings.h"
 #include "core/page/WindowFeatures.h"
 #include "platform/network/ResourceRequest.h"
-#include "weborigin/KURL.h"
-#include "weborigin/SecurityOrigin.h"
-#include "weborigin/SecurityPolicy.h"
+#include "platform/weborigin/KURL.h"
+#include "platform/weborigin/SecurityOrigin.h"
+#include "platform/weborigin/SecurityPolicy.h"
 
 namespace WebCore {
 
-static Frame* createWindow(Frame* openerFrame, Frame* lookupFrame, const FrameLoadRequest& request, const WindowFeatures& features, bool& created)
+static Frame* createWindow(Frame* openerFrame, Frame* lookupFrame, const FrameLoadRequest& request, const WindowFeatures& features, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer, bool& created)
 {
     ASSERT(!features.dialog || request.frameName().isEmpty());
 
-    if (!request.frameName().isEmpty() && request.frameName() != "_blank") {
+    if (!request.frameName().isEmpty() && request.frameName() != "_blank" && policy == NavigationPolicyIgnore) {
         if (Frame* frame = lookupFrame->loader().findFrameForNavigation(request.frameName(), openerFrame->document())) {
             if (request.frameName() != "_self") {
                 if (Page* page = frame->page())
@@ -73,7 +73,7 @@
     if (!oldPage)
         return 0;
 
-    Page* page = oldPage->chrome().client().createWindow(openerFrame, request, features);
+    Page* page = oldPage->chrome().client().createWindow(openerFrame, request, features, policy, shouldSendReferrer);
     if (!page)
         return 0;
 
@@ -106,7 +106,7 @@
     FloatRect newWindowRect = DOMWindow::adjustWindowRect(page, windowRect);
 
     page->chrome().setWindowRect(newWindowRect);
-    page->chrome().show();
+    page->chrome().show(policy);
 
     created = true;
     return frame;
@@ -134,7 +134,7 @@
     // We pass the opener frame for the lookupFrame in case the active frame is different from
     // the opener frame, and the name references a frame relative to the opener frame.
     bool created;
-    Frame* newFrame = createWindow(activeFrame, openerFrame, frameRequest, windowFeatures, created);
+    Frame* newFrame = createWindow(activeFrame, openerFrame, frameRequest, windowFeatures, NavigationPolicyIgnore, MaybeSendReferrer, created);
     if (!newFrame)
         return 0;
 
@@ -156,4 +156,33 @@
     return newFrame;
 }
 
+void createWindowForRequest(const FrameLoadRequest& request, Frame* openerFrame, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer)
+{
+    if (openerFrame->document()->pageDismissalEventBeingDispatched() != Document::NoDismissal)
+        return;
+
+    if (openerFrame->document() && openerFrame->document()->isSandboxed(SandboxPopups))
+        return;
+
+    if (!DOMWindow::allowPopUp(openerFrame))
+        return;
+
+    if (policy == NavigationPolicyCurrentTab)
+        policy = NavigationPolicyNewForegroundTab;
+
+    WindowFeatures features;
+    bool created;
+    Frame* newFrame = createWindow(openerFrame, openerFrame, request, features, policy, shouldSendReferrer, created);
+    if (!newFrame)
+        return;
+    newFrame->page()->setOpenedByDOM();
+    if (shouldSendReferrer == MaybeSendReferrer) {
+        newFrame->loader().setOpener(openerFrame);
+        newFrame->document()->setReferrerPolicy(openerFrame->document()->referrerPolicy());
+    }
+    FrameLoadRequest newRequest(0, request.resourceRequest());
+    newRequest.setFormState(request.formState());
+    newFrame->loader().load(newRequest);
+}
+
 } // namespace WebCore
diff --git a/Source/core/page/CreateWindow.h b/Source/core/page/CreateWindow.h
index a6fe12d..1c2f353 100644
--- a/Source/core/page/CreateWindow.h
+++ b/Source/core/page/CreateWindow.h
@@ -28,15 +28,20 @@
 #define CreateWindow_h
 
 #include "core/frame/DOMWindow.h"
+#include "core/loader/FrameLoaderTypes.h"
+#include "core/loader/NavigationPolicy.h"
 #include "wtf/text/WTFString.h"
 
 namespace WebCore {
 class Frame;
+struct FrameLoadRequest;
 struct WindowFeatures;
 
 Frame* createWindow(const String& urlString, const AtomicString& frameName, const WindowFeatures&,
     DOMWindow* activeWindow, Frame* firstFrame, Frame* openerFrame, DOMWindow::PrepareDialogFunction = 0, void* functionContext = 0);
 
+void createWindowForRequest(const FrameLoadRequest&, Frame* openerFrame, NavigationPolicy, ShouldSendReferrer);
+
 } // namespace WebCore
 
 #endif // CreateWindow_h
diff --git a/Source/core/page/DOMSelection.cpp b/Source/core/page/DOMSelection.cpp
index fbba561..a1d6702 100644
--- a/Source/core/page/DOMSelection.cpp
+++ b/Source/core/page/DOMSelection.cpp
@@ -194,13 +194,13 @@
     return m_frame->selection().isNone() ? 0 : 1;
 }
 
-void DOMSelection::collapse(Node* node, int offset, ExceptionState& es)
+void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionState)
 {
     if (!m_frame)
         return;
 
     if (offset < 0) {
-        es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute("collapse", "Selection", String::number(offset) + " is not a valid offset."));
+        exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute("collapse", "Selection", String::number(offset) + " is not a valid offset."));
         return;
     }
 
@@ -211,7 +211,7 @@
     m_frame->selection().moveTo(VisiblePosition(createLegacyEditingPosition(node, offset), DOWNSTREAM));
 }
 
-void DOMSelection::collapseToEnd(ExceptionState& es)
+void DOMSelection::collapseToEnd(ExceptionState& exceptionState)
 {
     if (!m_frame)
         return;
@@ -219,14 +219,14 @@
     const VisibleSelection& selection = m_frame->selection().selection();
 
     if (selection.isNone()) {
-        es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecute("collapseToEnd", "Selection", "there is no selection."));
+        exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecute("collapseToEnd", "Selection", "there is no selection."));
         return;
     }
 
     m_frame->selection().moveTo(VisiblePosition(selection.end(), DOWNSTREAM));
 }
 
-void DOMSelection::collapseToStart(ExceptionState& es)
+void DOMSelection::collapseToStart(ExceptionState& exceptionState)
 {
     if (!m_frame)
         return;
@@ -234,7 +234,7 @@
     const VisibleSelection& selection = m_frame->selection().selection();
 
     if (selection.isNone()) {
-        es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecute("collapseToStart", "Selection", "there is no selection."));
+        exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecute("collapseToStart", "Selection", "there is no selection."));
         return;
     }
 
@@ -248,18 +248,18 @@
     m_frame->selection().clear();
 }
 
-void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extentNode, int extentOffset, ExceptionState& es)
+void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extentNode, int extentOffset, ExceptionState& exceptionState)
 {
     if (!m_frame)
         return;
 
     if (baseOffset < 0) {
-        es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute("setBaseAndExtent", "Selection", String::number(baseOffset) + " is not a valid base offset."));
+        exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute("setBaseAndExtent", "Selection", String::number(baseOffset) + " is not a valid base offset."));
         return;
     }
 
     if (extentOffset < 0) {
-        es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute("setBaseAndExtent", "Selection", String::number(extentOffset) + " is not a valid extent offset."));
+        exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute("setBaseAndExtent", "Selection", String::number(extentOffset) + " is not a valid extent offset."));
         return;
     }
 
@@ -273,12 +273,12 @@
     m_frame->selection().moveTo(visibleBase, visibleExtent);
 }
 
-void DOMSelection::setPosition(Node* node, int offset, ExceptionState& es)
+void DOMSelection::setPosition(Node* node, int offset, ExceptionState& exceptionState)
 {
     if (!m_frame)
         return;
     if (offset < 0) {
-        es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute("setPosition", "Selection", String::number(offset) + " is not a valid offset."));
+        exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute("setPosition", "Selection", String::number(offset) + " is not a valid offset."));
         return;
     }
 
@@ -339,22 +339,22 @@
     m_frame->selection().modify(alter, direction, granularity);
 }
 
-void DOMSelection::extend(Node* node, int offset, ExceptionState& es)
+void DOMSelection::extend(Node* node, int offset, ExceptionState& exceptionState)
 {
     if (!m_frame)
         return;
 
     if (!node) {
-        es.throwDOMException(TypeMismatchError, ExceptionMessages::failedToExecute("extend", "Selection", "The node provided is invalid."));
+        exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::failedToExecute("extend", "Selection", "The node provided is invalid."));
         return;
     }
 
     if (offset < 0) {
-        es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute("extend", "Selection", String::number(offset) + " is not a valid offset."));
+        exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute("extend", "Selection", String::number(offset) + " is not a valid offset."));
         return;
     }
     if (offset > (node->offsetInCharacters() ? caretMaxOffset(node) : (int)node->childNodeCount())) {
-        es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute("extend", "Selection", String::number(offset) + " is larger than the given node's length."));
+        exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute("extend", "Selection", String::number(offset) + " is larger than the given node's length."));
         return;
     }
 
@@ -365,13 +365,13 @@
     m_frame->selection().setExtent(VisiblePosition(createLegacyEditingPosition(node, offset), DOWNSTREAM));
 }
 
-PassRefPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState& es)
+PassRefPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState& exceptionState)
 {
     if (!m_frame)
         return 0;
 
     if (index < 0 || index >= rangeCount()) {
-        es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute("getRangeAt", "Selection", String::number(index) + " is not a valid index."));
+        exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute("getRangeAt", "Selection", String::number(index) + " is not a valid index."));
         return 0;
     }
 
@@ -423,8 +423,8 @@
         }
     } else {
         // We don't support discontiguous selection. We don't do anything if r and range don't intersect.
-        TrackExceptionState es;
-        if (r->compareBoundaryPoints(Range::END_TO_START, range.get(), es) < 1 && !es.hadException()) {
+        TrackExceptionState exceptionState;
+        if (r->compareBoundaryPoints(Range::END_TO_START, range.get(), exceptionState) < 1 && !exceptionState.hadException()) {
             if (r->compareBoundaryPoints(Range::END_TO_END, range.get(), IGNORE_EXCEPTION) == -1) {
                 // The original range contains r.
                 selection.setSelection(VisibleSelection(range.get()));
@@ -475,29 +475,29 @@
     if (!parentNode)
         return false;
 
-    TrackExceptionState es;
-    bool nodeFullySelected = Range::compareBoundaryPoints(parentNode, nodeIndex, selectedRange->startContainer(), selectedRange->startOffset(), es) >= 0 && !es.hadException()
-        && Range::compareBoundaryPoints(parentNode, nodeIndex + 1, selectedRange->endContainer(), selectedRange->endOffset(), es) <= 0 && !es.hadException();
-    ASSERT(!es.hadException());
+    TrackExceptionState exceptionState;
+    bool nodeFullySelected = Range::compareBoundaryPoints(parentNode, nodeIndex, selectedRange->startContainer(), selectedRange->startOffset(), exceptionState) >= 0 && !exceptionState.hadException()
+        && Range::compareBoundaryPoints(parentNode, nodeIndex + 1, selectedRange->endContainer(), selectedRange->endOffset(), exceptionState) <= 0 && !exceptionState.hadException();
+    ASSERT(!exceptionState.hadException());
     if (nodeFullySelected)
         return true;
 
-    bool nodeFullyUnselected = (Range::compareBoundaryPoints(parentNode, nodeIndex, selectedRange->endContainer(), selectedRange->endOffset(), es) > 0 && !es.hadException())
-        || (Range::compareBoundaryPoints(parentNode, nodeIndex + 1, selectedRange->startContainer(), selectedRange->startOffset(), es) < 0 && !es.hadException());
-    ASSERT(!es.hadException());
+    bool nodeFullyUnselected = (Range::compareBoundaryPoints(parentNode, nodeIndex, selectedRange->endContainer(), selectedRange->endOffset(), exceptionState) > 0 && !exceptionState.hadException())
+        || (Range::compareBoundaryPoints(parentNode, nodeIndex + 1, selectedRange->startContainer(), selectedRange->startOffset(), exceptionState) < 0 && !exceptionState.hadException());
+    ASSERT(!exceptionState.hadException());
     if (nodeFullyUnselected)
         return false;
 
     return allowPartial || n->isTextNode();
 }
 
-void DOMSelection::selectAllChildren(Node* n, ExceptionState& es)
+void DOMSelection::selectAllChildren(Node* n, ExceptionState& exceptionState)
 {
     if (!n)
         return;
 
     // This doesn't (and shouldn't) select text node characters.
-    setBaseAndExtent(n, 0, n, n->childNodeCount(), es);
+    setBaseAndExtent(n, 0, n, n->childNodeCount(), exceptionState);
 }
 
 String DOMSelection::toString()
diff --git a/Source/core/page/DragActions.h b/Source/core/page/DragActions.h
index d98c9c4..ce42ab7 100644
--- a/Source/core/page/DragActions.h
+++ b/Source/core/page/DragActions.h
@@ -39,13 +39,12 @@
         DragDestinationActionAny     = UINT_MAX
     } DragDestinationAction;
 
-    // WebCoreDragSourceAction should be kept in sync with WebDragSourceAction
     typedef enum {
-        DragSourceActionNone         = 0,
-        DragSourceActionDHTML        = 1,
-        DragSourceActionImage        = 2,
-        DragSourceActionLink         = 4,
-        DragSourceActionSelection    = 8,
+        DragSourceActionNone,
+        DragSourceActionDHTML,
+        DragSourceActionImage,
+        DragSourceActionLink,
+        DragSourceActionSelection,
     } DragSourceAction;
 
     //matches NSDragOperation
diff --git a/Source/core/page/DragController.cpp b/Source/core/page/DragController.cpp
index 3dc03d2..1c97568 100644
--- a/Source/core/page/DragController.cpp
+++ b/Source/core/page/DragController.cpp
@@ -56,12 +56,12 @@
 #include "core/loader/FrameLoader.h"
 #include "core/page/DragActions.h"
 #include "core/page/DragClient.h"
+#include "core/page/DragData.h"
 #include "core/page/DragSession.h"
 #include "core/page/DragState.h"
 #include "core/page/EventHandler.h"
 #include "core/page/Page.h"
 #include "core/page/Settings.h"
-#include "core/platform/DragData.h"
 #include "core/platform/DragImage.h"
 #include "core/platform/chromium/ChromiumDataObject.h"
 #include "core/platform/graphics/Image.h"
@@ -73,7 +73,7 @@
 #include "platform/geometry/FloatRect.h"
 #include "platform/graphics/ImageOrientation.h"
 #include "platform/network/ResourceRequest.h"
-#include "weborigin/SecurityOrigin.h"
+#include "platform/weborigin/SecurityOrigin.h"
 #include "wtf/CurrentTime.h"
 #include "wtf/OwnPtr.h"
 #include "wtf/PassOwnPtr.h"
@@ -620,45 +620,77 @@
     return true;
 }
 
-Node* DragController::draggableNode(const Frame* src, Node* startNode, const IntPoint& dragOrigin, DragState& state) const
+Node* DragController::draggableNode(const Frame* src, Node* startNode, const IntPoint& dragOrigin, SelectionDragPolicy selectionDragPolicy, DragSourceAction& dragType) const
 {
-    state.m_dragType = (src->selection().contains(dragOrigin)) ? DragSourceActionSelection : DragSourceActionNone;
+    if (src->selection().contains(dragOrigin)) {
+        dragType = DragSourceActionSelection;
+        if (selectionDragPolicy == ImmediateSelectionDragResolution)
+            return startNode;
+    } else {
+        dragType = DragSourceActionNone;
+    }
 
+    Node* node = 0;
+    DragSourceAction candidateDragType = DragSourceActionNone;
     for (const RenderObject* renderer = startNode->renderer(); renderer; renderer = renderer->parent()) {
-        Node* node = renderer->nonPseudoNode();
-        if (!node)
+        node = renderer->nonPseudoNode();
+        if (!node) {
             // Anonymous render blocks don't correspond to actual DOM nodes, so we skip over them
             // for the purposes of finding a draggable node.
             continue;
-        if (!(state.m_dragType & DragSourceActionSelection) && node->isTextNode() && node->canStartSelection())
+        }
+        if (dragType != DragSourceActionSelection && node->isTextNode() && node->canStartSelection()) {
             // In this case we have a click in the unselected portion of text. If this text is
             // selectable, we want to start the selection process instead of looking for a parent
             // to try to drag.
             return 0;
+        }
         if (node->isElementNode()) {
             EUserDrag dragMode = renderer->style()->userDrag();
             if (dragMode == DRAG_NONE)
                 continue;
+            // Even if the image is part of a selection, we always only drag the image in this case.
             if (renderer->isImage()
                 && src->settings()
                 && src->settings()->loadsImagesAutomatically()) {
-                state.m_dragType = static_cast<DragSourceAction>(state.m_dragType | DragSourceActionImage);
+                dragType = DragSourceActionImage;
                 return node;
             }
+            // Other draggable elements are considered unselectable.
             if (isHTMLAnchorElement(node)
                 && toHTMLAnchorElement(node)->isLiveLink()) {
-                state.m_dragType = static_cast<DragSourceAction>(state.m_dragType | DragSourceActionLink);
-                return node;
+                candidateDragType = DragSourceActionLink;
+                break;
             }
             if (dragMode == DRAG_ELEMENT) {
-                state.m_dragType = static_cast<DragSourceAction>(state.m_dragType | DragSourceActionDHTML);
-                return node;
+                candidateDragType = DragSourceActionDHTML;
+                break;
             }
         }
     }
 
-    // We either have nothing to drag or we have a selection and we're not over a draggable element.
-    return (state.m_dragType & DragSourceActionSelection) ? startNode : 0;
+    if (candidateDragType == DragSourceActionNone) {
+        // Either:
+        // 1) Nothing under the cursor is considered draggable, so we bail out.
+        // 2) There was a selection under the cursor but selectionDragPolicy is set to
+        //    DelayedSelectionDragResolution and no other draggable element could be found, so bail
+        //    out and allow text selection to start at the cursor instead.
+        return 0;
+    }
+
+    ASSERT(node);
+    if (dragType == DragSourceActionSelection) {
+        // Dragging unselectable elements in a selection has special behavior if selectionDragPolicy
+        // is DelayedSelectionDragResolution and this drag was flagged as a potential selection
+        // drag. In that case, don't allow selection and just drag the entire selection instead.
+        ASSERT(selectionDragPolicy == DelayedSelectionDragResolution);
+        node = startNode;
+    } else {
+        // If the cursor isn't over a selection, then just drag the node we found earlier.
+        ASSERT(dragType == DragSourceActionNone);
+        dragType = candidateDragType;
+    }
+    return node;
 }
 
 static ImageResource* getImageResource(Element* element)
@@ -699,7 +731,7 @@
     if (!src->view() || !src->contentRenderer())
         return false;
 
-    HitTestResult hitTestResult = src->eventHandler().hitTestResultAtPoint(dragOrigin, HitTestRequest::ReadOnly | HitTestRequest::Active);
+    HitTestResult hitTestResult = src->eventHandler().hitTestResultAtPoint(dragOrigin);
     // FIXME: Can this even happen? I guess it's possible, but should verify
     // with a layout test.
     if (!state.m_dragSrc->contains(hitTestResult.innerNode())) {
@@ -820,11 +852,12 @@
         return false;
 
     HitTestResult hitTestResult = src->eventHandler().hitTestResultAtPoint(dragOrigin);
-    if (!state.m_dragSrc->contains(hitTestResult.innerNode()))
+    if (!state.m_dragSrc->contains(hitTestResult.innerNode())) {
         // The original node being dragged isn't under the drag origin anymore... maybe it was
         // hidden or moved out from under the cursor. Regardless, we don't want to start a drag on
         // something that's not actually under the drag origin.
         return false;
+    }
     const KURL& linkURL = hitTestResult.absoluteLinkURL();
     const KURL& imageURL = hitTestResult.absoluteImageURL();
 
diff --git a/Source/core/page/DragController.h b/Source/core/page/DragController.h
index 1aed97e..f109837 100644
--- a/Source/core/page/DragController.h
+++ b/Source/core/page/DragController.h
@@ -28,7 +28,7 @@
 
 #include "core/page/DragActions.h"
 #include "platform/geometry/IntPoint.h"
-#include "weborigin/KURL.h"
+#include "platform/weborigin/KURL.h"
 #include "wtf/Forward.h"
 
 namespace WebCore {
@@ -63,7 +63,11 @@
         DragSession dragUpdated(DragData*);
         bool performDrag(DragData*);
 
-        Node* draggableNode(const Frame*, Node*, const IntPoint&, DragState&) const;
+        enum SelectionDragPolicy {
+            ImmediateSelectionDragResolution,
+            DelayedSelectionDragResolution,
+        };
+        Node* draggableNode(const Frame*, Node*, const IntPoint&, SelectionDragPolicy, DragSourceAction&) const;
         void dragEnded();
 
         bool populateDragClipboard(Frame* src, const DragState&, const IntPoint& dragOrigin);
diff --git a/Source/core/page/DragData.cpp b/Source/core/page/DragData.cpp
new file mode 100644
index 0000000..79a2257
--- /dev/null
+++ b/Source/core/page/DragData.cpp
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ * Copyright (C) 2013 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "core/page/DragData.h"
+
+#include "core/dom/Document.h"
+#include "core/dom/DocumentFragment.h"
+#include "core/dom/Range.h"
+#include "core/editing/markup.h"
+#include "core/frame/Frame.h"
+#include "core/platform/chromium/ChromiumDataObject.h"
+#include "modules/filesystem/DraggedIsolatedFileSystem.h"
+#include "platform/FileMetadata.h"
+#include "platform/clipboard/ClipboardMimeTypes.h"
+#include "platform/weborigin/KURL.h"
+#include "wtf/text/WTFString.h"
+
+namespace WebCore {
+
+DragData::DragData(ChromiumDataObject* data, const IntPoint& clientPosition, const IntPoint& globalPosition,
+    DragOperation sourceOperationMask, DragApplicationFlags flags)
+    : m_clientPosition(clientPosition)
+    , m_globalPosition(globalPosition)
+    , m_platformDragData(data)
+    , m_draggingSourceOperationMask(sourceOperationMask)
+    , m_applicationFlags(flags)
+{
+}
+
+DragData::DragData(const String&, const IntPoint& clientPosition, const IntPoint& globalPosition,
+    DragOperation sourceOperationMask, DragApplicationFlags flags)
+    : m_clientPosition(clientPosition)
+    , m_globalPosition(globalPosition)
+    , m_platformDragData(0)
+    , m_draggingSourceOperationMask(sourceOperationMask)
+    , m_applicationFlags(flags)
+{
+}
+
+static bool containsHTML(const ChromiumDataObject* dropData)
+{
+    return dropData->types().contains(mimeTypeTextHTML);
+}
+
+bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
+{
+    return m_platformDragData->types().contains(mimeTypeTextURIList)
+        || (filenamePolicy == ConvertFilenames && m_platformDragData->containsFilenames());
+}
+
+String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) const
+{
+    String url;
+    if (m_platformDragData->types().contains(mimeTypeTextURIList))
+        m_platformDragData->urlAndTitle(url, title);
+    else if (filenamePolicy == ConvertFilenames && containsFiles())
+        url = filePathToURL(m_platformDragData->filenames()[0]);
+    return url;
+}
+
+bool DragData::containsFiles() const
+{
+    return m_platformDragData->containsFilenames();
+}
+
+unsigned DragData::numberOfFiles() const
+{
+    return m_platformDragData->filenames().size();
+}
+
+int DragData::modifierKeyState() const
+{
+    return m_platformDragData->modifierKeyState();
+}
+
+void DragData::asFilenames(Vector<String>& result) const
+{
+    const Vector<String>& filenames = m_platformDragData->filenames();
+    for (size_t i = 0; i < filenames.size(); ++i)
+        result.append(filenames[i]);
+}
+
+bool DragData::containsPlainText() const
+{
+    return m_platformDragData->types().contains(mimeTypeTextPlain);
+}
+
+String DragData::asPlainText() const
+{
+    return m_platformDragData->getData(mimeTypeTextPlain);
+}
+
+bool DragData::canSmartReplace() const
+{
+    // Mimic the situations in which mac allows drag&drop to do a smart replace.
+    // This is allowed whenever the drag data contains a 'range' (ie.,
+    // ClipboardWin::writeRange is called). For example, dragging a link
+    // should not result in a space being added.
+    return m_platformDragData->types().contains(mimeTypeTextPlain)
+        && !m_platformDragData->types().contains(mimeTypeTextURIList);
+}
+
+bool DragData::containsCompatibleContent() const
+{
+    return containsPlainText()
+        || containsURL()
+        || containsHTML(m_platformDragData)
+        || containsFiles();
+}
+
+PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range>, bool, bool&) const
+{
+    /*
+     * Order is richest format first. On OSX this is:
+     * * Web Archive
+     * * Filenames
+     * * HTML
+     * * RTF
+     * * TIFF
+     * * PICT
+     */
+
+    if (containsFiles()) {
+        // FIXME: Implement this. Should be pretty simple to make some HTML
+        // and call createFragmentFromMarkup.
+    }
+
+    if (m_platformDragData->types().contains(mimeTypeTextHTML)) {
+        String html;
+        KURL baseURL;
+        m_platformDragData->htmlAndBaseURL(html, baseURL);
+        ASSERT(frame->document());
+        if (RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(*frame->document(), html, baseURL, DisallowScriptingAndPluginContent))
+            return fragment.release();
+    }
+
+    return 0;
+}
+
+String DragData::droppedFileSystemId() const
+{
+    DraggedIsolatedFileSystem* filesystem = DraggedIsolatedFileSystem::from(m_platformDragData);
+    if (!filesystem)
+        return String();
+    return filesystem->filesystemId();
+}
+
+} // namespace WebCore
diff --git a/Source/core/page/DragData.h b/Source/core/page/DragData.h
new file mode 100644
index 0000000..33c108c
--- /dev/null
+++ b/Source/core/page/DragData.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DragData_h
+#define DragData_h
+
+#include "core/page/DragActions.h"
+#include "platform/geometry/IntPoint.h"
+
+#include "wtf/Forward.h"
+#include "wtf/HashMap.h"
+#include "wtf/Vector.h"
+
+namespace WebCore {
+
+class ChromiumDataObject;
+class DocumentFragment;
+class Frame;
+class KURL;
+class Range;
+
+enum DragApplicationFlags {
+    DragApplicationNone = 0,
+    DragApplicationIsModal = 1,
+    DragApplicationIsSource = 2,
+    DragApplicationHasAttachedSheet = 4,
+    DragApplicationIsCopyKeyDown = 8
+};
+
+class DragData {
+public:
+    enum FilenameConversionPolicy { DoNotConvertFilenames, ConvertFilenames };
+
+    // clientPosition is taken to be the position of the drag event within the target window, with (0,0) at the top left
+    DragData(ChromiumDataObject*, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation, DragApplicationFlags = DragApplicationNone);
+    DragData(const String& dragStorageName, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation, DragApplicationFlags = DragApplicationNone);
+    const IntPoint& clientPosition() const { return m_clientPosition; }
+    const IntPoint& globalPosition() const { return m_globalPosition; }
+    DragApplicationFlags flags() const { return m_applicationFlags; }
+    ChromiumDataObject* platformData() const { return m_platformDragData; }
+    DragOperation draggingSourceOperationMask() const { return m_draggingSourceOperationMask; }
+    bool containsURL(FilenameConversionPolicy filenamePolicy = ConvertFilenames) const;
+    bool containsPlainText() const;
+    bool containsCompatibleContent() const;
+    String asURL(FilenameConversionPolicy filenamePolicy = ConvertFilenames, String* title = 0) const;
+    String asPlainText() const;
+    void asFilenames(Vector<String>&) const;
+    PassRefPtr<DocumentFragment> asFragment(Frame*, PassRefPtr<Range> context, bool allowPlainText, bool& chosePlainText) const;
+    bool canSmartReplace() const;
+    bool containsFiles() const;
+    unsigned numberOfFiles() const;
+    int modifierKeyState() const;
+
+    String droppedFileSystemId() const;
+
+private:
+    IntPoint m_clientPosition;
+    IntPoint m_globalPosition;
+    ChromiumDataObject* m_platformDragData;
+    DragOperation m_draggingSourceOperationMask;
+    DragApplicationFlags m_applicationFlags;
+};
+
+}
+
+#endif // !DragData_h
diff --git a/Source/core/page/EditorClient.h b/Source/core/page/EditorClient.h
index 7be8026..f7664b6 100644
--- a/Source/core/page/EditorClient.h
+++ b/Source/core/page/EditorClient.h
@@ -27,74 +27,27 @@
 #ifndef EditorClient_h
 #define EditorClient_h
 
-#include "core/editing/TextAffinity.h"
-#include "core/editing/UndoStep.h"
-#include "platform/geometry/FloatRect.h"
-#include "platform/text/TextChecking.h"
+#include "core/editing/SelectionType.h"
 #include "wtf/Forward.h"
-#include "wtf/Vector.h"
 
 namespace WebCore {
 
-class ArchiveResource;
-class DocumentFragment;
-class Editor;
 class Element;
 class Frame;
-class HTMLElement;
-class KeyboardEvent;
-class Node;
-class Range;
-class SharedBuffer;
-class StylePropertySet;
-class TextCheckerClient;
-class VisibleSelection;
-class VisiblePosition;
-
-struct GrammarDetail;
+class UndoStep;
 
 class EditorClient {
 public:
-    virtual ~EditorClient() {  }
-
-    virtual bool smartInsertDeleteEnabled() = 0;
-    virtual bool isSelectTrailingWhitespaceEnabled() = 0;
-    virtual bool isContinuousSpellCheckingEnabled() = 0;
-    virtual void toggleContinuousSpellChecking() = 0;
-    virtual bool isGrammarCheckingEnabled() = 0;
+    virtual ~EditorClient() { }
 
     virtual void respondToChangedContents() = 0;
-    virtual void respondToChangedSelection(Frame*) = 0;
-    virtual void didCancelCompositionOnSelectionChange() = 0;
-
-    virtual void registerUndoStep(PassRefPtr<UndoStep>) = 0;
-    virtual void registerRedoStep(PassRefPtr<UndoStep>) = 0;
-    virtual void clearUndoRedoOperations() = 0;
+    virtual void respondToChangedSelection(SelectionType) = 0;
 
     virtual bool canCopyCut(Frame*, bool defaultValue) const = 0;
     virtual bool canPaste(Frame*, bool defaultValue) const = 0;
-    virtual bool canUndo() const = 0;
-    virtual bool canRedo() const = 0;
 
-    virtual void undo() = 0;
-    virtual void redo() = 0;
-
-    virtual void handleKeyboardEvent(KeyboardEvent*) = 0;
-
-    virtual void textFieldDidEndEditing(Element*) = 0;
-    virtual void textDidChangeInTextField(Element*) = 0;
-    virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*) = 0;
-
-    virtual TextCheckerClient& textChecker() = 0;
-
-    virtual void updateSpellingUIWithMisspelledWord(const String&) = 0;
-    virtual void showSpellingUI(bool show) = 0;
-    virtual bool spellingUIIsShowing() = 0;
-    virtual void willSetInputMethodState() = 0;
-
-    // Support for global selections, used on platforms like the X Window System that treat
-    // selection as a type of clipboard.
-    virtual bool supportsGlobalSelection() { return false; }
+    virtual void didExecuteCommand(String) = 0;
+    virtual bool handleKeyboardEvent() = 0;
 };
 
 }
diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp
index 5501d94..11e63b3 100644
--- a/Source/core/page/EventHandler.cpp
+++ b/Source/core/page/EventHandler.cpp
@@ -76,7 +76,6 @@
 #include "core/platform/Cursor.h"
 #include "core/platform/ScrollAnimator.h"
 #include "core/platform/Scrollbar.h"
-#include "core/platform/WindowsKeyboardCodes.h"
 #include "core/platform/chromium/ChromiumDataObject.h"
 #include "core/platform/graphics/Image.h"
 #include "core/rendering/HitTestRequest.h"
@@ -93,6 +92,7 @@
 #include "platform/PlatformKeyboardEvent.h"
 #include "platform/PlatformTouchEvent.h"
 #include "platform/PlatformWheelEvent.h"
+#include "platform/WindowsKeyboardCodes.h"
 #include "platform/geometry/FloatPoint.h"
 #include "wtf/Assertions.h"
 #include "wtf/CurrentTime.h"
@@ -135,7 +135,6 @@
 static const double TextDragDelay = 0.0;
 #endif
 
-
 enum NoCursorChangeType { NoCursorChange };
 
 class OptionalCursor {
@@ -259,14 +258,6 @@
     return enclosingBox->scroll(delta < 0 ? negativeDirection : positiveDirection, granularity, absDelta, stopNode);
 }
 
-static inline bool shouldGesturesTriggerActive()
-{
-    // If the platform we're on supports GestureShowPress and GestureTapCancel then we'll
-    // rely on them to set the active state. Unfortunately there's no generic way to
-    // know in advance what event types are supported.
-    return true;
-}
-
 // Refetch the event target node if it is removed or currently is the shadow node inside an <input> element.
 // If a mouse event handler changes the input element type to one that has a widget associated,
 // we'd like to EventHandler::handleMousePressEvent to pass the event to the widget and thus the
@@ -285,7 +276,6 @@
     , m_capturesDragging(false)
     , m_mouseDownMayStartSelect(false)
     , m_mouseDownMayStartDrag(false)
-    , m_dragMayStartSelectionInstead(false)
     , m_mouseDownWasSingleClickInSelection(false)
     , m_selectionInitiationState(HaveNotStartedSelection)
     , m_panScrollButtonPressed(false)
@@ -369,8 +359,15 @@
 
 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved)
 {
-    if (nodeToBeRemoved.contains(m_clickNode.get()))
+    if (!nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get()))
+        return;
+    if (nodeToBeRemoved.isInShadowTree()) {
+        m_clickNode = nodeToBeRemoved.parentOrShadowHostNode();
+    } else {
+        // We don't dispatch click events if the mousedown node is removed
+        // before a mouseup event. It is compatible with IE and Firefox.
         m_clickNode = 0;
+    }
 }
 
 static void setSelectionIfNeeded(FrameSelection& selection, const VisibleSelection& newSelection)
@@ -1374,10 +1371,10 @@
 #endif
 
     m_clickCount = mouseEvent.clickCount();
-    m_clickNode = mev.targetNode();
+    m_clickNode = mev.targetNode()->isTextNode() ?  mev.targetNode()->parentOrShadowHostNode() : mev.targetNode();
 
     if (FrameView* view = m_frame->view()) {
-        RenderLayer* layer = m_clickNode->renderer() ? m_clickNode->renderer()->enclosingLayer() : 0;
+        RenderLayer* layer = mev.targetNode()->renderer() ? mev.targetNode()->renderer()->enclosingLayer() : 0;
         IntPoint p = view->windowToContents(mouseEvent.position());
         if (layer && layer->scrollableArea() && layer->scrollableArea()->isPointInResizeControl(p, ResizerForPointer)) {
             m_resizeScrollableArea = layer->scrollableArea();
@@ -1616,30 +1613,6 @@
     m_clickNode = 0;
 }
 
-inline static bool mouseIsReleasedOnPressedElement(Node* targetNode, Node* clickNode)
-{
-    if (targetNode == clickNode)
-        return true;
-
-    if (!targetNode)
-        return false;
-
-    ShadowRoot* containingShadowRoot = targetNode->containingShadowRoot();
-    if (!containingShadowRoot)
-        return false;
-
-    // FIXME: When an element in UA ShadowDOM (e.g. inner element in <input>) is clicked,
-    // we assume that the host element is clicked. This is necessary for implementing <input type="range"> etc.
-    // However, we should not check ShadowRoot type basically.
-    // https://bugs.webkit.org/show_bug.cgi?id=108047
-    if (containingShadowRoot->type() != ShadowRoot::UserAgentShadowRoot)
-        return false;
-
-    Node* adjustedTargetNode = targetNode->shadowHost();
-    Node* adjustedClickNode = clickNode ? clickNode->shadowHost() : 0;
-    return adjustedTargetNode == adjustedClickNode;
-}
-
 bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
 {
     RefPtr<FrameView> protector(m_frame->view());
@@ -1699,7 +1672,11 @@
         contextMenuEvent = true;
 #endif
 
-    bool swallowClickEvent = m_clickCount > 0 && !contextMenuEvent && mouseIsReleasedOnPressedElement(mev.targetNode(), m_clickNode.get()) && !dispatchMouseEvent(EventTypeNames::click, mev.targetNode(), true, m_clickCount, mouseEvent, true);
+    bool swallowClickEvent = false;
+    if (m_clickCount > 0 && !contextMenuEvent && mev.targetNode() && m_clickNode) {
+        if (Node* clickTargetNode = mev.targetNode()->commonAncestorOverShadowBoundary(*m_clickNode))
+            swallowClickEvent = !dispatchMouseEvent(EventTypeNames::click, clickTargetNode, true, m_clickCount, mouseEvent, true);
+    }
 
     if (m_resizeScrollableArea) {
         m_resizeScrollableArea->setInResizeMode(false);
@@ -1740,7 +1717,7 @@
         return false;
     Frame* focusFrame = m_frame->page()->focusController().focusedOrMainFrame();
     // Do not paste here if the focus was moved somewhere else.
-    if (m_frame == focusFrame && m_frame->editor().client().supportsGlobalSelection())
+    if (m_frame == focusFrame && m_frame->editor().behavior().supportsGlobalSelection())
         return m_frame->editor().command("PasteGlobalSelection").execute();
 
     return false;
@@ -2268,6 +2245,16 @@
 
 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
 {
+    IntPoint adjustedPoint = gestureEvent.position();
+    if (gestureEvent.type() == PlatformEvent::GestureLongPress
+        || gestureEvent.type() == PlatformEvent::GestureLongTap
+        || gestureEvent.type() == PlatformEvent::GestureTwoFingerTap) {
+        adjustGesturePosition(gestureEvent, adjustedPoint);
+        RefPtr<Frame> subframe = getSubFrameForGestureEvent(adjustedPoint, gestureEvent);
+        if (subframe)
+            return subframe->eventHandler().handleGestureEvent(gestureEvent);
+    }
+
     Node* eventTarget = 0;
     Scrollbar* scrollbar = 0;
     if (gestureEvent.type() == PlatformEvent::GestureScrollEnd
@@ -2277,7 +2264,6 @@
         eventTarget = m_scrollGestureHandlingNode.get();
     }
 
-    IntPoint adjustedPoint = gestureEvent.position();
     HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent;
     if (gestureEvent.type() == PlatformEvent::GestureShowPress
         || gestureEvent.type() == PlatformEvent::GestureTapUnconfirmed) {
@@ -2293,9 +2279,6 @@
     else
         hitType |= HitTestRequest::Active | HitTestRequest::ReadOnly;
 
-    if (!shouldGesturesTriggerActive())
-        hitType |= HitTestRequest::ReadOnly;
-
     if ((!scrollbar && !eventTarget) || !(hitType & HitTestRequest::ReadOnly)) {
         IntPoint hitTestPoint = m_frame->view()->windowToContents(adjustedPoint);
         HitTestResult result = hitTestResultAtPoint(hitTestPoint, hitType | HitTestRequest::AllowFrameScrollbars);
@@ -2351,11 +2334,11 @@
     case PlatformEvent::GestureShowPress:
         return handleGestureShowPress();
     case PlatformEvent::GestureLongPress:
-        return handleGestureLongPress(gestureEvent);
+        return handleGestureLongPress(gestureEvent, adjustedPoint);
     case PlatformEvent::GestureLongTap:
-        return handleGestureLongTap(gestureEvent);
+        return handleGestureLongTap(gestureEvent, adjustedPoint);
     case PlatformEvent::GestureTwoFingerTap:
-        return handleGestureTwoFingerTap(gestureEvent);
+        return handleGestureTwoFingerTap(gestureEvent, adjustedPoint);
     case PlatformEvent::GestureTapDown:
     case PlatformEvent::GesturePinchBegin:
     case PlatformEvent::GesturePinchEnd:
@@ -2395,14 +2378,8 @@
     return defaultPrevented;
 }
 
-bool EventHandler::handleGestureLongPress(const PlatformGestureEvent& gestureEvent)
+bool EventHandler::handleGestureLongPress(const PlatformGestureEvent& gestureEvent, const IntPoint& adjustedPoint)
 {
-    IntPoint adjustedPoint = gestureEvent.position();
-    adjustGesturePosition(gestureEvent, adjustedPoint);
-    RefPtr<Frame> subframe = getSubFrameForGestureEvent(adjustedPoint, gestureEvent);
-    if (subframe && subframe->eventHandler().handleGestureLongPress(gestureEvent))
-        return true;
-
     m_longTapShouldInvokeContextMenu = false;
     if (m_frame->settings() && m_frame->settings()->touchDragDropEnabled() && m_frame->view()) {
         PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosition(), LeftButton, PlatformEvent::MousePressed, 1,
@@ -2444,13 +2421,8 @@
     return sendContextMenuEventForGesture(gestureEvent);
 }
 
-bool EventHandler::handleGestureLongTap(const PlatformGestureEvent& gestureEvent)
+bool EventHandler::handleGestureLongTap(const PlatformGestureEvent& gestureEvent, const IntPoint& adjustedPoint)
 {
-    IntPoint adjustedPoint = gestureEvent.position();
-    adjustGesturePosition(gestureEvent, adjustedPoint);
-    RefPtr<Frame> subframe = getSubFrameForGestureEvent(adjustedPoint, gestureEvent);
-    if (subframe && subframe->eventHandler().handleGestureLongTap(gestureEvent))
-        return true;
 #if !OS(ANDROID)
     if (m_longTapShouldInvokeContextMenu) {
         m_longTapShouldInvokeContextMenu = false;
@@ -2487,7 +2459,7 @@
     return false;
 }
 
-bool EventHandler::handleGestureTwoFingerTap(const PlatformGestureEvent& gestureEvent)
+bool EventHandler::handleGestureTwoFingerTap(const PlatformGestureEvent& gestureEvent, const IntPoint& adjustedPoint)
 {
     return sendContextMenuEventForGesture(gestureEvent);
 }
@@ -3219,13 +3191,9 @@
     return !dispatchDragEvent(eventType, dragState().m_dragSrc.get(), event, dragState().m_dragClipboard.get());
 }
 
-static bool exactlyOneBitSet(DragSourceAction n)
-{
-    return n && !(n & (n - 1));
-}
-
 bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, CheckDragHysteresis checkDragHysteresis)
 {
+    ASSERT(event.event().type() == PlatformEvent::MouseMoved);
     // Callers must protect the reference to FrameView, since this function may dispatch DOM
     // events, causing page/FrameView to go away.
     ASSERT(m_frame);
@@ -3242,58 +3210,27 @@
         return false;
     }
 
-    if (m_mouseDownMayStartDrag && !dragState().m_dragSrc) {
-        // try to find an element that wants to be dragged
-        HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::ConfusingAndOftenMisusedDisallowShadowContent);
+    if (m_mouseDownMayStartDrag) {
+        HitTestRequest request(HitTestRequest::ReadOnly);
         HitTestResult result(m_mouseDownPos);
         m_frame->contentRenderer()->hitTest(request, result);
         Node* node = result.innerNode();
-        if (node)
-            dragState().m_dragSrc = m_frame->page()->dragController().draggableNode(m_frame, node, m_mouseDownPos, dragState());
-        else
+        if (node) {
+            DragController::SelectionDragPolicy selectionDragPolicy = event.event().timestamp() - m_mouseDownTimestamp < TextDragDelay
+                ? DragController::DelayedSelectionDragResolution
+                : DragController::ImmediateSelectionDragResolution;
+            dragState().m_dragSrc = m_frame->page()->dragController().draggableNode(m_frame, node, m_mouseDownPos, selectionDragPolicy, dragState().m_dragType);
+        } else {
             dragState().m_dragSrc = 0;
+        }
 
         if (!dragState().m_dragSrc)
             m_mouseDownMayStartDrag = false; // no element is draggable
-        else
-            m_dragMayStartSelectionInstead = (dragState().m_dragType & DragSourceActionSelection);
-    }
-
-    // For drags starting in the selection, the user must wait between the mousedown and mousedrag,
-    // or else we bail on the dragging stuff and allow selection to occur
-    if (m_mouseDownMayStartDrag && m_dragMayStartSelectionInstead && (dragState().m_dragType & DragSourceActionSelection) && event.event().timestamp() - m_mouseDownTimestamp < TextDragDelay) {
-        ASSERT(event.event().type() == PlatformEvent::MouseMoved);
-        if ((dragState().m_dragType & DragSourceActionImage)) {
-            // ... unless the mouse is over an image, then we start dragging just the image
-            dragState().m_dragType = DragSourceActionImage;
-        } else if (!(dragState().m_dragType & (DragSourceActionDHTML | DragSourceActionLink))) {
-            // ... but only bail if we're not over an unselectable element.
-            m_mouseDownMayStartDrag = false;
-            dragState().m_dragSrc = 0;
-        } else {
-            // Prevent the following case from occuring:
-            // 1. User starts a drag immediately after mouse down over an unselectable element.
-            // 2. We enter this block and decided that since we're over an unselectable element,
-            //    don't cancel the drag.
-            // 3. The drag gets resolved as a potential selection drag below /but/ we haven't
-            //    exceeded the drag hysteresis yet.
-            // 4. We enter this block again, and since it's now marked as a selection drag, we
-            //    cancel the drag.
-            m_dragMayStartSelectionInstead = false;
-        }
     }
 
     if (!m_mouseDownMayStartDrag)
         return !mouseDownMayStartSelect() && !m_mouseDownMayStartAutoscroll;
 
-    if (!exactlyOneBitSet(dragState().m_dragType)) {
-        ASSERT((dragState().m_dragType & DragSourceActionSelection));
-        ASSERT((dragState().m_dragType & ~DragSourceActionSelection) == DragSourceActionDHTML
-                || (dragState().m_dragType & ~DragSourceActionSelection) == DragSourceActionImage
-                || (dragState().m_dragType & ~DragSourceActionSelection) == DragSourceActionLink);
-        dragState().m_dragType = DragSourceActionSelection;
-    }
-
     // We are starting a text/image/url drag, so the cursor should be an arrow
     // FIXME <rdar://7577595>: Custom cursors aren't supported during drag and drop (default to pointer).
     m_frame->view()->setCursor(pointerCursor());
@@ -3496,13 +3433,6 @@
     }
 }
 
-void EventHandler::sendResizeEvent()
-{
-    RefPtr<Event> event = Event::create(EventTypeNames::resize);
-    event->setTarget(m_frame->document()->domWindow());
-    m_frame->document()->scheduleAnimationFrameEvent(event.release());
-}
-
 void EventHandler::sendScrollEvent()
 {
     setFrameWasScrolledByUser();
@@ -3620,7 +3550,9 @@
         PlatformTouchPoint::State pointState = point.state();
         LayoutPoint pagePoint = documentPointForWindowPoint(m_frame, point.pos());
 
-        HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent;
+        // Gesture events trigger the active state, not touch events,
+        // so touch event hit tests can always be read only.
+        HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent | HitTestRequest::ReadOnly;
         // The HitTestRequest types used for mouse events map quite adequately
         // to touch events. Note that in addition to meaning that the hit test
         // should affect the active state of the current node if necessary,
@@ -3631,23 +3563,20 @@
             hitType |= HitTestRequest::Active;
             break;
         case PlatformTouchPoint::TouchMoved:
-            hitType |= HitTestRequest::Active | HitTestRequest::Move | HitTestRequest::ReadOnly;
+            hitType |= HitTestRequest::Active | HitTestRequest::Move;
             break;
         case PlatformTouchPoint::TouchReleased:
         case PlatformTouchPoint::TouchCancelled:
             hitType |= HitTestRequest::Release;
             break;
         case PlatformTouchPoint::TouchStationary:
-            hitType |= HitTestRequest::Active | HitTestRequest::ReadOnly;
+            hitType |= HitTestRequest::Active;
             break;
         default:
             ASSERT_NOT_REACHED();
             break;
         }
 
-        if (shouldGesturesTriggerActive())
-            hitType |= HitTestRequest::ReadOnly;
-
         // Increment the platform touch id by 1 to avoid storing a key of 0 in the hashmap.
         unsigned touchPointTargetKey = point.id() + 1;
         RefPtr<EventTarget> touchTarget;
@@ -3681,14 +3610,6 @@
             m_originatingTouchPointTargets.set(touchPointTargetKey, node);
             touchTarget = node;
         } else if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) {
-            // We only perform a hittest on release or cancel to unset :active or :hover state.
-            if (touchPointTargetKey == m_originatingTouchPointTargetKey) {
-                hitTestResultAtPoint(pagePoint, hitType);
-                m_originatingTouchPointTargetKey = 0;
-            } else if (m_originatingTouchPointDocument.get() && m_originatingTouchPointDocument->frame()) {
-                LayoutPoint pagePointInOriginatingDocument = documentPointForWindowPoint(m_originatingTouchPointDocument->frame(), point.pos());
-                hitTestResultInFrame(m_originatingTouchPointDocument->frame(), pagePointInOriginatingDocument, hitType);
-            }
             // The target should be the original target for this touch, so get it from the hashmap. As it's a release or cancel
             // we also remove it from the map.
             touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKey);
@@ -3808,18 +3729,18 @@
 bool EventHandler::handleMouseEventAsEmulatedGesture(const PlatformMouseEvent& event)
 {
     PlatformEvent::Type eventType = event.type();
-    Page* page = m_frame->page();
-    FrameView* view = m_frame->view();
-    if (event.button() != LeftButton || page->mainFrame() != m_frame)
+    if (event.button() != LeftButton || !m_frame->isMainFrame())
         return false;
 
     // Simulate pinch / scroll gesture.
     const IntPoint& position = event.position();
     bool swallowEvent = false;
 
+    FrameView* view = m_frame->view();
     if (event.shiftKey()) {
         // Shift pressed - consider it gesture.
         swallowEvent = true;
+        Page* page = m_frame->page();
         float pageScaleFactor = page->pageScaleFactor();
         switch (eventType) {
         case PlatformEvent::MousePressed:
diff --git a/Source/core/page/EventHandler.h b/Source/core/page/EventHandler.h
index 2fca448..f22e7fe 100644
--- a/Source/core/page/EventHandler.h
+++ b/Source/core/page/EventHandler.h
@@ -170,8 +170,7 @@
 
     void capsLockStateMayHaveChanged(); // Only called by FrameSelection
 
-    void sendResizeEvent(); // Only called in FrameView
-    void sendScrollEvent(); // Ditto
+    void sendScrollEvent(); // Only called in FrameView
 
     bool handleTouchEvent(const PlatformTouchEvent&);
 
@@ -200,9 +199,9 @@
     bool handlePasteGlobalSelection(const PlatformMouseEvent&);
 
     bool handleGestureTap(const PlatformGestureEvent&);
-    bool handleGestureLongPress(const PlatformGestureEvent&);
-    bool handleGestureLongTap(const PlatformGestureEvent&);
-    bool handleGestureTwoFingerTap(const PlatformGestureEvent&);
+    bool handleGestureLongPress(const PlatformGestureEvent&, const IntPoint& adjustedPoint);
+    bool handleGestureLongTap(const PlatformGestureEvent&, const IntPoint& adjustedPoint);
+    bool handleGestureTwoFingerTap(const PlatformGestureEvent&, const IntPoint& adjustedPoint);
     bool handleGestureScrollUpdate(const PlatformGestureEvent&);
     bool handleGestureScrollBegin(const PlatformGestureEvent&);
     void clearGestureScrollNodes();
@@ -303,7 +302,6 @@
 
     bool m_mouseDownMayStartSelect;
     bool m_mouseDownMayStartDrag;
-    bool m_dragMayStartSelectionInstead;
     bool m_mouseDownWasSingleClickInSelection;
     enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, ExtendedSelection };
     SelectionInitiationState m_selectionInitiationState;
diff --git a/Source/core/page/EventSource.cpp b/Source/core/page/EventSource.cpp
index 061c4d5..6a9600c 100644
--- a/Source/core/page/EventSource.cpp
+++ b/Source/core/page/EventSource.cpp
@@ -50,7 +50,7 @@
 #include "platform/network/ResourceError.h"
 #include "platform/network/ResourceRequest.h"
 #include "platform/network/ResourceResponse.h"
-#include "weborigin/SecurityOrigin.h"
+#include "platform/weborigin/SecurityOrigin.h"
 #include "wtf/text/StringBuilder.h"
 
 namespace WebCore {
@@ -63,7 +63,7 @@
     , m_withCredentials(false)
     , m_state(CONNECTING)
     , m_decoder(TextResourceDecoder::create("text/plain", "UTF-8"))
-    , m_reconnectTimer(this, &EventSource::reconnectTimerFired)
+    , m_connectTimer(this, &EventSource::connectTimerFired)
     , m_discardTrailingNewline(false)
     , m_requestInFlight(false)
     , m_reconnectDelay(defaultReconnectDelay)
@@ -72,16 +72,16 @@
     eventSourceInit.get("withCredentials", m_withCredentials);
 }
 
-PassRefPtr<EventSource> EventSource::create(ExecutionContext* context, const String& url, const Dictionary& eventSourceInit, ExceptionState& es)
+PassRefPtr<EventSource> EventSource::create(ExecutionContext* context, const String& url, const Dictionary& eventSourceInit, ExceptionState& exceptionState)
 {
     if (url.isEmpty()) {
-        es.throwDOMException(SyntaxError, "Cannot open an EventSource to an empty URL.");
+        exceptionState.throwDOMException(SyntaxError, "Cannot open an EventSource to an empty URL.");
         return 0;
     }
 
     KURL fullURL = context->completeURL(url);
     if (!fullURL.isValid()) {
-        es.throwDOMException(SyntaxError, "Cannot open an EventSource to '" + url + "'. The URL is invalid.");
+        exceptionState.throwDOMException(SyntaxError, "Cannot open an EventSource to '" + url + "'. The URL is invalid.");
         return 0;
     }
 
@@ -93,14 +93,14 @@
     }
     if (!shouldBypassMainWorldContentSecurityPolicy && !context->contentSecurityPolicy()->allowConnectToSource(fullURL)) {
         // We can safely expose the URL to JavaScript, as this exception is generate synchronously before any redirects take place.
-        es.throwSecurityError("Refused to connect to '" + fullURL.elidedString() + "' because it violates the document's Content Security Policy.");
+        exceptionState.throwSecurityError("Refused to connect to '" + fullURL.elidedString() + "' because it violates the document's Content Security Policy.");
         return 0;
     }
 
     RefPtr<EventSource> source = adoptRef(new EventSource(context, fullURL, eventSourceInit));
 
     source->setPendingActivity(source.get());
-    source->connect();
+    source->scheduleInitialConnect();
     source->suspendIfNeeded();
 
     return source.release();
@@ -112,6 +112,14 @@
     ASSERT(!m_requestInFlight);
 }
 
+void EventSource::scheduleInitialConnect()
+{
+    ASSERT(m_state == CONNECTING);
+    ASSERT(!m_requestInFlight);
+
+    m_connectTimer.startOneShot(0);
+}
+
 void EventSource::connect()
 {
     ASSERT(m_state == CONNECTING);
@@ -159,11 +167,11 @@
 void EventSource::scheduleReconnect()
 {
     m_state = CONNECTING;
-    m_reconnectTimer.startOneShot(m_reconnectDelay / 1000.0);
+    m_connectTimer.startOneShot(m_reconnectDelay / 1000.0);
     dispatchEvent(Event::create(EventTypeNames::error));
 }
 
-void EventSource::reconnectTimerFired(Timer<EventSource>*)
+void EventSource::connectTimerFired(Timer<EventSource>*)
 {
     connect();
 }
@@ -191,8 +199,8 @@
     }
 
     // Stop trying to reconnect if EventSource was explicitly closed or if ActiveDOMObject::stop() was called.
-    if (m_reconnectTimer.isActive()) {
-        m_reconnectTimer.stop();
+    if (m_connectTimer.isActive()) {
+        m_connectTimer.stop();
         unsetPendingActivity(this);
     }
 
@@ -306,9 +314,13 @@
 void EventSource::abortConnectionAttempt()
 {
     ASSERT(m_state == CONNECTING);
-    ASSERT(m_requestInFlight);
 
-    m_loader->cancel();
+    if (m_requestInFlight) {
+        m_loader->cancel();
+    } else {
+        m_state = CLOSED;
+        unsetPendingActivity(this);
+    }
 
     ASSERT(m_state == CLOSED);
     dispatchEvent(Event::create(EventTypeNames::error));
diff --git a/Source/core/page/EventSource.h b/Source/core/page/EventSource.h
index a290bde..66ea83a 100644
--- a/Source/core/page/EventSource.h
+++ b/Source/core/page/EventSource.h
@@ -37,7 +37,7 @@
 #include "core/events/EventTarget.h"
 #include "core/loader/ThreadableLoaderClient.h"
 #include "platform/Timer.h"
-#include "weborigin/KURL.h"
+#include "platform/weborigin/KURL.h"
 #include "wtf/RefPtr.h"
 #include "wtf/Vector.h"
 
@@ -96,10 +96,11 @@
     virtual void didFailAccessControlCheck(const ResourceError&);
     virtual void didFailRedirectCheck();
 
+    void scheduleInitialConnect();
     void connect();
     void networkRequestEnded();
     void scheduleReconnect();
-    void reconnectTimerFired(Timer<EventSource>*);
+    void connectTimerFired(Timer<EventSource>*);
     void abortConnectionAttempt();
     void parseEventStream();
     void parseEventStreamLine(unsigned pos, int fieldLength, int lineLength);
@@ -109,9 +110,9 @@
     bool m_withCredentials;
     State m_state;
 
-    RefPtr<TextResourceDecoder> m_decoder;
+    OwnPtr<TextResourceDecoder> m_decoder;
     RefPtr<ThreadableLoader> m_loader;
-    Timer<EventSource> m_reconnectTimer;
+    Timer<EventSource> m_connectTimer;
     Vector<UChar> m_receiveBuf;
     bool m_discardTrailingNewline;
     bool m_requestInFlight;
diff --git a/Source/core/page/EventSource.idl b/Source/core/page/EventSource.idl
index b43938d..fcf7dc1 100644
--- a/Source/core/page/EventSource.idl
+++ b/Source/core/page/EventSource.idl
@@ -34,7 +34,7 @@
     ActiveDOMObject,
     Constructor(DOMString url, optional Dictionary eventSourceInit),
     ConstructorCallWith=ExecutionContext,
-    ConstructorRaisesException
+    RaisesException=Constructor
 ] interface EventSource : EventTarget {
 
     readonly attribute DOMString URL; // Lowercased .url is the one in the spec, but leaving .URL for compatibility reasons.
diff --git a/Source/core/page/FocusController.cpp b/Source/core/page/FocusController.cpp
index 56871f6..be1d745 100644
--- a/Source/core/page/FocusController.cpp
+++ b/Source/core/page/FocusController.cpp
@@ -50,7 +50,7 @@
 #include "core/html/HTMLTextAreaElement.h"
 #include "core/html/shadow/HTMLShadowElement.h"
 #include "core/page/Chrome.h"
-#include "core/page/EditorClient.h"
+#include "core/page/ChromeClient.h"
 #include "core/page/EventHandler.h"
 #include "core/page/FrameTree.h"
 #include "core/page/Page.h"
@@ -165,6 +165,7 @@
     return element->isHTMLElement() && toHTMLElement(element)->hasCustomFocusLogic();
 }
 
+#if !ASSERT_DISABLED
 static inline bool isNonFocusableShadowHost(Node* node)
 {
     ASSERT(node);
@@ -173,6 +174,7 @@
     Element* element = toElement(node);
     return !element->isFocusable() && isShadowHost(element) && !hasCustomFocusLogic(element);
 }
+#endif
 
 static inline bool isNonKeyboardFocusableShadowHost(Node* node)
 {
@@ -466,7 +468,7 @@
 Node* FocusController::findNodeWithExactTabIndex(Node* start, int tabIndex, FocusDirection direction)
 {
     // Search is inclusive of start
-    for (Node* node = start; node; node = direction == FocusDirectionForward ? NodeTraversal::next(node) : NodeTraversal::previous(node)) {
+    for (Node* node = start; node; node = direction == FocusDirectionForward ? NodeTraversal::next(*node) : NodeTraversal::previous(*node)) {
         if (shouldVisit(node) && adjustedTabIndex(node) == tabIndex)
             return node;
     }
@@ -478,7 +480,7 @@
     // Search is inclusive of start
     int winningTabIndex = std::numeric_limits<short>::max() + 1;
     Node* winner = 0;
-    for (Node* node = start; node; node = NodeTraversal::next(node)) {
+    for (Node* node = start; node; node = NodeTraversal::next(*node)) {
         if (shouldVisit(node) && node->tabIndex() > tabIndex && node->tabIndex() < winningTabIndex) {
             winner = node;
             winningTabIndex = node->tabIndex();
@@ -493,7 +495,7 @@
     // Search is inclusive of start
     int winningTabIndex = 0;
     Node* winner = 0;
-    for (Node* node = start; node; node = NodeTraversal::previous(node)) {
+    for (Node* node = start; node; node = NodeTraversal::previous(*node)) {
         int currentTabIndex = adjustedTabIndex(node);
         if ((shouldVisit(node) || isNonKeyboardFocusableShadowHost(node)) && currentTabIndex < tabIndex && currentTabIndex > winningTabIndex) {
             winner = node;
@@ -509,14 +511,14 @@
         int tabIndex = adjustedTabIndex(start);
         // If a node is excluded from the normal tabbing cycle, the next focusable node is determined by tree order
         if (tabIndex < 0) {
-            for (Node* node = NodeTraversal::next(start); node; node = NodeTraversal::next(node)) {
+            for (Node* node = NodeTraversal::next(*start); node; node = NodeTraversal::next(*node)) {
                 if (shouldVisit(node) && adjustedTabIndex(node) >= 0)
                     return node;
             }
         }
 
         // First try to find a node with the same tabindex as start that comes after start in the scope.
-        if (Node* winner = findNodeWithExactTabIndex(NodeTraversal::next(start), tabIndex, FocusDirectionForward))
+        if (Node* winner = findNodeWithExactTabIndex(NodeTraversal::next(*start), tabIndex, FocusDirectionForward))
             return winner;
 
         if (!tabIndex)
@@ -547,7 +549,7 @@
     Node* startingNode;
     int startingTabIndex;
     if (start) {
-        startingNode = NodeTraversal::previous(start);
+        startingNode = NodeTraversal::previous(*start);
         startingTabIndex = adjustedTabIndex(start);
     } else {
         startingNode = last;
@@ -556,7 +558,7 @@
 
     // However, if a node is excluded from the normal tabbing cycle, the previous focusable node is determined by tree order
     if (startingTabIndex < 0) {
-        for (Node* node = startingNode; node; node = NodeTraversal::previous(node)) {
+        for (Node* node = startingNode; node; node = NodeTraversal::previous(*node)) {
             if (shouldVisit(node) && adjustedTabIndex(node) >= 0)
                 return node;
         }
@@ -622,28 +624,26 @@
     RefPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame->document() : 0;
 
     Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : 0;
-    if (oldFocusedElement == element)
+    if (element && oldFocusedElement == element)
         return true;
 
     // FIXME: Might want to disable this check for caretBrowsing
     if (oldFocusedElement && oldFocusedElement->isRootEditableElement() && !relinquishesEditingFocus(oldFocusedElement))
         return false;
 
-    m_page->editorClient().willSetInputMethodState();
+    m_page->chrome().client().willSetInputMethodState();
 
-    clearSelectionIfNeeded(oldFocusedFrame.get(), newFocusedFrame.get(), element);
-
-    if (!element) {
-        if (oldDocument)
-            oldDocument->setFocusedElement(0);
-        return true;
-    }
-
-    RefPtr<Document> newDocument(element->document());
+    RefPtr<Document> newDocument;
+    if (element)
+        newDocument = &element->document();
+    else if (newFocusedFrame)
+        newDocument = newFocusedFrame->document();
 
     if (newDocument && newDocument->focusedElement() == element)
         return true;
 
+    clearSelectionIfNeeded(oldFocusedFrame.get(), newFocusedFrame.get(), element);
+
     if (oldDocument && oldDocument != newDocument)
         oldDocument->setFocusedElement(0);
 
@@ -767,9 +767,8 @@
         closest = candidate;
 }
 
-void FocusController::findFocusCandidateInContainer(Node* container, const LayoutRect& startingRect, FocusDirection direction, FocusCandidate& closest)
+void FocusController::findFocusCandidateInContainer(Node& container, const LayoutRect& startingRect, FocusDirection direction, FocusCandidate& closest)
 {
-    ASSERT(container);
     Element* focusedElement = (focusedFrame() && focusedFrame()->document()) ? focusedFrame()->document()->focusedElement() : 0;
 
     Element* element = ElementTraversal::firstWithin(container);
@@ -779,8 +778,8 @@
     current.visibleNode = focusedElement;
 
     for (; element; element = (element->isFrameOwnerElement() || canScrollInDirection(element, direction))
-        ? ElementTraversal::nextSkippingChildren(element, container)
-        : ElementTraversal::next(element, container)) {
+        ? ElementTraversal::nextSkippingChildren(*element, &container)
+        : ElementTraversal::next(*element, &container)) {
         if (element == focusedElement)
             continue;
 
@@ -791,7 +790,7 @@
         if (candidate.isNull())
             continue;
 
-        candidate.enclosingScrollableBox = container;
+        candidate.enclosingScrollableBox = &container;
         updateFocusCandidateIfNeeded(direction, current, candidate, closest);
     }
 }
@@ -808,7 +807,7 @@
 
     // Find the closest node within current container in the direction of the navigation.
     FocusCandidate focusCandidate;
-    findFocusCandidateInContainer(container, newStartingRect, direction, focusCandidate);
+    findFocusCandidateInContainer(*container, newStartingRect, direction, focusCandidate);
 
     if (focusCandidate.isNull()) {
         // Nothing to focus, scroll if possible.
diff --git a/Source/core/page/FocusController.h b/Source/core/page/FocusController.h
index 8abdb66..38069eb 100644
--- a/Source/core/page/FocusController.h
+++ b/Source/core/page/FocusController.h
@@ -112,7 +112,7 @@
     Node* findNodeWithExactTabIndex(Node* start, int tabIndex, FocusDirection);
 
     bool advanceFocusDirectionallyInContainer(Node* container, const LayoutRect& startingRect, FocusDirection);
-    void findFocusCandidateInContainer(Node* container, const LayoutRect& startingRect, FocusDirection, FocusCandidate& closest);
+    void findFocusCandidateInContainer(Node& container, const LayoutRect& startingRect, FocusDirection, FocusCandidate& closest);
 
     Page* m_page;
     RefPtr<Frame> m_focusedFrame;
diff --git a/Source/core/page/Page.cpp b/Source/core/page/Page.cpp
index 57dfbb0..849418f 100644
--- a/Source/core/page/Page.cpp
+++ b/Source/core/page/Page.cpp
@@ -25,6 +25,7 @@
 #include "core/dom/StyleEngine.h"
 #include "core/dom/VisitedLinkState.h"
 #include "core/editing/Caret.h"
+#include "core/editing/UndoStack.h"
 #include "core/events/Event.h"
 #include "core/events/ThreadLocalEventNames.h"
 #include "core/frame/DOMTimer.h"
@@ -50,10 +51,10 @@
 #include "core/page/Settings.h"
 #include "core/page/ValidationMessageClient.h"
 #include "core/page/scrolling/ScrollingCoordinator.h"
-#include "core/plugins/PluginData.h"
 #include "core/rendering/RenderView.h"
 #include "core/storage/StorageNamespace.h"
 #include "core/workers/SharedWorkerRepositoryClient.h"
+#include "platform/plugins/PluginData.h"
 #include "wtf/HashMap.h"
 #include "wtf/RefCountedLeakCounter.h"
 #include "wtf/StdLibExtras.h"
@@ -104,19 +105,21 @@
     , m_contextMenuController(ContextMenuController::create(this, pageClients.contextMenuClient))
     , m_inspectorController(InspectorController::create(this, pageClients.inspectorClient))
     , m_pointerLockController(PointerLockController::create(this))
+    , m_history(adoptPtr(new HistoryController(this)))
     , m_settings(Settings::create(this))
     , m_progress(ProgressTracker::create())
+    , m_undoStack(UndoStack::create())
     , m_backForwardClient(pageClients.backForwardClient)
     , m_editorClient(pageClients.editorClient)
     , m_validationMessageClient(0)
     , m_sharedWorkerRepositoryClient(0)
+    , m_spellCheckerClient(pageClients.spellCheckerClient)
     , m_subframeCount(0)
     , m_openedByDOM(false)
     , m_tabKeyCyclesThroughElements(true)
     , m_defersLoading(false)
     , m_pageScaleFactor(1)
     , m_deviceScaleFactor(1)
-    , m_didLoadUserStyleSheet(false)
     , m_group(0)
     , m_timerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval())
     , m_visibilityState(PageVisibilityStateVisible)
@@ -222,18 +225,6 @@
     m_openedByDOM = true;
 }
 
-void Page::goToItem(HistoryItem* item)
-{
-    // stopAllLoaders may end up running onload handlers, which could cause further history traversals that may lead to the passed in HistoryItem
-    // being deref()-ed. Make sure we can still use it with HistoryController::goToItem later.
-    RefPtr<HistoryItem> protector(item);
-
-    if (m_mainFrame->loader().history()->shouldStopLoadingForHistoryItem(item))
-        m_mainFrame->loader().stopAllLoaders();
-
-    m_mainFrame->loader().history()->goToItem(item);
-}
-
 void Page::clearPageGroup()
 {
     if (!m_group)
@@ -247,9 +238,6 @@
     clearPageGroup();
 
     switch (type) {
-    case InspectorPageGroup:
-        m_group = PageGroup::inspectorGroup();
-        break;
     case PrivatePageGroup:
         m_group = PageGroup::create();
         break;
@@ -341,6 +329,7 @@
         return;
 
     m_defersLoading = defers;
+    m_history->setDefersLoading(defers);
     for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext())
         frame->loader().setDefersLoading(defers);
 }
@@ -390,36 +379,6 @@
     setNeedsRecalcStyleInAllFrames();
 }
 
-void Page::userStyleSheetLocationChanged()
-{
-    // FIXME: Eventually we will move to a model of just being handed the sheet
-    // text instead of loading the URL ourselves.
-    KURL url = m_settings->userStyleSheetLocation();
-
-    m_didLoadUserStyleSheet = false;
-    m_userStyleSheet = String();
-
-    // Data URLs with base64-encoded UTF-8 style sheets are common. We can process them
-    // synchronously and avoid using a loader.
-    if (url.protocolIsData() && url.string().startsWith("data:text/css;charset=utf-8;base64,")) {
-        m_didLoadUserStyleSheet = true;
-
-        Vector<char> styleSheetAsUTF8;
-        if (base64Decode(decodeURLEscapeSequences(url.string().substring(35)), styleSheetAsUTF8, Base64IgnoreWhitespace))
-            m_userStyleSheet = String::fromUTF8(styleSheetAsUTF8.data(), styleSheetAsUTF8.size());
-    }
-
-    for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext()) {
-        if (frame->document())
-            frame->document()->styleEngine()->updatePageUserSheet();
-    }
-}
-
-const String& Page::userStyleSheet() const
-{
-    return m_userStyleSheet;
-}
-
 void Page::allVisitedStateChanged(PageGroup* group)
 {
     ASSERT(group);
@@ -544,7 +503,7 @@
 
 PageLifecycleNotifier& Page::lifecycleNotifier()
 {
-    return static_cast<PageLifecycleNotifier&>(LifecycleContext::lifecycleNotifier());
+    return static_cast<PageLifecycleNotifier&>(LifecycleContext<Page>::lifecycleNotifier());
 }
 
 PassOwnPtr<LifecycleNotifier<Page> > Page::createLifecycleNotifier()
@@ -559,6 +518,7 @@
     , dragClient(0)
     , inspectorClient(0)
     , backForwardClient(0)
+    , spellCheckerClient(0)
 {
 }
 
diff --git a/Source/core/page/Page.h b/Source/core/page/Page.h
index c29caa8..79bad5f 100644
--- a/Source/core/page/Page.h
+++ b/Source/core/page/Page.h
@@ -23,7 +23,8 @@
 
 #include "core/dom/ViewportDescription.h"
 #include "core/page/PageVisibilityState.h"
-#include "core/page/UseCounter.h"
+#include "core/frame/UseCounter.h"
+#include "core/loader/HistoryController.h"
 #include "core/rendering/Pagination.h"
 #include "platform/LifecycleContext.h"
 #include "platform/Supplementable.h"
@@ -72,7 +73,9 @@
 class ScrollingCoordinator;
 class Settings;
 class SharedWorkerRepositoryClient;
+class SpellCheckerClient;
 class StorageNamespace;
+class UndoStack;
 class ValidationMessageClient;
 
 typedef uint64_t LinkHash;
@@ -98,6 +101,7 @@
         DragClient* dragClient;
         InspectorClient* inspectorClient;
         BackForwardClient* backForwardClient;
+        SpellCheckerClient* spellCheckerClient;
     };
 
     explicit Page(PageClients&);
@@ -111,6 +115,10 @@
     PluginData* pluginData() const;
 
     EditorClient& editorClient() const { return *m_editorClient; }
+    SpellCheckerClient& spellCheckerClient() const { return *m_spellCheckerClient; }
+    UndoStack& undoStack() const { return *m_undoStack; }
+
+    HistoryController* history() const { return m_history.get(); }
 
     void setMainFrame(PassRefPtr<Frame>);
     Frame* mainFrame() const { return m_mainFrame.get(); }
@@ -120,11 +128,7 @@
     bool openedByDOM() const;
     void setOpenedByDOM();
 
-    // DEPRECATED. Use backForward() instead of the following function.
-    void goToItem(HistoryItem*);
-
-    // FIXME: InspectorPageGroup is only needed to support single process debugger layout tests, it should be removed when DumpRenderTree is gone.
-    enum PageGroupType { InspectorPageGroup, PrivatePageGroup, SharedPageGroup };
+    enum PageGroupType { PrivatePageGroup, SharedPageGroup };
     void setGroupType(PageGroupType);
     void clearPageGroup();
     PageGroup& group()
@@ -183,9 +187,6 @@
     const Pagination& pagination() const { return m_pagination; }
     void setPagination(const Pagination&);
 
-    void userStyleSheetLocationChanged();
-    const String& userStyleSheet() const;
-
     void dnsPrefetchingStateChanged();
 
     static void allVisitedStateChanged(PageGroup*);
@@ -252,8 +253,10 @@
     const OwnPtr<PointerLockController> m_pointerLockController;
     RefPtr<ScrollingCoordinator> m_scrollingCoordinator;
 
+    const OwnPtr<HistoryController> m_history;
     const OwnPtr<Settings> m_settings;
     const OwnPtr<ProgressTracker> m_progress;
+    const OwnPtr<UndoStack> m_undoStack;
 
     RefPtr<Frame> m_mainFrame;
 
@@ -263,6 +266,7 @@
     EditorClient* const m_editorClient;
     ValidationMessageClient* m_validationMessageClient;
     SharedWorkerRepositoryClient* m_sharedWorkerRepositoryClient;
+    SpellCheckerClient* const m_spellCheckerClient;
 
     UseCounter m_useCounter;
 
@@ -277,9 +281,6 @@
 
     Pagination m_pagination;
 
-    String m_userStyleSheet;
-    bool m_didLoadUserStyleSheet;
-
     RefPtr<PageGroup> m_group;
 
     OwnPtr<StorageNamespace> m_sessionStorage;
diff --git a/Source/core/page/PageGroup.cpp b/Source/core/page/PageGroup.cpp
index c163264..b4a7271 100644
--- a/Source/core/page/PageGroup.cpp
+++ b/Source/core/page/PageGroup.cpp
@@ -30,6 +30,7 @@
 #include "core/dom/StyleEngine.h"
 #include "core/frame/Frame.h"
 #include "core/page/Page.h"
+#include "wtf/StdLibExtras.h"
 
 namespace WebCore {
 
@@ -44,16 +45,10 @@
 
 PageGroup* PageGroup::sharedGroup()
 {
-    static PageGroup* staticSharedGroup = create().leakRef();
+    DEFINE_STATIC_REF(PageGroup, staticSharedGroup, (create()));
     return staticSharedGroup;
 }
 
-PageGroup* PageGroup::inspectorGroup()
-{
-    static PageGroup* staticInspectorGroup = create().leakRef();
-    return staticInspectorGroup;
-}
-
 void PageGroup::addPage(Page* page)
 {
     ASSERT(page);
diff --git a/Source/core/page/PageGroup.h b/Source/core/page/PageGroup.h
index 0c7fb0d..65b24a1 100644
--- a/Source/core/page/PageGroup.h
+++ b/Source/core/page/PageGroup.h
@@ -46,7 +46,6 @@
 
         static PassRefPtr<PageGroup> create() { return adoptRef(new PageGroup()); }
         static PageGroup* sharedGroup();
-        static PageGroup* inspectorGroup();
 
         const HashSet<Page*>& pages() const { return m_pages; }
 
diff --git a/Source/core/page/PageLifecycleNotifier.cpp b/Source/core/page/PageLifecycleNotifier.cpp
index a48592b..d573334 100644
--- a/Source/core/page/PageLifecycleNotifier.cpp
+++ b/Source/core/page/PageLifecycleNotifier.cpp
@@ -30,7 +30,7 @@
 namespace WebCore {
 
 PageLifecycleNotifier::PageLifecycleNotifier(Page* context)
-    : LifecycleNotifier(context)
+    : LifecycleNotifier<Page>(context)
 {
 }
 
@@ -41,7 +41,7 @@
         m_pageObservers.add(static_cast<PageLifecycleObserver*>(observer));
     }
 
-    LifecycleNotifier::addObserver(observer);
+    LifecycleNotifier<Page>::addObserver(observer);
 }
 
 void PageLifecycleNotifier::removeObserver(PageLifecycleNotifier::Observer* observer)
@@ -51,7 +51,7 @@
         m_pageObservers.remove(static_cast<PageLifecycleObserver*>(observer));
     }
 
-    LifecycleNotifier::removeObserver(observer);
+    LifecycleNotifier<Page>::removeObserver(observer);
 }
 
 } // namespace WebCore
diff --git a/Source/core/page/PageLifecycleObserver.cpp b/Source/core/page/PageLifecycleObserver.cpp
index 040dccc..ce6c819 100644
--- a/Source/core/page/PageLifecycleObserver.cpp
+++ b/Source/core/page/PageLifecycleObserver.cpp
@@ -42,7 +42,7 @@
 }
 
 PageLifecycleObserver::PageLifecycleObserver(Page* page)
-    : LifecycleObserver(page, PageLifecycleObserverType)
+    : LifecycleObserver<Page>(page, PageLifecycleObserverType)
 {
 }
 
diff --git a/Source/core/page/PagePopupController.cpp b/Source/core/page/PagePopupController.cpp
index ba31b02..961d96e 100644
--- a/Source/core/page/PagePopupController.cpp
+++ b/Source/core/page/PagePopupController.cpp
@@ -74,7 +74,6 @@
     return numberString;
 }
 
-#if ENABLE(CALENDAR_PICKER)
 String PagePopupController::formatMonth(int year, int zeroBaseMonth)
 {
     if (!m_popupClient)
@@ -92,7 +91,6 @@
     date.setMonthsSinceEpoch((year - 1970) * 12.0 + zeroBaseMonth);
     return m_popupClient->locale().formatDateTime(date, Locale::FormatTypeShort);
 }
-#endif
 
 void PagePopupController::clearPagePopupClient()
 {
@@ -101,7 +99,7 @@
 
 void PagePopupController::histogramEnumeration(const String& name, int sample, int boundaryValue)
 {
-    WebKit::Platform::current()->histogramEnumeration(name.utf8().data(), sample, boundaryValue);
+    blink::Platform::current()->histogramEnumeration(name.utf8().data(), sample, boundaryValue);
 }
 
 }
diff --git a/Source/core/page/PagePopupController.h b/Source/core/page/PagePopupController.h
index 398fa4e..7a4846f 100644
--- a/Source/core/page/PagePopupController.h
+++ b/Source/core/page/PagePopupController.h
@@ -46,10 +46,8 @@
     void setValue(const String&);
     void closePopup();
     String localizeNumberString(const String&);
-#if ENABLE(CALENDAR_PICKER)
     String formatMonth(int year, int zeroBaseMonth);
     String formatShortMonth(int year, int zeroBaseMonth);
-#endif
     void clearPagePopupClient();
     void histogramEnumeration(const String& name, int sample, int boundaryValue);
 
diff --git a/Source/core/page/PagePopupController.idl b/Source/core/page/PagePopupController.idl
index 069098c..0a4fbd4 100644
--- a/Source/core/page/PagePopupController.idl
+++ b/Source/core/page/PagePopupController.idl
@@ -36,7 +36,7 @@
     void setValue(DOMString value);
     void closePopup();
     DOMString localizeNumberString(DOMString numberString);
-    [Conditional=CALENDAR_PICKER] DOMString formatMonth(long year, long zeroBaseMonth);
-    [Conditional=CALENDAR_PICKER] DOMString formatShortMonth(long year, long zeroBaseMonth);
+    DOMString formatMonth(long year, long zeroBaseMonth);
+    DOMString formatShortMonth(long year, long zeroBaseMonth);
     void histogramEnumeration(DOMString name, long sample, long boundaryValue);
 };
diff --git a/Source/core/page/PageSerializer.h b/Source/core/page/PageSerializer.h
index 93a4dc1..745af7e 100644
--- a/Source/core/page/PageSerializer.h
+++ b/Source/core/page/PageSerializer.h
@@ -31,8 +31,8 @@
 #ifndef PageSerializer_h
 #define PageSerializer_h
 
-#include "weborigin/KURL.h"
-#include "weborigin/KURLHash.h"
+#include "platform/weborigin/KURL.h"
+#include "platform/weborigin/KURLHash.h"
 #include "wtf/HashMap.h"
 #include "wtf/ListHashSet.h"
 #include "wtf/Vector.h"
diff --git a/Source/core/page/PageVisibilityState.cpp b/Source/core/page/PageVisibilityState.cpp
index 630b0db..4b015df 100644
--- a/Source/core/page/PageVisibilityState.cpp
+++ b/Source/core/page/PageVisibilityState.cpp
@@ -38,7 +38,6 @@
     DEFINE_STATIC_LOCAL(const String, visible, ("visible"));
     DEFINE_STATIC_LOCAL(const String, hidden, ("hidden"));
     DEFINE_STATIC_LOCAL(const String, prerender, ("prerender"));
-    DEFINE_STATIC_LOCAL(const String, preview, ("preview"));
 
     switch (state) {
     case PageVisibilityStateVisible:
@@ -47,8 +46,6 @@
         return hidden;
     case PageVisibilityStatePrerender:
         return prerender;
-    case PageVisibilityStatePreview:
-        return preview;
     }
 
     ASSERT_NOT_REACHED();
diff --git a/Source/core/page/PageVisibilityState.h b/Source/core/page/PageVisibilityState.h
index 229b22f..cd09a2a 100644
--- a/Source/core/page/PageVisibilityState.h
+++ b/Source/core/page/PageVisibilityState.h
@@ -41,7 +41,6 @@
     PageVisibilityStateVisible,
     PageVisibilityStateHidden,
     PageVisibilityStatePrerender,
-    PageVisibilityStatePreview
 };
 
 String pageVisibilityStateString(PageVisibilityState);
diff --git a/Source/core/page/Settings.cpp b/Source/core/page/Settings.cpp
index 53aae2d..c341480 100644
--- a/Source/core/page/Settings.cpp
+++ b/Source/core/page/Settings.cpp
@@ -113,7 +113,7 @@
 Settings::Settings(Page* page)
     : m_page(0)
     , m_mediaTypeOverride("screen")
-    , m_textAutosizingFontScaleFactor(1)
+    , m_accessibilityFontScaleFactor(1)
     , m_deviceScaleAdjustment(1.0f)
 #if HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP
     , m_textAutosizingWindowSizeOverride(320, 480)
@@ -133,7 +133,9 @@
     , m_touchEventEmulationEnabled(false)
     , m_openGLMultisamplingEnabled(false)
     , m_viewportEnabled(false)
+    , m_viewportMetaEnabled(false)
     , m_compositorDrivenAcceleratedScrollingEnabled(false)
+    , m_layerSquashingEnabled(false)
     , m_setImageLoadingSettingsTimer(this, &Settings::imageLoadingSettingsTimerFired)
 {
     m_page = page; // Page is not yet fully initialized wen constructing Settings, so keeping m_page null over initializeDefaultFontFamilies() call.
@@ -230,11 +232,6 @@
     return InspectorInstrumentation::overrideTextAutosizing(m_page, m_textAutosizingEnabled);
 }
 
-float Settings::textAutosizingFontScaleFactor() const
-{
-    return InspectorInstrumentation::overrideTextAutosizingFontScaleFactor(m_page, m_textAutosizingFontScaleFactor);
-}
-
 void Settings::setTextAutosizingWindowSizeOverride(const IntSize& textAutosizingWindowSizeOverride)
 {
     if (m_textAutosizingWindowSizeOverride == textAutosizingWindowSizeOverride)
@@ -273,9 +270,9 @@
     m_page->setNeedsRecalcStyleInAllFrames();
 }
 
-void Settings::setTextAutosizingFontScaleFactor(float fontScaleFactor)
+void Settings::setAccessibilityFontScaleFactor(float fontScaleFactor)
 {
-    m_textAutosizingFontScaleFactor = fontScaleFactor;
+    m_accessibilityFontScaleFactor = fontScaleFactor;
     recalculateTextAutosizingMultipliers();
 }
 
@@ -285,6 +282,11 @@
     recalculateTextAutosizingMultipliers();
 }
 
+float Settings::deviceScaleAdjustment() const
+{
+    return InspectorInstrumentation::overrideFontScaleFactor(m_page, m_deviceScaleAdjustment);
+}
+
 void Settings::setMediaTypeOverride(const String& mediaTypeOverride)
 {
     if (m_mediaTypeOverride == mediaTypeOverride)
@@ -355,16 +357,6 @@
     m_arePluginsEnabled = arePluginsEnabled;
 }
 
-void Settings::setUserStyleSheetLocation(const KURL& userStyleSheetLocation)
-{
-    if (m_userStyleSheetLocation == userStyleSheetLocation)
-        return;
-
-    m_userStyleSheetLocation = userStyleSheetLocation;
-
-    m_page->userStyleSheetLocationChanged();
-}
-
 void Settings::setDNSPrefetchingEnabled(bool dnsPrefetchingEnabled)
 {
     if (m_dnsPrefetchingEnabled == dnsPrefetchingEnabled)
@@ -403,9 +395,17 @@
     if (m_viewportEnabled == enabled)
         return;
 
+    // FIXME: Remove once Chromium-side lands.
+    setViewportMetaEnabled(enabled);
+
     m_viewportEnabled = enabled;
     if (m_page->mainFrame())
         m_page->mainFrame()->document()->updateViewportDescription();
 }
 
+void Settings::setViewportMetaEnabled(bool enabled)
+{
+    m_viewportMetaEnabled = enabled;
+}
+
 } // namespace WebCore
diff --git a/Source/core/page/Settings.h b/Source/core/page/Settings.h
index 86bfa9f..59a2add 100644
--- a/Source/core/page/Settings.h
+++ b/Source/core/page/Settings.h
@@ -31,7 +31,7 @@
 #include "core/editing/EditingBehaviorTypes.h"
 #include "platform/Timer.h"
 #include "platform/geometry/IntSize.h"
-#include "weborigin/KURL.h"
+#include "platform/weborigin/KURL.h"
 #include "wtf/HashMap.h"
 #include "wtf/text/AtomicString.h"
 #include "wtf/text/AtomicStringHash.h"
@@ -88,14 +88,15 @@
     void setTextAutosizingEnabled(bool);
     bool textAutosizingEnabled() const;
 
-    void setTextAutosizingFontScaleFactor(float);
-    float textAutosizingFontScaleFactor() const;
+    // Font scale factor for accessibility, applied as part of text autosizing.
+    void setAccessibilityFontScaleFactor(float);
+    float accessibilityFontScaleFactor() const { return m_accessibilityFontScaleFactor; }
 
     // Compensates for poor text legibility on mobile devices. This value is
     // multiplied by the font scale factor when performing text autosizing of
     // websites that do not set an explicit viewport description.
     void setDeviceScaleAdjustment(float);
-    float deviceScaleAdjustment() const { return m_deviceScaleAdjustment; }
+    float deviceScaleAdjustment() const;
 
     // Only set by Layout Tests, and only used if textAutosizingEnabled() returns true.
     void setTextAutosizingWindowSizeOverride(const IntSize&);
@@ -139,9 +140,6 @@
     void setDNSPrefetchingEnabled(bool);
     bool dnsPrefetchingEnabled() const { return m_dnsPrefetchingEnabled; }
 
-    void setUserStyleSheetLocation(const KURL&);
-    const KURL& userStyleSheetLocation() const { return m_userStyleSheetLocation; }
-
     static void setMockScrollbarsEnabled(bool flag);
     static bool mockScrollbarsEnabled();
 
@@ -154,18 +152,30 @@
     void setViewportEnabled(bool);
     bool viewportEnabled() const { return m_viewportEnabled; }
 
+    void setViewportMetaEnabled(bool);
+    bool viewportMetaEnabled() const
+    {
+        // FIXME: Remove and uncomment once chromium side changes land.
+        return true;
+        // return m_viewportMetaEnabled;
+    }
+
     // FIXME: This is a temporary flag and should be removed once accelerated
     // overflow scroll is ready (crbug.com/254111).
     void setCompositorDrivenAcceleratedScrollingEnabled(bool enabled) { m_compositorDrivenAcceleratedScrollingEnabled = enabled; }
     bool isCompositorDrivenAcceleratedScrollingEnabled() const { return m_compositorDrivenAcceleratedScrollingEnabled; }
 
+    // FIXME: This is a temporary flag and should be removed when squashing is ready.
+    // (crbug.com/261605)
+    void setLayerSquashingEnabled(bool enabled) { m_layerSquashingEnabled = enabled; }
+    bool isLayerSquashingEnabled() const { return m_layerSquashingEnabled; }
+
 private:
     explicit Settings(Page*);
 
     Page* m_page;
 
     String m_mediaTypeOverride;
-    KURL m_userStyleSheetLocation;
     ScriptFontFamilyMap m_standardFontFamilyMap;
     ScriptFontFamilyMap m_serifFontFamilyMap;
     ScriptFontFamilyMap m_fixedFontFamilyMap;
@@ -173,7 +183,7 @@
     ScriptFontFamilyMap m_cursiveFontFamilyMap;
     ScriptFontFamilyMap m_fantasyFontFamilyMap;
     ScriptFontFamilyMap m_pictographFontFamilyMap;
-    float m_textAutosizingFontScaleFactor;
+    float m_accessibilityFontScaleFactor;
     float m_deviceScaleAdjustment;
     IntSize m_textAutosizingWindowSizeOverride;
     bool m_textAutosizingEnabled : 1;
@@ -192,11 +202,15 @@
     bool m_touchEventEmulationEnabled : 1;
     bool m_openGLMultisamplingEnabled : 1;
     bool m_viewportEnabled : 1;
+    bool m_viewportMetaEnabled : 1;
 
     // FIXME: This is a temporary flag and should be removed once accelerated
     // overflow scroll is ready (crbug.com/254111).
     bool m_compositorDrivenAcceleratedScrollingEnabled : 1;
 
+    // FIXME: This is a temporary flag and should be removed when squashing is ready.
+    bool m_layerSquashingEnabled : 1;
+
     Timer<Settings> m_setImageLoadingSettingsTimer;
     void imageLoadingSettingsTimerFired(Timer<Settings>*);
     void recalculateTextAutosizingMultipliers();
diff --git a/Source/core/page/Settings.in b/Source/core/page/Settings.in
index 47b3187..4d21a27 100644
--- a/Source/core/page/Settings.in
+++ b/Source/core/page/Settings.in
@@ -72,7 +72,6 @@
 shouldPrintBackgrounds initial=false
 
 textAreasAreResizable initial=false, setNeedsStyleRecalcInAllFrames=1
-authorAndUserStylesEnabled initial=true, setNeedsStyleRecalcInAllFrames=1
 acceleratedCompositingEnabled initial=true, setNeedsStyleRecalcInAllFrames=1
 
 # Debugging feature used for accelerated compositing layers.
diff --git a/Source/core/page/SpellCheckerClient.h b/Source/core/page/SpellCheckerClient.h
new file mode 100644
index 0000000..73a49e5
--- /dev/null
+++ b/Source/core/page/SpellCheckerClient.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SpellCheckerClient_h
+#define SpellCheckerClient_h
+
+#include "wtf/Forward.h"
+
+namespace WebCore {
+
+class TextCheckerClient;
+
+class SpellCheckerClient {
+public:
+    virtual ~SpellCheckerClient() { }
+
+    virtual bool isContinuousSpellCheckingEnabled() = 0;
+    virtual void toggleContinuousSpellChecking() = 0;
+    virtual bool isGrammarCheckingEnabled() = 0;
+
+    virtual TextCheckerClient& textChecker() = 0;
+
+    virtual void updateSpellingUIWithMisspelledWord(const WTF::String&) = 0;
+    virtual void showSpellingUI(bool show) = 0;
+    virtual bool spellingUIIsShowing() = 0;
+};
+
+}
+
+#endif // SpellCheckerClient_h
diff --git a/Source/core/page/TouchDisambiguation.cpp b/Source/core/page/TouchDisambiguation.cpp
index 019e61f..5fda7d8d 100644
--- a/Source/core/page/TouchDisambiguation.cpp
+++ b/Source/core/page/TouchDisambiguation.cpp
@@ -59,11 +59,11 @@
     while (node) {
         // Skip the whole sub-tree if the node doesn't propagate events.
         if (node != eventNode && node->willRespondToMouseClickEvents()) {
-            node = NodeTraversal::nextSkippingChildren(node, eventNode);
+            node = NodeTraversal::nextSkippingChildren(*node, eventNode);
             continue;
         }
         result.unite(node->pixelSnappedBoundingBox());
-        node = NodeTraversal::next(node, eventNode);
+        node = NodeTraversal::next(*node, eventNode);
     }
     return eventNode->document().view()->contentsToWindow(result);
 }
diff --git a/Source/core/page/UseCounter.cpp b/Source/core/page/UseCounter.cpp
deleted file mode 100644
index 0353938..0000000
--- a/Source/core/page/UseCounter.cpp
+++ /dev/null
@@ -1,732 +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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "core/page/UseCounter.h"
-
-#include "core/css/CSSStyleSheet.h"
-#include "core/css/StyleSheetContents.h"
-#include "core/dom/Document.h"
-#include "core/dom/ExecutionContext.h"
-#include "core/frame/DOMWindow.h"
-#include "core/page/Page.h"
-#include "core/page/PageConsole.h"
-#include "public/platform/Platform.h"
-#include "wtf/text/WTFString.h"
-
-namespace WebCore {
-
-static int totalPagesMeasuredCSSSampleId() { return 1; }
-
-// FIXME : This mapping should be autogenerated. This function should
-//         be moved to a separate file and a script run at build time
-//         to detect new values in CSSPropertyID and add them to the
-//         end of this function. This file would be checked in.
-//         https://code.google.com/p/chromium/issues/detail?id=234940
-int UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(int id)
-{
-    CSSPropertyID cssPropertyID = convertToCSSPropertyID(id);
-
-    switch (cssPropertyID) {
-    // Begin at 2, because 1 is reserved for totalPagesMeasuredCSSSampleId.
-    case CSSPropertyColor: return 2;
-    case CSSPropertyDirection: return 3;
-    case CSSPropertyDisplay: return 4;
-    case CSSPropertyFont: return 5;
-    case CSSPropertyFontFamily: return 6;
-    case CSSPropertyFontSize: return 7;
-    case CSSPropertyFontStyle: return 8;
-    case CSSPropertyFontVariant: return 9;
-    case CSSPropertyFontWeight: return 10;
-    case CSSPropertyTextRendering: return 11;
-    case CSSPropertyWebkitFontFeatureSettings: return 12;
-    case CSSPropertyWebkitFontKerning: return 13;
-    case CSSPropertyWebkitFontSmoothing: return 14;
-    case CSSPropertyWebkitFontVariantLigatures: return 15;
-    case CSSPropertyWebkitLocale: return 16;
-    case CSSPropertyWebkitTextOrientation: return 17;
-    case CSSPropertyWebkitWritingMode: return 18;
-    case CSSPropertyZoom: return 19;
-    case CSSPropertyLineHeight: return 20;
-    case CSSPropertyBackground: return 21;
-    case CSSPropertyBackgroundAttachment: return 22;
-    case CSSPropertyBackgroundClip: return 23;
-    case CSSPropertyBackgroundColor: return 24;
-    case CSSPropertyBackgroundImage: return 25;
-    case CSSPropertyBackgroundOrigin: return 26;
-    case CSSPropertyBackgroundPosition: return 27;
-    case CSSPropertyBackgroundPositionX: return 28;
-    case CSSPropertyBackgroundPositionY: return 29;
-    case CSSPropertyBackgroundRepeat: return 30;
-    case CSSPropertyBackgroundRepeatX: return 31;
-    case CSSPropertyBackgroundRepeatY: return 32;
-    case CSSPropertyBackgroundSize: return 33;
-    case CSSPropertyBorder: return 34;
-    case CSSPropertyBorderBottom: return 35;
-    case CSSPropertyBorderBottomColor: return 36;
-    case CSSPropertyBorderBottomLeftRadius: return 37;
-    case CSSPropertyBorderBottomRightRadius: return 38;
-    case CSSPropertyBorderBottomStyle: return 39;
-    case CSSPropertyBorderBottomWidth: return 40;
-    case CSSPropertyBorderCollapse: return 41;
-    case CSSPropertyBorderColor: return 42;
-    case CSSPropertyBorderImage: return 43;
-    case CSSPropertyBorderImageOutset: return 44;
-    case CSSPropertyBorderImageRepeat: return 45;
-    case CSSPropertyBorderImageSlice: return 46;
-    case CSSPropertyBorderImageSource: return 47;
-    case CSSPropertyBorderImageWidth: return 48;
-    case CSSPropertyBorderLeft: return 49;
-    case CSSPropertyBorderLeftColor: return 50;
-    case CSSPropertyBorderLeftStyle: return 51;
-    case CSSPropertyBorderLeftWidth: return 52;
-    case CSSPropertyBorderRadius: return 53;
-    case CSSPropertyBorderRight: return 54;
-    case CSSPropertyBorderRightColor: return 55;
-    case CSSPropertyBorderRightStyle: return 56;
-    case CSSPropertyBorderRightWidth: return 57;
-    case CSSPropertyBorderSpacing: return 58;
-    case CSSPropertyBorderStyle: return 59;
-    case CSSPropertyBorderTop: return 60;
-    case CSSPropertyBorderTopColor: return 61;
-    case CSSPropertyBorderTopLeftRadius: return 62;
-    case CSSPropertyBorderTopRightRadius: return 63;
-    case CSSPropertyBorderTopStyle: return 64;
-    case CSSPropertyBorderTopWidth: return 65;
-    case CSSPropertyBorderWidth: return 66;
-    case CSSPropertyBottom: return 67;
-    case CSSPropertyBoxShadow: return 68;
-    case CSSPropertyBoxSizing: return 69;
-    case CSSPropertyCaptionSide: return 70;
-    case CSSPropertyClear: return 71;
-    case CSSPropertyClip: return 72;
-    case CSSPropertyWebkitClipPath: return 73;
-    case CSSPropertyContent: return 74;
-    case CSSPropertyCounterIncrement: return 75;
-    case CSSPropertyCounterReset: return 76;
-    case CSSPropertyCursor: return 77;
-    case CSSPropertyEmptyCells: return 78;
-    case CSSPropertyFloat: return 79;
-    case CSSPropertyFontStretch: return 80;
-    case CSSPropertyHeight: return 81;
-    case CSSPropertyImageRendering: return 82;
-    case CSSPropertyLeft: return 83;
-    case CSSPropertyLetterSpacing: return 84;
-    case CSSPropertyListStyle: return 85;
-    case CSSPropertyListStyleImage: return 86;
-    case CSSPropertyListStylePosition: return 87;
-    case CSSPropertyListStyleType: return 88;
-    case CSSPropertyMargin: return 89;
-    case CSSPropertyMarginBottom: return 90;
-    case CSSPropertyMarginLeft: return 91;
-    case CSSPropertyMarginRight: return 92;
-    case CSSPropertyMarginTop: return 93;
-    case CSSPropertyMaxHeight: return 94;
-    case CSSPropertyMaxWidth: return 95;
-    case CSSPropertyMinHeight: return 96;
-    case CSSPropertyMinWidth: return 97;
-    case CSSPropertyOpacity: return 98;
-    case CSSPropertyOrphans: return 99;
-    case CSSPropertyOutline: return 100;
-    case CSSPropertyOutlineColor: return 101;
-    case CSSPropertyOutlineOffset: return 102;
-    case CSSPropertyOutlineStyle: return 103;
-    case CSSPropertyOutlineWidth: return 104;
-    case CSSPropertyOverflow: return 105;
-    case CSSPropertyOverflowWrap: return 106;
-    case CSSPropertyOverflowX: return 107;
-    case CSSPropertyOverflowY: return 108;
-    case CSSPropertyPadding: return 109;
-    case CSSPropertyPaddingBottom: return 110;
-    case CSSPropertyPaddingLeft: return 111;
-    case CSSPropertyPaddingRight: return 112;
-    case CSSPropertyPaddingTop: return 113;
-    case CSSPropertyPage: return 114;
-    case CSSPropertyPageBreakAfter: return 115;
-    case CSSPropertyPageBreakBefore: return 116;
-    case CSSPropertyPageBreakInside: return 117;
-    case CSSPropertyPointerEvents: return 118;
-    case CSSPropertyPosition: return 119;
-    case CSSPropertyQuotes: return 120;
-    case CSSPropertyResize: return 121;
-    case CSSPropertyRight: return 122;
-    case CSSPropertySize: return 123;
-    case CSSPropertySrc: return 124;
-    case CSSPropertySpeak: return 125;
-    case CSSPropertyTableLayout: return 126;
-    case CSSPropertyTabSize: return 127;
-    case CSSPropertyTextAlign: return 128;
-    case CSSPropertyTextDecoration: return 129;
-    case CSSPropertyTextIndent: return 130;
-    /* Removed CSSPropertyTextLineThrough - 131 */
-    case CSSPropertyTextLineThroughColor: return 132;
-    case CSSPropertyTextLineThroughMode: return 133;
-    case CSSPropertyTextLineThroughStyle: return 134;
-    case CSSPropertyTextLineThroughWidth: return 135;
-    case CSSPropertyTextOverflow: return 136;
-    /* Removed CSSPropertyTextOverline - 137 */
-    case CSSPropertyTextOverlineColor: return 138;
-    case CSSPropertyTextOverlineMode: return 139;
-    case CSSPropertyTextOverlineStyle: return 140;
-    case CSSPropertyTextOverlineWidth: return 141;
-    case CSSPropertyTextShadow: return 142;
-    case CSSPropertyTextTransform: return 143;
-    /* Removed CSSPropertyTextUnderline - 144 */
-    case CSSPropertyTextUnderlineColor: return 145;
-    case CSSPropertyTextUnderlineMode: return 146;
-    case CSSPropertyTextUnderlineStyle: return 147;
-    case CSSPropertyTextUnderlineWidth: return 148;
-    case CSSPropertyTop: return 149;
-    case CSSPropertyTransition: return 150;
-    case CSSPropertyTransitionDelay: return 151;
-    case CSSPropertyTransitionDuration: return 152;
-    case CSSPropertyTransitionProperty: return 153;
-    case CSSPropertyTransitionTimingFunction: return 154;
-    case CSSPropertyUnicodeBidi: return 155;
-    case CSSPropertyUnicodeRange: return 156;
-    case CSSPropertyVerticalAlign: return 157;
-    case CSSPropertyVisibility: return 158;
-    case CSSPropertyWhiteSpace: return 159;
-    case CSSPropertyWidows: return 160;
-    case CSSPropertyWidth: return 161;
-    case CSSPropertyWordBreak: return 162;
-    case CSSPropertyWordSpacing: return 163;
-    case CSSPropertyWordWrap: return 164;
-    case CSSPropertyZIndex: return 165;
-    case CSSPropertyWebkitAnimation: return 166;
-    case CSSPropertyWebkitAnimationDelay: return 167;
-    case CSSPropertyWebkitAnimationDirection: return 168;
-    case CSSPropertyWebkitAnimationDuration: return 169;
-    case CSSPropertyWebkitAnimationFillMode: return 170;
-    case CSSPropertyWebkitAnimationIterationCount: return 171;
-    case CSSPropertyWebkitAnimationName: return 172;
-    case CSSPropertyWebkitAnimationPlayState: return 173;
-    case CSSPropertyWebkitAnimationTimingFunction: return 174;
-    case CSSPropertyWebkitAppearance: return 175;
-    case CSSPropertyWebkitAspectRatio: return 176;
-    case CSSPropertyWebkitBackfaceVisibility: return 177;
-    case CSSPropertyWebkitBackgroundClip: return 178;
-    case CSSPropertyWebkitBackgroundComposite: return 179;
-    case CSSPropertyWebkitBackgroundOrigin: return 180;
-    case CSSPropertyWebkitBackgroundSize: return 181;
-    case CSSPropertyWebkitBorderAfter: return 182;
-    case CSSPropertyWebkitBorderAfterColor: return 183;
-    case CSSPropertyWebkitBorderAfterStyle: return 184;
-    case CSSPropertyWebkitBorderAfterWidth: return 185;
-    case CSSPropertyWebkitBorderBefore: return 186;
-    case CSSPropertyWebkitBorderBeforeColor: return 187;
-    case CSSPropertyWebkitBorderBeforeStyle: return 188;
-    case CSSPropertyWebkitBorderBeforeWidth: return 189;
-    case CSSPropertyWebkitBorderEnd: return 190;
-    case CSSPropertyWebkitBorderEndColor: return 191;
-    case CSSPropertyWebkitBorderEndStyle: return 192;
-    case CSSPropertyWebkitBorderEndWidth: return 193;
-    case CSSPropertyWebkitBorderFit: return 194;
-    case CSSPropertyWebkitBorderHorizontalSpacing: return 195;
-    case CSSPropertyWebkitBorderImage: return 196;
-    case CSSPropertyWebkitBorderRadius: return 197;
-    case CSSPropertyWebkitBorderStart: return 198;
-    case CSSPropertyWebkitBorderStartColor: return 199;
-    case CSSPropertyWebkitBorderStartStyle: return 200;
-    case CSSPropertyWebkitBorderStartWidth: return 201;
-    case CSSPropertyWebkitBorderVerticalSpacing: return 202;
-    case CSSPropertyWebkitBoxAlign: return 203;
-    case CSSPropertyWebkitBoxDirection: return 204;
-    case CSSPropertyWebkitBoxFlex: return 205;
-    case CSSPropertyWebkitBoxFlexGroup: return 206;
-    case CSSPropertyWebkitBoxLines: return 207;
-    case CSSPropertyWebkitBoxOrdinalGroup: return 208;
-    case CSSPropertyWebkitBoxOrient: return 209;
-    case CSSPropertyWebkitBoxPack: return 210;
-    case CSSPropertyWebkitBoxReflect: return 211;
-    case CSSPropertyWebkitBoxShadow: return 212;
-    case CSSPropertyWebkitColumnAxis: return 214;
-    case CSSPropertyWebkitColumnBreakAfter: return 215;
-    case CSSPropertyWebkitColumnBreakBefore: return 216;
-    case CSSPropertyWebkitColumnBreakInside: return 217;
-    case CSSPropertyWebkitColumnCount: return 218;
-    case CSSPropertyWebkitColumnGap: return 219;
-    case CSSPropertyWebkitColumnProgression: return 220;
-    case CSSPropertyWebkitColumnRule: return 221;
-    case CSSPropertyWebkitColumnRuleColor: return 222;
-    case CSSPropertyWebkitColumnRuleStyle: return 223;
-    case CSSPropertyWebkitColumnRuleWidth: return 224;
-    case CSSPropertyWebkitColumnSpan: return 225;
-    case CSSPropertyWebkitColumnWidth: return 226;
-    case CSSPropertyWebkitColumns: return 227;
-#if defined(ENABLE_CSS_BOX_DECORATION_BREAK) && ENABLE_CSS_BOX_DECORATION_BREAK
-    case CSSPropertyWebkitBoxDecorationBreak: return 228;
-#endif
-#if defined(ENABLE_CSS_FILTERS) && ENABLE_CSS_FILTERS
-    case CSSPropertyWebkitFilter: return 229;
-#endif
-    case CSSPropertyAlignContent: return 230;
-    case CSSPropertyAlignItems: return 231;
-    case CSSPropertyAlignSelf: return 232;
-    case CSSPropertyFlex: return 233;
-    case CSSPropertyFlexBasis: return 234;
-    case CSSPropertyFlexDirection: return 235;
-    case CSSPropertyFlexFlow: return 236;
-    case CSSPropertyFlexGrow: return 237;
-    case CSSPropertyFlexShrink: return 238;
-    case CSSPropertyFlexWrap: return 239;
-    case CSSPropertyJustifyContent: return 240;
-    case CSSPropertyWebkitFontSizeDelta: return 241;
-    case CSSPropertyGridDefinitionColumns: return 242;
-    case CSSPropertyGridDefinitionRows: return 243;
-    case CSSPropertyGridColumnStart: return 244;
-    case CSSPropertyGridColumnEnd: return 245;
-    case CSSPropertyGridRowStart: return 246;
-    case CSSPropertyGridRowEnd: return 247;
-    case CSSPropertyGridColumn: return 248;
-    case CSSPropertyGridRow: return 249;
-    case CSSPropertyGridAutoFlow: return 250;
-    case CSSPropertyWebkitHighlight: return 251;
-    case CSSPropertyWebkitHyphenateCharacter: return 252;
-    case CSSPropertyWebkitLineBoxContain: return 257;
-    case CSSPropertyWebkitLineAlign: return 258;
-    case CSSPropertyWebkitLineBreak: return 259;
-    case CSSPropertyWebkitLineClamp: return 260;
-    case CSSPropertyWebkitLineGrid: return 261;
-    case CSSPropertyWebkitLineSnap: return 262;
-    case CSSPropertyWebkitLogicalWidth: return 263;
-    case CSSPropertyWebkitLogicalHeight: return 264;
-    case CSSPropertyWebkitMarginAfterCollapse: return 265;
-    case CSSPropertyWebkitMarginBeforeCollapse: return 266;
-    case CSSPropertyWebkitMarginBottomCollapse: return 267;
-    case CSSPropertyWebkitMarginTopCollapse: return 268;
-    case CSSPropertyWebkitMarginCollapse: return 269;
-    case CSSPropertyWebkitMarginAfter: return 270;
-    case CSSPropertyWebkitMarginBefore: return 271;
-    case CSSPropertyWebkitMarginEnd: return 272;
-    case CSSPropertyWebkitMarginStart: return 273;
-    // CSSPropertyWebkitMarquee was 274.
-    // CSSPropertyInternalMarquee* were 275-279.
-    case CSSPropertyWebkitMask: return 280;
-    case CSSPropertyWebkitMaskBoxImage: return 281;
-    case CSSPropertyWebkitMaskBoxImageOutset: return 282;
-    case CSSPropertyWebkitMaskBoxImageRepeat: return 283;
-    case CSSPropertyWebkitMaskBoxImageSlice: return 284;
-    case CSSPropertyWebkitMaskBoxImageSource: return 285;
-    case CSSPropertyWebkitMaskBoxImageWidth: return 286;
-    case CSSPropertyWebkitMaskClip: return 287;
-    case CSSPropertyWebkitMaskComposite: return 288;
-    case CSSPropertyWebkitMaskImage: return 289;
-    case CSSPropertyWebkitMaskOrigin: return 290;
-    case CSSPropertyWebkitMaskPosition: return 291;
-    case CSSPropertyWebkitMaskPositionX: return 292;
-    case CSSPropertyWebkitMaskPositionY: return 293;
-    case CSSPropertyWebkitMaskRepeat: return 294;
-    case CSSPropertyWebkitMaskRepeatX: return 295;
-    case CSSPropertyWebkitMaskRepeatY: return 296;
-    case CSSPropertyWebkitMaskSize: return 297;
-    case CSSPropertyWebkitMaxLogicalWidth: return 298;
-    case CSSPropertyWebkitMaxLogicalHeight: return 299;
-    case CSSPropertyWebkitMinLogicalWidth: return 300;
-    case CSSPropertyWebkitMinLogicalHeight: return 301;
-    // WebkitNbspMode has been deleted, was return 302;
-    case CSSPropertyOrder: return 303;
-    case CSSPropertyWebkitPaddingAfter: return 304;
-    case CSSPropertyWebkitPaddingBefore: return 305;
-    case CSSPropertyWebkitPaddingEnd: return 306;
-    case CSSPropertyWebkitPaddingStart: return 307;
-    case CSSPropertyWebkitPerspective: return 308;
-    case CSSPropertyWebkitPerspectiveOrigin: return 309;
-    case CSSPropertyWebkitPerspectiveOriginX: return 310;
-    case CSSPropertyWebkitPerspectiveOriginY: return 311;
-    case CSSPropertyWebkitPrintColorAdjust: return 312;
-    case CSSPropertyWebkitRtlOrdering: return 313;
-    case CSSPropertyWebkitRubyPosition: return 314;
-    case CSSPropertyWebkitTextCombine: return 315;
-    case CSSPropertyWebkitTextDecorationsInEffect: return 316;
-    case CSSPropertyWebkitTextEmphasis: return 317;
-    case CSSPropertyWebkitTextEmphasisColor: return 318;
-    case CSSPropertyWebkitTextEmphasisPosition: return 319;
-    case CSSPropertyWebkitTextEmphasisStyle: return 320;
-    case CSSPropertyWebkitTextFillColor: return 321;
-    case CSSPropertyWebkitTextSecurity: return 322;
-    case CSSPropertyWebkitTextStroke: return 323;
-    case CSSPropertyWebkitTextStrokeColor: return 324;
-    case CSSPropertyWebkitTextStrokeWidth: return 325;
-    case CSSPropertyWebkitTransform: return 326;
-    case CSSPropertyWebkitTransformOrigin: return 327;
-    case CSSPropertyWebkitTransformOriginX: return 328;
-    case CSSPropertyWebkitTransformOriginY: return 329;
-    case CSSPropertyWebkitTransformOriginZ: return 330;
-    case CSSPropertyWebkitTransformStyle: return 331;
-    case CSSPropertyWebkitTransition: return 332;
-    case CSSPropertyWebkitTransitionDelay: return 333;
-    case CSSPropertyWebkitTransitionDuration: return 334;
-    case CSSPropertyWebkitTransitionProperty: return 335;
-    case CSSPropertyWebkitTransitionTimingFunction: return 336;
-    case CSSPropertyWebkitUserDrag: return 337;
-    case CSSPropertyWebkitUserModify: return 338;
-    case CSSPropertyWebkitUserSelect: return 339;
-    case CSSPropertyWebkitFlowInto: return 340;
-    case CSSPropertyWebkitFlowFrom: return 341;
-    case CSSPropertyWebkitRegionFragment: return 342;
-    case CSSPropertyWebkitRegionBreakAfter: return 343;
-    case CSSPropertyWebkitRegionBreakBefore: return 344;
-    case CSSPropertyWebkitRegionBreakInside: return 345;
-    case CSSPropertyShapeInside: return 346;
-    case CSSPropertyShapeOutside: return 347;
-    case CSSPropertyShapeMargin: return 348;
-    case CSSPropertyShapePadding: return 349;
-    case CSSPropertyWebkitWrapFlow: return 350;
-    case CSSPropertyWebkitWrapThrough: return 351;
-    // CSSPropertyWebkitWrap was 352.
-#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
-    case CSSPropertyWebkitTapHighlightColor: return 353;
-#endif
-#if defined(ENABLE_DRAGGABLE_REGION) && ENABLE_DRAGGABLE_REGION
-    case CSSPropertyWebkitAppRegion: return 354;
-#endif
-    case CSSPropertyClipPath: return 355;
-    case CSSPropertyClipRule: return 356;
-    case CSSPropertyMask: return 357;
-    case CSSPropertyEnableBackground: return 358;
-    case CSSPropertyFilter: return 359;
-    case CSSPropertyFloodColor: return 360;
-    case CSSPropertyFloodOpacity: return 361;
-    case CSSPropertyLightingColor: return 362;
-    case CSSPropertyStopColor: return 363;
-    case CSSPropertyStopOpacity: return 364;
-    case CSSPropertyColorInterpolation: return 365;
-    case CSSPropertyColorInterpolationFilters: return 366;
-    case CSSPropertyColorProfile: return 367;
-    case CSSPropertyColorRendering: return 368;
-    case CSSPropertyFill: return 369;
-    case CSSPropertyFillOpacity: return 370;
-    case CSSPropertyFillRule: return 371;
-    case CSSPropertyMarker: return 372;
-    case CSSPropertyMarkerEnd: return 373;
-    case CSSPropertyMarkerMid: return 374;
-    case CSSPropertyMarkerStart: return 375;
-    case CSSPropertyMaskType: return 376;
-    case CSSPropertyShapeRendering: return 377;
-    case CSSPropertyStroke: return 378;
-    case CSSPropertyStrokeDasharray: return 379;
-    case CSSPropertyStrokeDashoffset: return 380;
-    case CSSPropertyStrokeLinecap: return 381;
-    case CSSPropertyStrokeLinejoin: return 382;
-    case CSSPropertyStrokeMiterlimit: return 383;
-    case CSSPropertyStrokeOpacity: return 384;
-    case CSSPropertyStrokeWidth: return 385;
-    case CSSPropertyAlignmentBaseline: return 386;
-    case CSSPropertyBaselineShift: return 387;
-    case CSSPropertyDominantBaseline: return 388;
-    case CSSPropertyGlyphOrientationHorizontal: return 389;
-    case CSSPropertyGlyphOrientationVertical: return 390;
-    case CSSPropertyKerning: return 391;
-    case CSSPropertyTextAnchor: return 392;
-    case CSSPropertyVectorEffect: return 393;
-    case CSSPropertyWritingMode: return 394;
-    // CSSPropertyWebkitSvgShadow has been removed, was return 395;
-#if defined(ENABLE_CURSOR_VISIBILITY) && ENABLE_CURSOR_VISIBILITY
-    case CSSPropertyWebkitCursorVisibility: return 396;
-#endif
-    // CSSPropertyImageOrientation has been removed, was return 397;
-    // CSSPropertyImageResolution has been removed, was return 398;
-#if defined(ENABLE_CSS_COMPOSITING) && ENABLE_CSS_COMPOSITING
-    case CSSPropertyWebkitBlendMode: return 399;
-    case CSSPropertyWebkitBackgroundBlendMode: return 400;
-#endif
-    case CSSPropertyTextDecorationLine: return 401;
-    case CSSPropertyTextDecorationStyle: return 402;
-    case CSSPropertyTextDecorationColor: return 403;
-    case CSSPropertyTextAlignLast: return 404;
-    case CSSPropertyTextUnderlinePosition: return 405;
-    case CSSPropertyMaxZoom: return 406;
-    case CSSPropertyMinZoom: return 407;
-    case CSSPropertyOrientation: return 408;
-    case CSSPropertyUserZoom: return 409;
-    // CSSPropertyWebkitDashboardRegion was 410.
-    // CSSPropertyWebkitOverflowScrolling was 411.
-    case CSSPropertyWebkitAppRegion: return 412;
-    case CSSPropertyWebkitFilter: return 413;
-    case CSSPropertyWebkitBoxDecorationBreak: return 414;
-    case CSSPropertyWebkitTapHighlightColor: return 415;
-    case CSSPropertyBufferedRendering: return 416;
-    case CSSPropertyGridAutoRows: return 417;
-    case CSSPropertyGridAutoColumns: return 418;
-    case CSSPropertyBackgroundBlendMode: return 419;
-    case CSSPropertyMixBlendMode: return 420;
-    case CSSPropertyTouchAction: return 421;
-    case CSSPropertyGridArea: return 422;
-    case CSSPropertyGridTemplate: return 423;
-    case CSSPropertyAnimation: return 424;
-    case CSSPropertyAnimationDelay: return 425;
-    case CSSPropertyAnimationDirection: return 426;
-    case CSSPropertyAnimationDuration: return 427;
-    case CSSPropertyAnimationFillMode: return 428;
-    case CSSPropertyAnimationIterationCount: return 429;
-    case CSSPropertyAnimationName: return 430;
-    case CSSPropertyAnimationPlayState: return 431;
-    case CSSPropertyAnimationTimingFunction: return 432;
-    case CSSPropertyObjectFit: return 433;
-    case CSSPropertyPaintOrder: return 434;
-    case CSSPropertyMaskSourceType: return 435;
-    case CSSPropertyIsolation: return 436;
-    case CSSPropertyObjectPosition: return 437;
-    case CSSPropertyInternalCallback: return 438;
-    case CSSPropertyShapeImageThreshold: return 439;
-    case CSSPropertyColumnFill: return 440;
-    case CSSPropertyTextJustify: return 441;
-    case CSSPropertyTouchActionDelay: return 442;
-
-    // Add new features above this line (don't change the assigned numbers of the existing
-    // items) and update maximumCSSSampleId() with the new maximum value.
-
-    // Internal properties should not be counted.
-    case CSSPropertyInternalMarqueeDirection:
-    case CSSPropertyInternalMarqueeIncrement:
-    case CSSPropertyInternalMarqueeRepetition:
-    case CSSPropertyInternalMarqueeSpeed:
-    case CSSPropertyInternalMarqueeStyle:
-    case CSSPropertyInvalid:
-    case CSSPropertyVariable:
-        ASSERT_NOT_REACHED();
-        return 0;
-    }
-
-    ASSERT_NOT_REACHED();
-    return 0;
-}
-
-static int maximumCSSSampleId() { return 442; }
-
-UseCounter::UseCounter()
-{
-    m_CSSFeatureBits.ensureSize(lastCSSProperty + 1);
-    m_CSSFeatureBits.clearAll();
-}
-
-UseCounter::~UseCounter()
-{
-    // We always log PageDestruction so that we have a scale for the rest of the features.
-    WebKit::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageDestruction, NumberOfFeatures);
-
-    updateMeasurements();
-}
-
-void UseCounter::updateMeasurements()
-{
-    WebKit::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageVisits, NumberOfFeatures);
-
-    if (m_countBits) {
-        for (unsigned i = 0; i < NumberOfFeatures; ++i) {
-            if (m_countBits->quickGet(i))
-                WebKit::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", i, NumberOfFeatures);
-        }
-        // Clearing count bits is timing sensitive.
-        m_countBits->clearAll();
-    }
-
-    // FIXME: Sometimes this function is called more than once per page. The following
-    //        bool guards against incrementing the page count when there are no CSS
-    //        bits set. http://crbug.com/236262.
-    bool needsPagesMeasuredUpdate = false;
-    for (int i = firstCSSProperty; i <= lastCSSProperty; ++i) {
-        if (m_CSSFeatureBits.quickGet(i)) {
-            int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(i);
-            WebKit::Platform::current()->histogramEnumeration("WebCore.FeatureObserver.CSSProperties", cssSampleId, maximumCSSSampleId());
-            needsPagesMeasuredUpdate = true;
-        }
-    }
-
-    if (needsPagesMeasuredUpdate)
-        WebKit::Platform::current()->histogramEnumeration("WebCore.FeatureObserver.CSSProperties", totalPagesMeasuredCSSSampleId(), maximumCSSSampleId());
-
-    m_CSSFeatureBits.clearAll();
-}
-
-void UseCounter::didCommitLoad()
-{
-    updateMeasurements();
-}
-
-void UseCounter::count(const Document& document, Feature feature)
-{
-    Page* page = document.page();
-    if (!page)
-        return;
-
-    ASSERT(page->useCounter().deprecationMessage(feature).isEmpty());
-    page->useCounter().recordMeasurement(feature);
-}
-
-void UseCounter::count(const DOMWindow* domWindow, Feature feature)
-{
-    ASSERT(domWindow);
-    if (!domWindow->document())
-        return;
-    count(*domWindow->document(), feature);
-}
-
-void UseCounter::countDeprecation(ExecutionContext* context, Feature feature)
-{
-    if (!context || !context->isDocument())
-        return;
-    UseCounter::countDeprecation(*toDocument(context), feature);
-}
-
-void UseCounter::countDeprecation(const DOMWindow* window, Feature feature)
-{
-    if (!window || !window->document())
-        return;
-    UseCounter::countDeprecation(*window->document(), feature);
-}
-
-void UseCounter::countDeprecation(const Document& document, Feature feature)
-{
-    Page* page = document.page();
-    if (!page)
-        return;
-
-    if (page->useCounter().recordMeasurement(feature)) {
-        ASSERT(!page->useCounter().deprecationMessage(feature).isEmpty());
-        page->console().addMessage(DeprecationMessageSource, WarningMessageLevel, page->useCounter().deprecationMessage(feature));
-    }
-}
-
-String UseCounter::deprecationMessage(Feature feature)
-{
-    switch (feature) {
-    // Content Security Policy
-    case PrefixedContentSecurityPolicy:
-    case PrefixedContentSecurityPolicyReportOnly:
-        return "The 'X-WebKit-CSP' headers are no longer supported. Please consider using the canonical 'Content-Security-Policy' header instead.";
-
-    // HTMLMediaElement
-    case PrefixedMediaGenerateKeyRequest:
-        return "'HTMLMediaElement.webkitGenerateKeyRequest()' is deprecated. Please use 'MediaKeys.createSession()' instead.";
-
-    // Quota
-    case StorageInfo:
-        return "'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.";
-
-    // Performance
-    case PrefixedPerformanceTimeline:
-        return "'window.performance.webkitGet*' methods have been deprecated. Please use the unprefixed 'performance.get*' methods instead.";
-    case PrefixedUserTiming:
-        return "'window.performance.webkit*' methods have been deprecated. Please use the unprefixed 'window.performance.*' methods instead.";
-
-    // Web Audio
-    case WebAudioLooping:
-        return "AudioBufferSourceNode 'looping' attribute is deprecated.  Use 'loop' instead.";
-
-    case DocumentClear:
-        return "document.clear() is deprecated. This method doesn't do anything.";
-
-    case PrefixedTransitionMediaFeature:
-        return "The '(-webkit-transition)' media query feature is deprecated; please consider using the more exact conditional \"@supports('(transition-property: prop_name)')\" instead.";
-
-    // Web Components
-    case HTMLShadowElementOlderShadowRoot:
-        return "HTMLShadowElement.olderShadowRoot is deprecated.";
-    case PrefixedDocumentRegister:
-        return "The document.webkitRegister method is deprecated. Use the document.register method instead.";
-
-    // HTML Media Capture
-    case CaptureAttributeAsEnum:
-        return "Using the 'capture' attribute as an enum is deprecated. Please use it as a boolean and specify the media types that should be accepted in the 'accept' attribute.";
-
-    // Keyboard Event (DOM Level 3)
-    case KeyboardEventKeyLocation:
-        return "'KeyboardEvent.keyLocation'' is deprecated. Please use 'KeyboardEvent.location' instead.";
-
-    case CaptureEvents:
-        return "captureEvents() is deprecated. This method doesn't do anything.";
-
-    case ReleaseEvents:
-        return "releaseEvents() is deprecated. This method doesn't do anything.";
-
-    case ConsoleMarkTimeline:
-        return "console.markTimeline is deprecated. Please use the console.timeStamp instead.";
-
-    case FileError:
-        return "FileError is deprecated. Please use the 'name' or 'message' attributes of DOMError rather than 'code'.";
-
-    case EventReturnValue:
-        return "event.returnValue is deprecated. Please use the standard event.preventDefault() instead.";
-
-    case ScrollTopBodyNotQuirksMode:
-        return "body.scrollTop is deprecated in strict mode. Please use 'documentElement.scrollTop' if in strict mode and 'body.scrollTop' only if in quirks mode.";
-
-    case ScrollLeftBodyNotQuirksMode:
-        return "body.scrollLeft is deprecated in strict mode. Please use 'documentElement.scrollLeft' if in strict mode and 'body.scrollLeft' only if in quirks mode.";
-
-    case ShowModalDialog:
-        return "Chromium is considering deprecating showModalDialog. Please use window.open and postMessage instead.";
-
-    // Features that aren't deprecated don't have a deprecation message.
-    default:
-        return String();
-    }
-}
-
-void UseCounter::count(CSSParserContext context, CSSPropertyID feature)
-{
-    ASSERT(feature >= firstCSSProperty);
-    ASSERT(feature <= lastCSSProperty);
-    ASSERT(!isInternalProperty(feature));
-
-    if (!isUseCounterEnabledForMode(context.mode))
-        return;
-
-    m_CSSFeatureBits.quickSet(feature);
-}
-
-void UseCounter::count(Feature feature)
-{
-    ASSERT(deprecationMessage(feature).isEmpty());
-    recordMeasurement(feature);
-}
-
-UseCounter* UseCounter::getFrom(const Document* document)
-{
-    if (document && document->page())
-        return &document->page()->useCounter();
-    return 0;
-}
-
-UseCounter* UseCounter::getFrom(const CSSStyleSheet* sheet)
-{
-    if (sheet)
-        return getFrom(sheet->contents());
-    return 0;
-}
-
-UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents)
-{
-    // FIXME: We may want to handle stylesheets that have multiple owners
-    //        http://crbug.com/242125
-    if (sheetContents && !sheetContents->isUserStyleSheet() && sheetContents->hasSingleOwnerNode())
-        return getFrom(sheetContents->singleOwnerDocument());
-    return 0;
-}
-
-} // namespace WebCore
diff --git a/Source/core/page/UseCounter.h b/Source/core/page/UseCounter.h
deleted file mode 100644
index dd21b79..0000000
--- a/Source/core/page/UseCounter.h
+++ /dev/null
@@ -1,312 +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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef UseCounter_h
-#define UseCounter_h
-
-#include "CSSPropertyNames.h"
-#include "wtf/BitVector.h"
-#include "wtf/Noncopyable.h"
-#include "wtf/OwnPtr.h"
-#include "wtf/PassOwnPtr.h"
-#include "wtf/text/WTFString.h"
-
-namespace WebCore {
-
-class CSSStyleSheet;
-class DOMWindow;
-class Document;
-class ExecutionContext;
-class StyleSheetContents;
-
-// UseCounter is used for counting the number of times features of
-// Blink are used on real web pages and help us know commonly
-// features are used and thus when it's safe to remove or change them.
-//
-// The Chromium Content layer controls what is done with this data.
-// For instance, in Google Chrome, these counts are submitted
-// anonymously through the Histogram recording system in Chrome
-// for users who opt-in to "Usage Statistics" submission
-// during their install of Google Chrome:
-// http://www.google.com/chrome/intl/en/privacy.html
-
-class UseCounter {
-    WTF_MAKE_NONCOPYABLE(UseCounter);
-public:
-    UseCounter();
-    ~UseCounter();
-
-    enum Feature {
-        PageDestruction,
-        LegacyNotifications,
-        MultipartMainResource,
-        PrefixedIndexedDB,
-        WorkerStart,
-        SharedWorkerStart,
-        LegacyWebAudio,
-        WebAudioStart,
-        PrefixedContentSecurityPolicy,
-        UnprefixedIndexedDB,
-        OpenWebDatabase,
-        UnusedSlot01, // Prior to 7/2013, we used this slot for LegacyHTMLNotifications.
-        LegacyTextNotifications,
-        UnprefixedRequestAnimationFrame,
-        PrefixedRequestAnimationFrame,
-        ContentSecurityPolicy,
-        ContentSecurityPolicyReportOnly,
-        PrefixedContentSecurityPolicyReportOnly,
-        PrefixedTransitionEndEvent,
-        UnprefixedTransitionEndEvent,
-        PrefixedAndUnprefixedTransitionEndEvent,
-        AutoFocusAttribute,
-        UnusedSlot02, // Prior to 4/2013, we used this slot for AutoSaveAttribute.
-        DataListElement,
-        FormAttribute,
-        IncrementalAttribute,
-        InputTypeColor,
-        InputTypeDate,
-        InputTypeDateTime,
-        InputTypeDateTimeFallback,
-        InputTypeDateTimeLocal,
-        InputTypeEmail,
-        InputTypeMonth,
-        InputTypeNumber,
-        InputTypeRange,
-        InputTypeSearch,
-        InputTypeTel,
-        InputTypeTime,
-        InputTypeURL,
-        InputTypeWeek,
-        InputTypeWeekFallback,
-        ListAttribute,
-        MaxAttribute,
-        MinAttribute,
-        PatternAttribute,
-        PlaceholderAttribute,
-        PrecisionAttribute,
-        PrefixedDirectoryAttribute,
-        PrefixedSpeechAttribute,
-        RequiredAttribute,
-        ResultsAttribute,
-        StepAttribute,
-        PageVisits,
-        HTMLMarqueeElement,
-        UnusedSlot03, // Removed, was tracking overflow: -webkit-marquee.
-        Reflection,
-        CursorVisibility, // Removed, was -webkit-cursor-visibility.
-        StorageInfo,
-        XFrameOptions,
-        XFrameOptionsSameOrigin,
-        XFrameOptionsSameOriginWithBadAncestorChain,
-        DeprecatedFlexboxWebContent,
-        DeprecatedFlexboxChrome,
-        DeprecatedFlexboxChromeExtension,
-        UnusedSlot04,
-        UnprefixedPerformanceTimeline,
-        PrefixedPerformanceTimeline,
-        UnprefixedUserTiming,
-        PrefixedUserTiming,
-        WindowEvent,
-        ContentSecurityPolicyWithBaseElement,
-        PrefixedMediaAddKey,
-        PrefixedMediaGenerateKeyRequest,
-        WebAudioLooping,
-        DocumentClear,
-        PrefixedTransitionMediaFeature,
-        SVGFontElement,
-        XMLDocument,
-        XSLProcessingInstruction,
-        XSLTProcessor,
-        SVGSwitchElement,
-        PrefixedDocumentRegister,
-        HTMLShadowElementOlderShadowRoot,
-        DocumentAll,
-        FormElement,
-        DemotedFormElement,
-        CaptureAttributeAsEnum,
-        ShadowDOMPrefixedPseudo,
-        ShadowDOMPrefixedCreateShadowRoot,
-        ShadowDOMPrefixedShadowRoot,
-        SVGAnimationElement,
-        KeyboardEventKeyLocation,
-        CaptureEvents,
-        ReleaseEvents,
-        CSSDisplayRunIn,
-        CSSDisplayCompact,
-        LineClamp,
-        SubFrameBeforeUnloadRegistered,
-        SubFrameBeforeUnloadFired,
-        CSSPseudoElementPrefixedDistributed,
-        TextReplaceWholeText,
-        PrefixedShadowRootConstructor,
-        ConsoleMarkTimeline,
-        CSSPseudoElementUserAgentCustomPseudo,
-        DocumentTypeEntities, // Removed from DOM4.
-        DocumentTypeInternalSubset, // Removed from DOM4.
-        DocumentTypeNotations, // Removed from DOM4.
-        ElementGetAttributeNode, // Removed from DOM4.
-        ElementSetAttributeNode, // Removed from DOM4.
-        ElementRemoveAttributeNode, // Removed from DOM4.
-        ElementGetAttributeNodeNS, // Removed from DOM4.
-        DocumentCreateAttribute, // Removed from DOM4.
-        DocumentCreateAttributeNS, // Removed from DOM4.
-        DocumentCreateCDATASection, // Removed from DOM4.
-        DocumentInputEncoding, // Removed from DOM4.
-        DocumentXMLEncoding, // Removed from DOM4.
-        DocumentXMLStandalone, // Removed from DOM4.
-        DocumentXMLVersion, // Removed from DOM4.
-        NodeIsSameNode, // Removed from DOM4.
-        NodeIsSupported, // Removed from DOM4.
-        NodeNamespaceURI, // Removed from DOM4.
-        NodePrefix, // Removed from DOM4.
-        NodeLocalName, // Removed from DOM4.
-        NavigatorProductSub,
-        NavigatorVendor,
-        NavigatorVendorSub,
-        FileError,
-        DocumentCharset, // Documented as IE extensions, from KHTML days.
-        PrefixedAnimationEndEvent,
-        UnprefixedAnimationEndEvent,
-        PrefixedAndUnprefixedAnimationEndEvent,
-        PrefixedAnimationStartEvent,
-        UnprefixedAnimationStartEvent,
-        PrefixedAndUnprefixedAnimationStartEvent,
-        PrefixedAnimationIterationEvent,
-        UnprefixedAnimationIterationEvent,
-        PrefixedAndUnprefixedAnimationIterationEvent,
-        EventReturnValue, // Legacy IE extension.
-        SVGSVGElement,
-        SVGAnimateColorElement,
-        InsertAdjacentText,
-        InsertAdjacentElement,
-        HasAttributes, // Removed from DOM4.
-        DOMSubtreeModifiedEvent,
-        DOMNodeInsertedEvent,
-        DOMNodeRemovedEvent,
-        DOMNodeRemovedFromDocumentEvent,
-        DOMNodeInsertedIntoDocumentEvent,
-        DOMCharacterDataModifiedEvent,
-        DocumentAllTags,
-        DocumentAllLegacyCall,
-        HTMLAppletElementLegacyCall,
-        HTMLEmbedElementLegacyCall,
-        HTMLObjectElementLegacyCall,
-        BeforeLoadEvent,
-        GetMatchedCSSRules,
-        SVGFontInCSS,
-        ScrollTopBodyNotQuirksMode,
-        ScrollLeftBodyNotQuirksMode,
-        AttributeIsId, // Removed in DOM4.
-        AttributeOwnerElement, // Removed in DOM4.
-        AttributeSetPrefix, // Attribute prefix is readonly in DOM4.
-        AttributeSpecified, // Removed in DOM4.
-        BeforeLoadEventInIsolatedWorld,
-        PrefixedAudioDecodedByteCount,
-        PrefixedVideoDecodedByteCount,
-        PrefixedVideoSupportsFullscreen,
-        PrefixedVideoDisplayingFullscreen,
-        PrefixedVideoEnterFullscreen,
-        PrefixedVideoExitFullscreen,
-        PrefixedVideoEnterFullScreen,
-        PrefixedVideoExitFullScreen,
-        PrefixedVideoDecodedFrameCount,
-        PrefixedVideoDroppedFrameCount,
-        SourceElementCandidate,
-        SourceElementNonMatchingMedia,
-        PrefixedElementRequestFullscreen,
-        PrefixedElementRequestFullScreen,
-        BarPropLocationbar,
-        BarPropMenubar,
-        BarPropPersonalbar,
-        BarPropScrollbars,
-        BarPropStatusbar,
-        BarPropToolbar,
-        InputTypeEmailMultiple,
-        InputTypeEmailMaxLength,
-        InputTypeEmailMultipleMaxLength,
-        TextTrackCueConstructor,
-        CSSStyleDeclarationPropertyName, // Removed in CSSOM.
-        CSSStyleDeclarationFloatPropertyName, // Pending removal in CSSOM.
-        InputTypeText,
-        InputTypeTextMaxLength,
-        InputTypePassword,
-        InputTypePasswordMaxLength,
-        SVGInstanceRoot,
-        ShowModalDialog,
-        // Add new features immediately above this line. Don't change assigned
-        // numbers of each items, and don't reuse unused slots.
-        NumberOfFeatures, // This enum value must be last.
-    };
-
-    // "count" sets the bit for this feature to 1. Repeated calls are ignored.
-    static void count(const Document&, Feature);
-    static void count(const DOMWindow*, Feature);
-    void count(CSSParserContext, CSSPropertyID);
-    void count(Feature);
-
-    // "countDeprecation" sets the bit for this feature to 1, and sends a deprecation
-    // warning to the console. Repeated calls are ignored.
-    //
-    // Be considerate to developers' consoles: features should only send deprecation warnings
-    // when we're actively interested in removing them from the platform.
-    static void countDeprecation(const DOMWindow*, Feature);
-    static void countDeprecation(ExecutionContext*, Feature);
-    static void countDeprecation(const Document&, Feature);
-    String deprecationMessage(Feature);
-
-    void didCommitLoad();
-
-    static UseCounter* getFrom(const Document*);
-    static UseCounter* getFrom(const CSSStyleSheet*);
-    static UseCounter* getFrom(const StyleSheetContents*);
-
-    static int mapCSSPropertyIdToCSSSampleIdForHistogram(int id);
-
-private:
-    bool recordMeasurement(Feature feature)
-    {
-        ASSERT(feature != PageDestruction); // PageDestruction is reserved as a scaling factor.
-        ASSERT(feature < NumberOfFeatures);
-        if (!m_countBits) {
-            m_countBits = adoptPtr(new BitVector(NumberOfFeatures));
-            m_countBits->clearAll();
-        }
-
-        if (m_countBits->quickGet(feature))
-            return false;
-
-        m_countBits->quickSet(feature);
-        return true;
-    }
-
-    void updateMeasurements();
-
-    OwnPtr<BitVector> m_countBits;
-    BitVector m_CSSFeatureBits;
-};
-
-} // namespace WebCore
-
-#endif // UseCounter_h
diff --git a/Source/core/page/scrolling/ScrollingCoordinator.cpp b/Source/core/page/scrolling/ScrollingCoordinator.cpp
index ca72786..07ec6a2 100644
--- a/Source/core/page/scrolling/ScrollingCoordinator.cpp
+++ b/Source/core/page/scrolling/ScrollingCoordinator.cpp
@@ -61,11 +61,11 @@
 #include "public/platform/WebScrollbarThemePainter.h"
 #include "wtf/text/StringBuilder.h"
 
-using WebKit::WebLayer;
-using WebKit::WebLayerPositionConstraint;
-using WebKit::WebRect;
-using WebKit::WebScrollbarLayer;
-using WebKit::WebVector;
+using blink::WebLayer;
+using blink::WebLayerPositionConstraint;
+using blink::WebRect;
+using blink::WebScrollbarLayer;
+using blink::WebVector;
 
 
 namespace WebCore {
@@ -90,6 +90,8 @@
     : m_page(page)
     , m_scrollGestureRegionIsDirty(false)
     , m_touchEventTargetRectsAreDirty(false)
+    , m_wasFrameScrollable(false)
+    , m_lastMainThreadScrollingReasons(0)
 {
 }
 
@@ -151,6 +153,12 @@
         m_touchEventTargetRectsAreDirty = false;
     }
 
+    FrameView* frameView = m_page->mainFrame()->view();
+    bool frameIsScrollable = frameView && frameView->isScrollable();
+    if (m_wasFrameScrollable != frameIsScrollable)
+        updateShouldUpdateScrollLayerPositionOnMainThread();
+    m_wasFrameScrollable = frameIsScrollable;
+
     const FrameTree& tree = m_page->mainFrame()->tree();
     for (const Frame* child = tree.firstChild(); child; child = child->tree().nextSibling()) {
         if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(child->view()))
@@ -172,7 +180,7 @@
 
 static WebLayerPositionConstraint computePositionConstraint(const RenderLayer* layer)
 {
-    ASSERT(layer->compositedLayerMapping());
+    ASSERT(layer->hasCompositedLayerMapping());
     do {
         if (layer->renderer()->style()->position() == FixedPosition) {
             const RenderObject* fixedPositionObject = layer->renderer();
@@ -185,14 +193,14 @@
 
         // Composited layers that inherit a fixed position state will be positioned with respect to the nearest compositedLayerMapping's GraphicsLayer.
         // So, once we find a layer that has its own compositedLayerMapping, we can stop searching for a fixed position RenderObject.
-    } while (layer && layer->compositedLayerMapping());
+    } while (layer && !layer->hasCompositedLayerMapping());
     return WebLayerPositionConstraint();
 }
 
 void ScrollingCoordinator::updateLayerPositionConstraint(RenderLayer* layer)
 {
-    ASSERT(layer->compositedLayerMapping());
-    CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMapping();
+    ASSERT(layer->hasCompositedLayerMapping());
+    CompositedLayerMappingPtr compositedLayerMapping = layer->compositedLayerMapping();
     GraphicsLayer* mainLayer = compositedLayerMapping->childForSuperlayers();
 
     // Avoid unnecessary commits
@@ -219,18 +227,18 @@
 static PassOwnPtr<WebScrollbarLayer> createScrollbarLayer(Scrollbar* scrollbar)
 {
     ScrollbarTheme* theme = scrollbar->theme();
-    WebKit::WebScrollbarThemePainter painter(theme, scrollbar);
-    OwnPtr<WebKit::WebScrollbarThemeGeometry> geometry(WebKit::WebScrollbarThemeGeometryNative::create(theme));
+    blink::WebScrollbarThemePainter painter(theme, scrollbar);
+    OwnPtr<blink::WebScrollbarThemeGeometry> geometry(blink::WebScrollbarThemeGeometryNative::create(theme));
 
-    OwnPtr<WebScrollbarLayer> scrollbarLayer = adoptPtr(WebKit::Platform::current()->compositorSupport()->createScrollbarLayer(new WebKit::WebScrollbarImpl(scrollbar), painter, geometry.leakPtr()));
+    OwnPtr<WebScrollbarLayer> scrollbarLayer = adoptPtr(blink::Platform::current()->compositorSupport()->createScrollbarLayer(new blink::WebScrollbarImpl(scrollbar), painter, geometry.leakPtr()));
     GraphicsLayer::registerContentsLayer(scrollbarLayer->layer());
     return scrollbarLayer.release();
 }
 
 PassOwnPtr<WebScrollbarLayer> ScrollingCoordinator::createSolidColorScrollbarLayer(ScrollbarOrientation orientation, int thumbThickness, bool isLeftSideVerticalScrollbar)
 {
-    WebKit::WebScrollbar::Orientation webOrientation = (orientation == HorizontalScrollbar) ? WebKit::WebScrollbar::Horizontal : WebKit::WebScrollbar::Vertical;
-    OwnPtr<WebScrollbarLayer> scrollbarLayer = adoptPtr(WebKit::Platform::current()->compositorSupport()->createSolidColorScrollbarLayer(webOrientation, thumbThickness, isLeftSideVerticalScrollbar));
+    blink::WebScrollbar::Orientation webOrientation = (orientation == HorizontalScrollbar) ? blink::WebScrollbar::Horizontal : blink::WebScrollbar::Vertical;
+    OwnPtr<WebScrollbarLayer> scrollbarLayer = adoptPtr(blink::Platform::current()->compositorSupport()->createSolidColorScrollbarLayer(webOrientation, thumbThickness, isLeftSideVerticalScrollbar));
     GraphicsLayer::registerContentsLayer(scrollbarLayer->layer());
     return scrollbarLayer.release();
 }
@@ -257,7 +265,7 @@
     scrollbarGraphicsLayer->setDrawsContent(false);
 }
 
-WebScrollbarLayer* ScrollingCoordinator::addWebScrollbarLayer(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, PassOwnPtr<WebKit::WebScrollbarLayer> scrollbarLayer)
+WebScrollbarLayer* ScrollingCoordinator::addWebScrollbarLayer(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, PassOwnPtr<blink::WebScrollbarLayer> scrollbarLayer)
 {
     ScrollbarMap& scrollbars = orientation == HorizontalScrollbar ? m_horizontalScrollbars : m_verticalScrollbars;
     return scrollbars.add(scrollableArea, scrollbarLayer).iterator->value.get();
@@ -493,6 +501,18 @@
     setTouchEventTargetRects(touchEventTargetRects);
 }
 
+void ScrollingCoordinator::reset()
+{
+    m_horizontalScrollbars.clear();
+    m_verticalScrollbars.clear();
+    m_layersWithTouchRects.clear();
+    m_wasFrameScrollable = false;
+
+    // This is retained for testing.
+    m_lastMainThreadScrollingReasons = 0;
+    setShouldUpdateScrollLayerPositionOnMainThread(m_lastMainThreadScrollingReasons);
+}
+
 // Note that in principle this could be called more often than computeTouchEventTargetRects, for
 // example during a non-composited scroll (although that's not yet implemented - crbug.com/261307).
 void ScrollingCoordinator::setTouchEventTargetRects(const LayerHitTestRects& layerRects)
@@ -510,7 +530,9 @@
         WebVector<WebRect> webRects(iter->value.size());
         for (size_t i = 0; i < iter->value.size(); ++i)
             webRects[i] = enclosingIntRect(iter->value[i]);
-        CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMapping();
+        // This should be ensured by convertLayerRectsToEnclosingCompositedLayer above.
+        ASSERT(layer->hasCompositedLayerMapping());
+        CompositedLayerMappingPtr compositedLayerMapping = layer->compositedLayerMapping();
         // If the layer is using composited scrolling, then it's the contents that these
         // rects apply to.
         GraphicsLayer* graphicsLayer = compositedLayerMapping->scrollingContentsLayer();
@@ -523,10 +545,14 @@
 
     // If there are any layers left that we haven't updated, clear them out.
     for (HashSet<const RenderLayer*>::iterator it = oldLayersWithTouchRects.begin(); it != oldLayersWithTouchRects.end(); ++it) {
-        if (CompositedLayerMapping* compositedLayerMapping = (*it)->compositedLayerMapping()) {
-            GraphicsLayer* graphicsLayer = compositedLayerMapping->scrollingContentsLayer();
+        // FIXME: This is a bug. What's happening here is that we're clearing touch regions for
+        // layers that we didn't visit above. That assumes a 1:1 mapping between RenderLayer and
+        // the graphics layer that owns the touch rects. This is false in the case of
+        // HasOwnBackingButPaintsIntoAncestor and will be extra-false in the world of squashing.
+        if ((*it)->hasCompositedLayerMapping()) {
+            GraphicsLayer* graphicsLayer = (*it)->compositedLayerMapping()->scrollingContentsLayer();
             if (!graphicsLayer)
-                graphicsLayer = compositedLayerMapping->mainGraphicsLayer();
+                graphicsLayer = (*it)->compositedLayerMapping()->mainGraphicsLayer();
             graphicsLayer->platformLayer()->setTouchEventHandlerRegion(WebVector<WebRect>());
         }
     }
@@ -553,7 +579,7 @@
 void ScrollingCoordinator::updateScrollParentForGraphicsLayer(GraphicsLayer* child, RenderLayer* parent)
 {
     WebLayer* scrollParentWebLayer = 0;
-    if (parent && parent->compositedLayerMapping())
+    if (parent && parent->hasCompositedLayerMapping())
         scrollParentWebLayer = scrollingWebLayerForGraphicsLayer(parent->compositedLayerMapping()->parentForSublayers());
 
     child->setScrollParent(scrollParentWebLayer);
@@ -562,7 +588,7 @@
 void ScrollingCoordinator::updateClipParentForGraphicsLayer(GraphicsLayer* child, RenderLayer* parent)
 {
     WebLayer* clipParentWebLayer = 0;
-    if (parent && parent->compositedLayerMapping())
+    if (parent && parent->hasCompositedLayerMapping())
         clipParentWebLayer = scrollingWebLayerForGraphicsLayer(parent->compositedLayerMapping()->parentForSublayers());
 
     child->setClipParent(clipParentWebLayer);
@@ -587,8 +613,10 @@
 
 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainThreadScrollingReasons reasons)
 {
-    if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainFrame()->view()))
+    if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainFrame()->view())) {
+        m_lastMainThreadScrollingReasons = reasons;
         scrollLayer->setShouldScrollOnMainThread(reasons);
+    }
 }
 
 void ScrollingCoordinator::pageDestroyed()
@@ -853,8 +881,11 @@
 
 MainThreadScrollingReasons ScrollingCoordinator::mainThreadScrollingReasons() const
 {
+    // The main thread scrolling reasons are applicable to scrolls of the main
+    // frame. If it does not exist or if it is not scrollable, there is no
+    // reason to force main thread scrolling.
     FrameView* frameView = m_page->mainFrame()->view();
-    if (!frameView)
+    if (!frameView || !frameView->isScrollable())
         return static_cast<MainThreadScrollingReasons>(0);
 
     MainThreadScrollingReasons mainThreadScrollingReasons = (MainThreadScrollingReasons)0;
@@ -890,7 +921,14 @@
 
 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const
 {
-    return mainThreadScrollingReasonsAsText(mainThreadScrollingReasons());
+    return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons);
+}
+
+bool ScrollingCoordinator::frameViewIsScrollableIsDirty() const
+{
+    FrameView* frameView = m_page->mainFrame()->view();
+    bool frameIsScrollable = frameView && frameView->isScrollable();
+    return frameIsScrollable != m_wasFrameScrollable;
 }
 
 } // namespace WebCore
diff --git a/Source/core/page/scrolling/ScrollingCoordinator.h b/Source/core/page/scrolling/ScrollingCoordinator.h
index 0c42913..3acfe9a 100644
--- a/Source/core/page/scrolling/ScrollingCoordinator.h
+++ b/Source/core/page/scrolling/ScrollingCoordinator.h
@@ -32,7 +32,7 @@
 #include "platform/scroll/ScrollTypes.h"
 #include "wtf/text/WTFString.h"
 
-namespace WebKit {
+namespace blink {
 class WebLayer;
 class WebScrollbarLayer;
 }
@@ -66,7 +66,7 @@
     // Should be called after compositing has been updated.
     void updateAfterCompositingChange();
 
-    bool needsToUpdateAfterCompositingChange() const { return m_scrollGestureRegionIsDirty || m_touchEventTargetRectsAreDirty; }
+    bool needsToUpdateAfterCompositingChange() const { return m_scrollGestureRegionIsDirty || m_touchEventTargetRectsAreDirty || frameViewIsScrollableIsDirty(); }
 
     // Should be called whenever a wheel event handler is added or removed in the
     // frame view's underlying document.
@@ -95,7 +95,7 @@
     MainThreadScrollingReasons mainThreadScrollingReasons() const;
     bool shouldUpdateScrollLayerPositionOnMainThread() const { return mainThreadScrollingReasons() != 0; }
 
-    PassOwnPtr<WebKit::WebScrollbarLayer> createSolidColorScrollbarLayer(ScrollbarOrientation, int thumbThickness, bool isLeftSideVerticalScrollbar);
+    PassOwnPtr<blink::WebScrollbarLayer> createSolidColorScrollbarLayer(ScrollbarOrientation, int thumbThickness, bool isLeftSideVerticalScrollbar);
 
     void willDestroyScrollableArea(ScrollableArea*);
     // Returns true if the coordinator handled this change.
@@ -115,6 +115,10 @@
 
     void updateTouchEventTargetRectsIfNeeded();
 
+    // For testing purposes only. This ScrollingCoordinator is reused between layout test, and must be reset
+    // for the results to be valid.
+    void reset();
+
 protected:
     explicit ScrollingCoordinator(Page*);
 
@@ -140,7 +144,7 @@
     bool hasVisibleSlowRepaintViewportConstrainedObjects(FrameView*) const;
     void updateShouldUpdateScrollLayerPositionOnMainThread();
 
-    static WebKit::WebLayer* scrollingWebLayerForScrollableArea(ScrollableArea*);
+    static blink::WebLayer* scrollingWebLayerForScrollableArea(ScrollableArea*);
 
     bool touchHitTestingEnabled() const;
     void setShouldHandleScrollGestureOnMainThreadRegion(const Region&);
@@ -148,15 +152,20 @@
     void computeTouchEventTargetRects(LayerHitTestRects&);
     void setWheelEventHandlerCount(unsigned);
 
-    WebKit::WebScrollbarLayer* addWebScrollbarLayer(ScrollableArea*, ScrollbarOrientation, PassOwnPtr<WebKit::WebScrollbarLayer>);
-    WebKit::WebScrollbarLayer* getWebScrollbarLayer(ScrollableArea*, ScrollbarOrientation);
+    blink::WebScrollbarLayer* addWebScrollbarLayer(ScrollableArea*, ScrollbarOrientation, PassOwnPtr<blink::WebScrollbarLayer>);
+    blink::WebScrollbarLayer* getWebScrollbarLayer(ScrollableArea*, ScrollbarOrientation);
     void removeWebScrollbarLayer(ScrollableArea*, ScrollbarOrientation);
 
+    bool frameViewIsScrollableIsDirty() const;
 
-    typedef HashMap<ScrollableArea*, OwnPtr<WebKit::WebScrollbarLayer> > ScrollbarMap;
+    typedef HashMap<ScrollableArea*, OwnPtr<blink::WebScrollbarLayer> > ScrollbarMap;
     ScrollbarMap m_horizontalScrollbars;
     ScrollbarMap m_verticalScrollbars;
     HashSet<const RenderLayer*> m_layersWithTouchRects;
+    bool m_wasFrameScrollable;
+
+    // This is retained for testing.
+    MainThreadScrollingReasons m_lastMainThreadScrollingReasons;
 };
 
 } // namespace WebCore