Cherry-pick "Add setting for disabling compositor touch hit testing"

Bug 11070366

Taken from
https://src.chromium.org/viewvc/blink?view=revision&revision=158956 plus
ScrollingCoordinator.cpp updated with additional #include not present in
the M30 branch.

Original description:

BUG=303945

Review URL: https://codereview.chromium.org/25507008

Change-Id: Ifd72104105cd19dde5393ef901e6d45145ae02fc
git-svn-id: svn://svn.chromium.org/blink/trunk@158956 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/LayoutTests/fast/events/touch/compositor-touch-hit-rects-disabled-expected.txt b/LayoutTests/fast/events/touch/compositor-touch-hit-rects-disabled-expected.txt
new file mode 100644
index 0000000..ab22494
--- /dev/null
+++ b/LayoutTests/fast/events/touch/compositor-touch-hit-rects-disabled-expected.txt
@@ -0,0 +1,5 @@
+This tests verifies that hit testing can be disabled.
+
+normalFlow: no rects
+
+
diff --git a/LayoutTests/fast/events/touch/compositor-touch-hit-rects-disabled.html b/LayoutTests/fast/events/touch/compositor-touch-hit-rects-disabled.html
new file mode 100644
index 0000000..33bcd6f
--- /dev/null
+++ b/LayoutTests/fast/events/touch/compositor-touch-hit-rects-disabled.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href="resources/compositor-touch-hit-rects.css">
+<style>
+</style>
+</head>
+<body>
+<script>
+if (window.internals) {
+  window.internals.settings.setCompositorTouchHitTesting(false);
+}
+</script>
+<p id="description">
+This tests verifies that hit testing can be disabled.
+</p>
+
+<div id="tests">
+  <div class="testcase" id="normalFlow">
+    Normal
+    <span>flow</span>.
+  </div>
+</div>
+
+<div id="console"></div>
+<div style="height: 1000px;"></div>
+<script src="resources/compositor-touch-hit-rects.js"></script>
+</body>
diff --git a/Source/core/page/Settings.in b/Source/core/page/Settings.in
index e4c6f77..54c6e0b 100644
--- a/Source/core/page/Settings.in
+++ b/Source/core/page/Settings.in
@@ -102,6 +102,7 @@
 deviceSupportsMouse initial=true
 
 touchAdjustmentEnabled initial=true
+compositorTouchHitTesting initial=true
 
 fixedPositionCreatesStackingContext initial=false
 syncXHRInDocumentsEnabled initial=true
diff --git a/Source/core/page/scrolling/ScrollingCoordinator.cpp b/Source/core/page/scrolling/ScrollingCoordinator.cpp
index 30975d1..8aa9e95 100644
--- a/Source/core/page/scrolling/ScrollingCoordinator.cpp
+++ b/Source/core/page/scrolling/ScrollingCoordinator.cpp
@@ -34,6 +34,7 @@
 #include "core/page/Frame.h"
 #include "core/page/FrameView.h"
 #include "core/page/Page.h"
+#include "core/page/Settings.h"
 #include "core/platform/PlatformWheelEvent.h"
 #include "core/platform/ScrollAnimator.h"
 #include "core/platform/ScrollbarTheme.h"
@@ -102,7 +103,8 @@
 bool ScrollingCoordinator::touchHitTestingEnabled() const
 {
     RenderView* contentRenderer = m_page->mainFrame()->contentRenderer();
-    return RuntimeEnabledFeatures::touchEnabled() && contentRenderer && contentRenderer->usesCompositing();
+    Settings* settings = m_page->mainFrame()->document()->settings();
+    return RuntimeEnabledFeatures::touchEnabled() && settings->compositorTouchHitTesting() && contentRenderer && contentRenderer->usesCompositing();
 }
 
 void ScrollingCoordinator::setShouldHandleScrollGestureOnMainThreadRegion(const Region& region)
diff --git a/Source/web/WebSettingsImpl.cpp b/Source/web/WebSettingsImpl.cpp
index b69c54d..a61066d 100644
--- a/Source/web/WebSettingsImpl.cpp
+++ b/Source/web/WebSettingsImpl.cpp
@@ -682,6 +682,11 @@
     m_settings->setCompositedScrollingForFramesEnabled(enabled);
 }
 
+void WebSettingsImpl::setCompositorTouchHitTesting(bool enabled)
+{
+    m_settings->setCompositorTouchHitTesting(enabled);
+}
+
 void WebSettingsImpl::setSelectTrailingWhitespaceEnabled(bool enabled)
 {
     m_settings->setSelectTrailingWhitespaceEnabled(enabled);
diff --git a/Source/web/WebSettingsImpl.h b/Source/web/WebSettingsImpl.h
index 9908d74..7ba4126 100644
--- a/Source/web/WebSettingsImpl.h
+++ b/Source/web/WebSettingsImpl.h
@@ -74,6 +74,7 @@
     virtual void setAutoZoomFocusedNodeToLegibleScale(bool);
     virtual void setCaretBrowsingEnabled(bool);
     virtual void setCompositedScrollingForFramesEnabled(bool);
+    virtual void setCompositorTouchHitTesting(bool);
     virtual void setCookieEnabled(bool);
     virtual void setCursiveFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON);
     virtual void setDNSPrefetchingEnabled(bool);
diff --git a/public/web/WebSettings.h b/public/web/WebSettings.h
index 56668da..b5d13c7 100644
--- a/public/web/WebSettings.h
+++ b/public/web/WebSettings.h
@@ -81,6 +81,7 @@
     virtual void setAuthorAndUserStylesEnabled(bool) = 0;
     virtual void setCaretBrowsingEnabled(bool) = 0;
     virtual void setCompositedScrollingForFramesEnabled(bool) = 0;
+    virtual void setCompositorTouchHitTesting(bool) = 0;
     virtual void setCookieEnabled(bool) = 0;
     virtual void setCursiveFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON) = 0;
     virtual void setDNSPrefetchingEnabled(bool) = 0;