Fix flattening for scrollable areas.

Previously we flattened the scrollingContentsLayer, but not the
graphics or scrolling layers. This resulted in incorrect hit testing
sometimes.

BUG=543655

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

Cr-Commit-Position: refs/heads/master@{#364120}
diff --git a/content/browser/renderer_host/input/composited_scrolling_browsertest.cc b/content/browser/renderer_host/input/composited_scrolling_browsertest.cc
new file mode 100644
index 0000000..e776a8e
--- /dev/null
+++ b/content/browser/renderer_host/input/composited_scrolling_browsertest.cc
@@ -0,0 +1,167 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/bind.h"
+#include "base/command_line.h"
+#include "base/run_loop.h"
+#include "base/strings/utf_string_conversions.h"
+#include "cc/base/math_util.h"
+#include "content/browser/renderer_host/input/synthetic_gesture.h"
+#include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h"
+#include "content/browser/renderer_host/render_widget_host_impl.h"
+#include "content/browser/web_contents/web_contents_impl.h"
+#include "content/common/input/synthetic_gesture_params.h"
+#include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/common/content_switches.h"
+#include "content/public/test/browser_test_utils.h"
+#include "content/public/test/content_browser_test.h"
+#include "content/public/test/content_browser_test_utils.h"
+#include "content/public/test/test_utils.h"
+#include "content/shell/browser/shell.h"
+
+namespace {
+
+const char kCompositedScrollingDataURL[] =
+    "data:text/html;charset=utf-8,"
+    "<!DOCTYPE html>"
+    "<meta name='viewport' content='width=device-width'/>"
+    "<style>"
+    "#scroller {"
+    "  width:500px;"
+    "  height:500px;"
+    "  overflow:scroll;"
+    "  transform: rotateX(-30deg);"
+    "}"
+
+    "#content {"
+    "  background-color:red;"
+    "  width:1000px;"
+    "  height:1000px;"
+    "}"
+    "</style>"
+    "<div id='scroller'>"
+    "  <div id='content'>"
+    "  </div>"
+    "</div>"
+    "<script>"
+    "  document.title='ready';"
+    "</script>";
+
+}  // namespace
+
+namespace content {
+
+
+class CompositedScrollingBrowserTest : public ContentBrowserTest {
+ public:
+  CompositedScrollingBrowserTest() {}
+  ~CompositedScrollingBrowserTest() override {}
+
+  void SetUpCommandLine(base::CommandLine* cmd) override {
+    cmd->AppendSwitch(switches::kEnablePreferCompositingToLCDText);
+  }
+
+  RenderWidgetHostImpl* GetWidgetHost() {
+    return RenderWidgetHostImpl::From(
+        shell()->web_contents()->GetRenderViewHost()->GetWidget());
+  }
+
+  void OnSyntheticGestureCompleted(SyntheticGesture::Result result) {
+    EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result);
+    runner_->Quit();
+  }
+
+ protected:
+  void LoadURL() {
+    const GURL data_url(kCompositedScrollingDataURL);
+    NavigateToURL(shell(), data_url);
+
+    RenderWidgetHostImpl* host = GetWidgetHost();
+    scoped_refptr<FrameWatcher> frame_watcher(new FrameWatcher());
+    host->GetProcess()->AddFilter(frame_watcher.get());
+    host->GetView()->SetSize(gfx::Size(400, 400));
+
+    base::string16 ready_title(base::ASCIIToUTF16("ready"));
+    TitleWatcher watcher(shell()->web_contents(), ready_title);
+    ignore_result(watcher.WaitAndGetTitle());
+
+    // We need to wait until at least one frame has been composited
+    // otherwise the injection of the synthetic gestures may get
+    // dropped because of MainThread/Impl thread sync of touch event
+    // regions.
+    frame_watcher->WaitFrames(1);
+  }
+
+  // ContentBrowserTest:
+  int ExecuteScriptAndExtractInt(const std::string& script) {
+    int value = 0;
+    EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
+        shell()->web_contents(),
+        "domAutomationController.send(" + script + ")",
+        &value));
+    return value;
+  }
+
+  int GetScrollTop() {
+    return ExecuteScriptAndExtractInt(
+        "document.getElementById(\"scroller\").scrollTop");
+  }
+
+  // Generate touch events for a synthetic scroll from |point| for |distance|.
+  // Returns the distance scrolled.
+  int DoTouchScroll(const gfx::Point& point, const gfx::Vector2d& distance) {
+    EXPECT_EQ(0, GetScrollTop());
+
+    int scrollHeight = ExecuteScriptAndExtractInt(
+        "document.getElementById('scroller').scrollHeight");
+    EXPECT_EQ(1000, scrollHeight);
+
+    SyntheticSmoothScrollGestureParams params;
+    params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
+    params.anchor = gfx::PointF(point);
+    params.distances.push_back(-distance);
+
+    runner_ = new MessageLoopRunner();
+
+    scoped_ptr<SyntheticSmoothScrollGesture> gesture(
+        new SyntheticSmoothScrollGesture(params));
+    GetWidgetHost()->QueueSyntheticGesture(
+        gesture.Pass(),
+        base::Bind(&CompositedScrollingBrowserTest::OnSyntheticGestureCompleted,
+                   base::Unretained(this)));
+
+    // Runs until we get the OnSyntheticGestureCompleted callback
+    runner_->Run();
+    runner_ = NULL;
+
+    return GetScrollTop();
+  }
+
+ private:
+  scoped_refptr<MessageLoopRunner> runner_;
+
+  DISALLOW_COPY_AND_ASSIGN(CompositedScrollingBrowserTest);
+};
+
+// Verify transforming a scroller doesn't prevent it from scrolling. See
+// crbug.com/543655 for a case where this was broken.
+// Disabled on MacOS because it doesn't support touch input.
+// Disabled on Android due to flakiness, see https://crbug.com/376668.
+#if defined(OS_MACOSX) || defined(OS_ANDROID)
+#define MAYBE_Scroll3DTransformedScroller DISABLED_Scroll3DTransformedScroller
+#else
+#define MAYBE_Scroll3DTransformedScroller Scroll3DTransformedScroller
+#endif
+IN_PROC_BROWSER_TEST_F(CompositedScrollingBrowserTest,
+                       MAYBE_Scroll3DTransformedScroller) {
+  LoadURL();
+  int scrollDistance =
+      DoTouchScroll(gfx::Point(50, 150), gfx::Vector2d(0, 100));
+  // The scroll distance is increased due to the rotation of the scroller.
+  EXPECT_EQ(std::floor(100 / std::cos(cc::MathUtil::Deg2Rad(30.f))) - 1,
+            scrollDistance);
+}
+
+}  // namespace content
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 5dfc0a5..3bbd37b 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -243,6 +243,7 @@
       'browser/message_port_provider_browsertest.cc',
       'browser/mojo_shell_browsertest.cc',
       'browser/net_info_browsertest.cc',
+      'browser/renderer_host/input/composited_scrolling_browsertest.cc',
       'browser/renderer_host/input/touch_action_browsertest.cc',
       'browser/renderer_host/input/touch_input_browsertest.cc',
       'browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc',
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations
index 8fc58bf1..f7d9c0c 100644
--- a/third_party/WebKit/LayoutTests/TestExpectations
+++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -1307,6 +1307,61 @@
 crbug.com/532643 [ Mac ] virtual/trustedeventsdefaultaction/fast/events/hit-test-cache-scrollbar-no-crash.html [ Pass Failure ]
 crbug.com/532643 [ Mac ] virtual/pointerevent/fast/events/hit-test-cache-scrollbar-no-crash.html [ Pass Failure ]
 
+crbug.com/543655 compositing/layer-creation/fixed-position-in-fixed-overflow.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/accelerated-overflow-scroll-should-not-affect-perspective.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/clear-scroll-parent.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/composited-scrolling-paint-phases.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/content-gains-scrollbars.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/overflow-scrollbar-layers.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/reparented-scrollbars-non-sc-anc.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/scroll-parent-absolute.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/scroll-parent-with-non-stacking-context-composited-ancestor.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/scrolling-content-clip-to-viewport.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/scrolling-without-painting.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/universal-accelerated-overflow-scroll.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/updating-scrolling-content.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/scrollbars/nested-overlay-scrollbars.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/squashing/composited-bounds-for-negative-z.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/update-paint-phases.html [ NeedsRebaseline ]
+crbug.com/543655 fast/repaint/overflow-move-after-scroll.html [ NeedsRebaseline ]
+crbug.com/543655 fast/repaint/overflow-scroll-after-move.html [ NeedsRebaseline ]
+crbug.com/543655 paint/invalidation/invalidate-after-composited-scroll.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/layer-creation/fixed-position-nonscrollable-body-mismatch-containers.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/selection-gaps-after-removing-scrolling-contents.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/selection-gaps-toggling.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/selection-gaps-toggling-with-scrolling-contents.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/overflow/textarea-scroll-touch.html [ NeedsRebaseline ]
+crbug.com/543655 compositing/repaint/should-not-clip-composited-overflow-scrolling-layer.html [ NeedsRebaseline ]
+crbug.com/543655 paint/selection/selection-within-composited-scroller.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/syncpaint/compositing/repaint/should-not-clip-composited-overflow-scrolling-layer.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/syncpaint/paint/selection/selection-within-composited-scroller.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/syncpaint/fast/repaint/overflow-scroll-after-move.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/syncpaint/fast/repaint/overflow-move-after-scroll.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/syncpaint/paint/invalidation/invalidate-after-composited-scroll.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/accelerated-overflow-scroll-should-not-affect-perspective.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/clear-scroll-parent.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/composited-scrolling-paint-phases.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/content-gains-scrollbars.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-auto-with-touch-toggle.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-auto-with-touch.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-overlay-with-touch.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-scrollbar-layers.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/reparented-scrollbars-non-sc-anc.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/scroll-parent-absolute.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/scroll-parent-with-non-stacking-context-composited-ancestor.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/scrolling-content-clip-to-viewport.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/scrolling-without-painting.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-after-removing-scrolling-contents.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-toggling-with-scrolling-contents.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-toggling.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/text-color-change.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/text-match-highlight.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/textarea-scroll-touch.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/universal-accelerated-overflow-scroll.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-container-and-content.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-container.html [ NeedsRebaseline ]
+crbug.com/543655 virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-content.html [ NeedsRebaseline ]
+
 # The Win10 result for fast/text/emoji-font-fallback-win.html does not match the description
 crbug.com/527044 [ Win10 ] fast/text/emoji-font-fallback-win.html [ Failure ]
 
diff --git a/third_party/WebKit/LayoutTests/compositing/layer-creation/fixed-position-in-fixed-overflow-expected.txt b/third_party/WebKit/LayoutTests/compositing/layer-creation/fixed-position-in-fixed-overflow-expected.txt
index b0058b6..7117f5be 100644
--- a/third_party/WebKit/LayoutTests/compositing/layer-creation/fixed-position-in-fixed-overflow-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/layer-creation/fixed-position-in-fixed-overflow-expected.txt
@@ -9,14 +9,15 @@
         {
           "position": [8, 13],
           "bounds": [800, 600],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [785, 600],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [785, 1000],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "children": [
                     {
diff --git a/third_party/WebKit/LayoutTests/compositing/overflow/accelerated-overflow-scroll-should-not-affect-perspective-expected.txt b/third_party/WebKit/LayoutTests/compositing/overflow/accelerated-overflow-scroll-should-not-affect-perspective-expected.txt
index 39c25efe..ad67ede 100644
--- a/third_party/WebKit/LayoutTests/compositing/overflow/accelerated-overflow-scroll-should-not-affect-perspective-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/overflow/accelerated-overflow-scroll-should-not-affect-perspective-expected.txt
@@ -9,6 +9,7 @@
         {
           "position": [8, 8],
           "bounds": [200, 200],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
diff --git a/third_party/WebKit/LayoutTests/compositing/overflow/clear-scroll-parent-expected.txt b/third_party/WebKit/LayoutTests/compositing/overflow/clear-scroll-parent-expected.txt
index 21ff09a..82736418 100644
--- a/third_party/WebKit/LayoutTests/compositing/overflow/clear-scroll-parent-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/overflow/clear-scroll-parent-expected.txt
@@ -9,15 +9,16 @@
         {
           "position": [8, 8],
           "bounds": [308, 208],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [4, 4],
               "bounds": [285, 200],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [285, 530],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
diff --git a/third_party/WebKit/LayoutTests/compositing/overflow/composited-scrolling-paint-phases-expected.txt b/third_party/WebKit/LayoutTests/compositing/overflow/composited-scrolling-paint-phases-expected.txt
index 6d86be9..4013b92d 100644
--- a/third_party/WebKit/LayoutTests/compositing/overflow/composited-scrolling-paint-phases-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/overflow/composited-scrolling-paint-phases-expected.txt
@@ -45,6 +45,7 @@
             {
               "position": [28, 20],
               "bounds": [202, 202],
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "paintingPhases": [
                 "GraphicsLayerPaintBackground",
@@ -55,6 +56,7 @@
                 {
                   "position": [1, 1],
                   "bounds": [185, 185],
+                  "shouldFlattenTransform": false,
                   "paintingPhases": [
                     "GraphicsLayerPaintBackground",
                     "GraphicsLayerPaintForeground",
@@ -63,7 +65,6 @@
                   "children": [
                     {
                       "bounds": [185, 715],
-                      "shouldFlattenTransform": false,
                       "drawsContent": true,
                       "paintingPhases": [
                         "GraphicsLayerPaintForeground",
diff --git a/third_party/WebKit/LayoutTests/compositing/overflow/content-gains-scrollbars-expected.txt b/third_party/WebKit/LayoutTests/compositing/overflow/content-gains-scrollbars-expected.txt
index d243ed8b..10f2551 100644
--- a/third_party/WebKit/LayoutTests/compositing/overflow/content-gains-scrollbars-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/overflow/content-gains-scrollbars-expected.txt
@@ -9,14 +9,15 @@
         {
           "position": [8, 13],
           "bounds": [100, 100],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [85, 100],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [85, 200],
-                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [10, 200]
@@ -39,14 +40,15 @@
         {
           "position": [8, 13],
           "bounds": [100, 100],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [100, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [200, 85],
-                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [200, 10]
@@ -69,14 +71,15 @@
         {
           "position": [8, 13],
           "bounds": [100, 100],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [200, 200],
-                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [200, 200]
diff --git a/third_party/WebKit/LayoutTests/compositing/overflow/overflow-scrollbar-layers-expected.txt b/third_party/WebKit/LayoutTests/compositing/overflow/overflow-scrollbar-layers-expected.txt
index d243ed8b..10f2551 100644
--- a/third_party/WebKit/LayoutTests/compositing/overflow/overflow-scrollbar-layers-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/overflow/overflow-scrollbar-layers-expected.txt
@@ -9,14 +9,15 @@
         {
           "position": [8, 13],
           "bounds": [100, 100],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [85, 100],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [85, 200],
-                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [10, 200]
@@ -39,14 +40,15 @@
         {
           "position": [8, 13],
           "bounds": [100, 100],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [100, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [200, 85],
-                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [200, 10]
@@ -69,14 +71,15 @@
         {
           "position": [8, 13],
           "bounds": [100, 100],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [200, 200],
-                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [200, 200]
diff --git a/third_party/WebKit/LayoutTests/compositing/overflow/reparented-scrollbars-non-sc-anc-expected.txt b/third_party/WebKit/LayoutTests/compositing/overflow/reparented-scrollbars-non-sc-anc-expected.txt
index b11e3e4..5244c6e 100644
--- a/third_party/WebKit/LayoutTests/compositing/overflow/reparented-scrollbars-non-sc-anc-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/overflow/reparented-scrollbars-non-sc-anc-expected.txt
@@ -24,14 +24,15 @@
                       "children": [
                         {
                           "bounds": [1200, 1000],
+                          "shouldFlattenTransform": false,
                           "drawsContent": true,
                           "children": [
                             {
                               "bounds": [1200, 1000],
+                              "shouldFlattenTransform": false,
                               "children": [
                                 {
                                   "bounds": [1200, 10000],
-                                  "shouldFlattenTransform": false,
                                   "drawsContent": true
                                 }
                               ]
diff --git a/third_party/WebKit/LayoutTests/compositing/overflow/scroll-parent-absolute-expected.txt b/third_party/WebKit/LayoutTests/compositing/overflow/scroll-parent-absolute-expected.txt
index a861f58..631b21d 100644
--- a/third_party/WebKit/LayoutTests/compositing/overflow/scroll-parent-absolute-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/overflow/scroll-parent-absolute-expected.txt
@@ -13,15 +13,16 @@
               "position": [8, 8],
               "bounds": [500, 500],
               "contentsOpaque": true,
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "backgroundColor": "#0000FF",
               "children": [
                 {
                   "bounds": [485, 485],
+                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [485, 5000],
-                      "shouldFlattenTransform": false,
                       "drawsContent": true
                     }
                   ]
diff --git a/third_party/WebKit/LayoutTests/compositing/overflow/scroll-parent-with-non-stacking-context-composited-ancestor-expected.txt b/third_party/WebKit/LayoutTests/compositing/overflow/scroll-parent-with-non-stacking-context-composited-ancestor-expected.txt
index eca105b..de97ec2 100644
--- a/third_party/WebKit/LayoutTests/compositing/overflow/scroll-parent-with-non-stacking-context-composited-ancestor-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/overflow/scroll-parent-with-non-stacking-context-composited-ancestor-expected.txt
@@ -16,15 +16,16 @@
           "children": [
             {
               "bounds": [102, 102],
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "children": [
                 {
                   "position": [1, 1],
                   "bounds": [100, 100],
+                  "shouldFlattenTransform": false,
                   "children": [
                     {
-                      "bounds": [100, 180],
-                      "shouldFlattenTransform": false
+                      "bounds": [100, 180]
                     }
                   ]
                 }
diff --git a/third_party/WebKit/LayoutTests/compositing/overflow/scrolling-content-clip-to-viewport-expected.txt b/third_party/WebKit/LayoutTests/compositing/overflow/scrolling-content-clip-to-viewport-expected.txt
index a74270d..e456a58 100644
--- a/third_party/WebKit/LayoutTests/compositing/overflow/scrolling-content-clip-to-viewport-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/overflow/scrolling-content-clip-to-viewport-expected.txt
@@ -8,14 +8,15 @@
       "children": [
         {
           "bounds": [320, 340],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [305, 325],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [305, 1224],
-                  "shouldFlattenTransform": false
+                  "bounds": [305, 1224]
                 }
               ]
             },
diff --git a/third_party/WebKit/LayoutTests/compositing/overflow/scrolling-without-painting-expected.txt b/third_party/WebKit/LayoutTests/compositing/overflow/scrolling-without-painting-expected.txt
index 466febf8..11f017e2 100644
--- a/third_party/WebKit/LayoutTests/compositing/overflow/scrolling-without-painting-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/overflow/scrolling-without-painting-expected.txt
@@ -9,15 +9,16 @@
         {
           "position": [8, 8],
           "bounds": [202, 202],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [1, 1],
               "bounds": [185, 185],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [185, 1025],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
diff --git a/third_party/WebKit/LayoutTests/compositing/overflow/universal-accelerated-overflow-scroll-expected.txt b/third_party/WebKit/LayoutTests/compositing/overflow/universal-accelerated-overflow-scroll-expected.txt
index 4b59382..6ca1829 100644
--- a/third_party/WebKit/LayoutTests/compositing/overflow/universal-accelerated-overflow-scroll-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/overflow/universal-accelerated-overflow-scroll-expected.txt
@@ -12,15 +12,16 @@
             {
               "position": [10, 10],
               "bounds": [104, 104],
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "children": [
                 {
                   "position": [2, 2],
                   "bounds": [85, 85],
+                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [85, 144],
-                      "shouldFlattenTransform": false,
                       "drawsContent": true
                     }
                   ]
@@ -72,15 +73,16 @@
         {
           "position": [130, 10],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [105, 144],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -128,15 +130,16 @@
             {
               "position": [250, 10],
               "bounds": [104, 104],
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "children": [
                 {
                   "position": [2, 2],
                   "bounds": [85, 85],
+                  "shouldFlattenTransform": false,
                   "children": [
                     {
-                      "bounds": [85, 144],
-                      "shouldFlattenTransform": false
+                      "bounds": [85, 144]
                     }
                   ]
                 },
@@ -190,15 +193,16 @@
             {
               "position": [370, 10],
               "bounds": [104, 104],
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "children": [
                 {
                   "position": [2, 2],
                   "bounds": [85, 85],
+                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [85, 144],
-                      "shouldFlattenTransform": false,
                       "drawsContent": true
                     }
                   ]
@@ -250,15 +254,16 @@
         {
           "position": [10, 130],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [105, 144],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -306,15 +311,16 @@
             {
               "position": [130, 130],
               "bounds": [104, 104],
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "children": [
                 {
                   "position": [2, 2],
                   "bounds": [85, 85],
+                  "shouldFlattenTransform": false,
                   "children": [
                     {
-                      "bounds": [85, 144],
-                      "shouldFlattenTransform": false
+                      "bounds": [85, 144]
                     }
                   ]
                 },
@@ -365,15 +371,16 @@
         {
           "position": [250, 130],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [105, 144],
-                  "shouldFlattenTransform": false
+                  "bounds": [105, 144]
                 }
               ]
             },
@@ -417,15 +424,16 @@
         {
           "position": [370, 130],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [105, 144],
-                  "shouldFlattenTransform": false
+                  "bounds": [105, 144]
                 }
               ]
             },
@@ -469,15 +477,16 @@
         {
           "position": [10, 250],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [85, 144],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -529,15 +538,16 @@
         {
           "position": [130, 250],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [85, 144],
-                  "shouldFlattenTransform": false
+                  "bounds": [85, 144]
                 }
               ]
             },
@@ -588,15 +598,16 @@
         {
           "position": [250, 250],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [85, 144],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -648,15 +659,16 @@
         {
           "position": [370, 250],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [85, 144],
-                  "shouldFlattenTransform": false
+                  "bounds": [85, 144]
                 }
               ]
             },
diff --git a/third_party/WebKit/LayoutTests/compositing/overflow/updating-scrolling-content-expected.txt b/third_party/WebKit/LayoutTests/compositing/overflow/updating-scrolling-content-expected.txt
index 59fbd8e..ecb91aa 100644
--- a/third_party/WebKit/LayoutTests/compositing/overflow/updating-scrolling-content-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/overflow/updating-scrolling-content-expected.txt
@@ -9,6 +9,7 @@
         {
           "position": [8, 8],
           "bounds": [200, 200],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "repaintRects": [
             [0, 0, 185, 200]
@@ -16,10 +17,10 @@
           "children": [
             {
               "bounds": [185, 185],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [185, 1200],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "repaintRects": [
                     [0, 0, 185, 200]
diff --git a/third_party/WebKit/LayoutTests/compositing/scrollbars/nested-overlay-scrollbars-expected.txt b/third_party/WebKit/LayoutTests/compositing/scrollbars/nested-overlay-scrollbars-expected.txt
index c7027fd..fb3a8a1c 100644
--- a/third_party/WebKit/LayoutTests/compositing/scrollbars/nested-overlay-scrollbars-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/scrollbars/nested-overlay-scrollbars-expected.txt
@@ -9,29 +9,31 @@
         {
           "position": [8, 8],
           "bounds": [404, 404],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [400, 400],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [400, 704],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "children": [
                     {
                       "position": [0, 500],
                       "bounds": [204, 204],
+                      "shouldFlattenTransform": false,
                       "drawsContent": true,
                       "children": [
                         {
                           "position": [2, 2],
                           "bounds": [200, 200],
+                          "shouldFlattenTransform": false,
                           "children": [
                             {
                               "bounds": [5000, 9000],
-                              "shouldFlattenTransform": false,
                               "drawsContent": true
                             }
                           ]
diff --git a/third_party/WebKit/LayoutTests/compositing/squashing/composited-bounds-for-negative-z-expected.txt b/third_party/WebKit/LayoutTests/compositing/squashing/composited-bounds-for-negative-z-expected.txt
index 9db0a91..06ec77e6 100644
--- a/third_party/WebKit/LayoutTests/compositing/squashing/composited-bounds-for-negative-z-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/squashing/composited-bounds-for-negative-z-expected.txt
@@ -23,14 +23,15 @@
             {
               "position": [108, 100],
               "bounds": [300, 300],
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "children": [
                 {
                   "bounds": [285, 300],
+                  "shouldFlattenTransform": false,
                   "children": [
                     {
-                      "bounds": [285, 1000],
-                      "shouldFlattenTransform": false
+                      "bounds": [285, 1000]
                     }
                   ]
                 },
diff --git a/third_party/WebKit/LayoutTests/compositing/update-paint-phases-expected.txt b/third_party/WebKit/LayoutTests/compositing/update-paint-phases-expected.txt
index fe482d2c..66ab0ee 100644
--- a/third_party/WebKit/LayoutTests/compositing/update-paint-phases-expected.txt
+++ b/third_party/WebKit/LayoutTests/compositing/update-paint-phases-expected.txt
@@ -19,6 +19,7 @@
         {
           "position": [8, 8],
           "bounds": [102, 102],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "paintingPhases": [
             "GraphicsLayerPaintBackground",
@@ -29,6 +30,7 @@
             {
               "position": [1, 1],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "paintingPhases": [
                 "GraphicsLayerPaintBackground",
                 "GraphicsLayerPaintForeground",
@@ -37,7 +39,6 @@
               "children": [
                 {
                   "bounds": [85, 120],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "paintingPhases": [
                     "GraphicsLayerPaintForeground",
diff --git a/third_party/WebKit/LayoutTests/fast/repaint/overflow-move-after-scroll-expected.txt b/third_party/WebKit/LayoutTests/fast/repaint/overflow-move-after-scroll-expected.txt
index 67397b3a..8197a75f 100644
--- a/third_party/WebKit/LayoutTests/fast/repaint/overflow-move-after-scroll-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/repaint/overflow-move-after-scroll-expected.txt
@@ -9,6 +9,7 @@
         {
           "position": [10, 60],
           "bounds": [700, 400],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "repaintRects": [
             [300, 100, 120, 50],
@@ -17,10 +18,10 @@
           "children": [
             {
               "bounds": [685, 385],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [685, 600],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "repaintRects": [
                     [300, 200, 120, 50],
diff --git a/third_party/WebKit/LayoutTests/fast/repaint/overflow-scroll-after-move-expected.txt b/third_party/WebKit/LayoutTests/fast/repaint/overflow-scroll-after-move-expected.txt
index d4e783d..7a74da9 100644
--- a/third_party/WebKit/LayoutTests/fast/repaint/overflow-scroll-after-move-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/repaint/overflow-scroll-after-move-expected.txt
@@ -9,6 +9,7 @@
         {
           "position": [10, 60],
           "bounds": [300, 400],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "repaintRects": [
             [50, 160, 200, 50],
@@ -17,10 +18,10 @@
           "children": [
             {
               "bounds": [285, 385],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [285, 900],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "repaintRects": [
                     [50, 310, 200, 50],
diff --git a/third_party/WebKit/LayoutTests/paint/invalidation/invalidate-after-composited-scroll-expected.txt b/third_party/WebKit/LayoutTests/paint/invalidation/invalidate-after-composited-scroll-expected.txt
index 7a475c6..c46d6c2 100644
--- a/third_party/WebKit/LayoutTests/paint/invalidation/invalidate-after-composited-scroll-expected.txt
+++ b/third_party/WebKit/LayoutTests/paint/invalidation/invalidate-after-composited-scroll-expected.txt
@@ -9,6 +9,7 @@
         {
           "position": [300, 300],
           "bounds": [200, 200],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "repaintRects": [
             [0, 50, 100, 100]
@@ -16,10 +17,10 @@
           "children": [
             {
               "bounds": [185, 200],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [185, 4900],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "repaintRects": [
                     [0, 2400, 100, 100]
diff --git a/third_party/WebKit/LayoutTests/platform/linux/compositing/layer-creation/fixed-position-nonscrollable-body-mismatch-containers-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/compositing/layer-creation/fixed-position-nonscrollable-body-mismatch-containers-expected.txt
index 290b2c179..782a82c 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/compositing/layer-creation/fixed-position-nonscrollable-body-mismatch-containers-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/compositing/layer-creation/fixed-position-nonscrollable-body-mismatch-containers-expected.txt
@@ -11,15 +11,16 @@
         {
           "position": [8, 72],
           "bounds": [302, 302],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [1, 1],
               "bounds": [285, 285],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [285, 800],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
diff --git a/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/selection-gaps-after-removing-scrolling-contents-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/selection-gaps-after-removing-scrolling-contents-expected.txt
index b85a763..f4e88a0 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/selection-gaps-after-removing-scrolling-contents-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/selection-gaps-after-removing-scrolling-contents-expected.txt
@@ -25,15 +25,16 @@
           "position": [8, 68],
           "bounds": [300, 500],
           "contentsOpaque": true,
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "backgroundColor": "#0000FF",
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [285, 665],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -137,10 +138,10 @@
 *** iteration 2: ***
 
 {
-  "bounds": [785, 2562],
+  "bounds": [785, 2578],
   "children": [
     {
-      "bounds": [785, 2562],
+      "bounds": [785, 2578],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
@@ -148,15 +149,16 @@
           "position": [8, 68],
           "bounds": [300, 500],
           "contentsOpaque": true,
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "backgroundColor": "#0000FF",
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [285, 665],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -260,24 +262,25 @@
 *** iteration 3: ***
 
 {
-  "bounds": [785, 4530],
+  "bounds": [785, 4562],
   "children": [
     {
-      "bounds": [785, 4530],
+      "bounds": [785, 4562],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
         {
           "position": [8, 68],
           "bounds": [300, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [285, 665],
-                  "shouldFlattenTransform": false
+                  "bounds": [285, 665]
                 }
               ]
             },
@@ -380,24 +383,25 @@
 *** iteration 4: ***
 
 {
-  "bounds": [785, 6450],
+  "bounds": [785, 6498],
   "children": [
     {
-      "bounds": [785, 6450],
+      "bounds": [785, 6498],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
         {
           "position": [8, 68],
           "bounds": [300, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [285, 665],
-                  "shouldFlattenTransform": false
+                  "bounds": [285, 665]
                 }
               ]
             },
diff --git a/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/selection-gaps-toggling-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/selection-gaps-toggling-expected.txt
index 4a47763..7bb7d757 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/selection-gaps-toggling-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/selection-gaps-toggling-expected.txt
@@ -24,14 +24,15 @@
         {
           "position": [8, 68],
           "bounds": [300, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [285, 665],
-                  "shouldFlattenTransform": false
+                  "bounds": [285, 665]
                 }
               ]
             },
@@ -134,24 +135,25 @@
 *** iteration 2: ***
 
 {
-  "bounds": [785, 2514],
+  "bounds": [785, 2530],
   "children": [
     {
-      "bounds": [785, 2514],
+      "bounds": [785, 2530],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
         {
           "position": [8, 68],
           "bounds": [300, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [285, 665],
-                  "shouldFlattenTransform": false
+                  "bounds": [285, 665]
                 }
               ]
             },
@@ -254,24 +256,25 @@
 *** iteration 3: ***
 
 {
-  "bounds": [785, 4434],
+  "bounds": [785, 4466],
   "children": [
     {
-      "bounds": [785, 4434],
+      "bounds": [785, 4466],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
         {
           "position": [8, 68],
           "bounds": [300, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [285, 665],
-                  "shouldFlattenTransform": false
+                  "bounds": [285, 665]
                 }
               ]
             },
diff --git a/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/selection-gaps-toggling-with-scrolling-contents-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/selection-gaps-toggling-with-scrolling-contents-expected.txt
index d6996d2..f6d489f 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/selection-gaps-toggling-with-scrolling-contents-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/selection-gaps-toggling-with-scrolling-contents-expected.txt
@@ -24,14 +24,15 @@
         {
           "position": [8, 68],
           "bounds": [300, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [285, 665],
-                  "shouldFlattenTransform": false
+                  "bounds": [285, 665]
                 }
               ]
             },
@@ -134,10 +135,10 @@
 *** iteration 2: ***
 
 {
-  "bounds": [785, 2514],
+  "bounds": [785, 2530],
   "children": [
     {
-      "bounds": [785, 2514],
+      "bounds": [785, 2530],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
@@ -145,15 +146,16 @@
           "position": [8, 68],
           "bounds": [300, 500],
           "contentsOpaque": true,
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "backgroundColor": "#0000FF",
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [285, 665],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -257,10 +259,10 @@
 *** iteration 3: ***
 
 {
-  "bounds": [785, 4482],
+  "bounds": [785, 4514],
   "children": [
     {
-      "bounds": [785, 4482],
+      "bounds": [785, 4514],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
@@ -268,15 +270,16 @@
           "position": [8, 68],
           "bounds": [300, 500],
           "contentsOpaque": true,
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "backgroundColor": "#0000FF",
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [285, 665],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -380,24 +383,25 @@
 *** iteration 4: ***
 
 {
-  "bounds": [785, 6450],
+  "bounds": [785, 6498],
   "children": [
     {
-      "bounds": [785, 6450],
+      "bounds": [785, 6498],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
         {
           "position": [8, 68],
           "bounds": [300, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [285, 665],
-                  "shouldFlattenTransform": false
+                  "bounds": [285, 665]
                 }
               ]
             },
diff --git a/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/textarea-scroll-touch-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/textarea-scroll-touch-expected.txt
index ebcfe549..7569bf1 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/textarea-scroll-touch-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/compositing/overflow/textarea-scroll-touch-expected.txt
@@ -11,16 +11,17 @@
           "position": [18, 18],
           "bounds": [206, 126],
           "contentsOpaque": true,
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "backgroundColor": "#CCCCCC",
           "children": [
             {
               "position": [1, 1],
               "bounds": [189, 124],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [189, 328],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -45,16 +46,17 @@
           "position": [248, 18],
           "bounds": [206, 126],
           "contentsOpaque": true,
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "backgroundColor": "#CCCCCC",
           "children": [
             {
               "position": [1, 1],
               "bounds": [189, 124],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [189, 328],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
diff --git a/third_party/WebKit/LayoutTests/platform/linux/compositing/repaint/should-not-clip-composited-overflow-scrolling-layer-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/compositing/repaint/should-not-clip-composited-overflow-scrolling-layer-expected.txt
index ee3d294..c45f25aa 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/compositing/repaint/should-not-clip-composited-overflow-scrolling-layer-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/compositing/repaint/should-not-clip-composited-overflow-scrolling-layer-expected.txt
@@ -9,6 +9,7 @@
         {
           "position": [8, 8],
           "bounds": [500, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "repaintRects": [
             [-2000, -2000, 5000, 5000]
@@ -16,10 +17,10 @@
           "children": [
             {
               "bounds": [485, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [5000, 5000],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "repaintRects": [
                     [0, 0, 5000, 5000]
diff --git a/third_party/WebKit/LayoutTests/platform/linux/paint/selection/selection-within-composited-scroller-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/paint/selection/selection-within-composited-scroller-expected.txt
index b172a4e..33e09c53 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/paint/selection/selection-within-composited-scroller-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/paint/selection/selection-within-composited-scroller-expected.txt
@@ -14,6 +14,7 @@
           "position": [8, 8],
           "bounds": [200, 200],
           "contentsOpaque": true,
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "backgroundColor": "#D3D3D3",
           "repaintRects": [
@@ -25,10 +26,10 @@
           "children": [
             {
               "bounds": [185, 185],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [200, 1620],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "repaintRects": [
                     [0, 610, 21, 19]
diff --git a/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-after-removing-scrolling-contents-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-after-removing-scrolling-contents-expected.txt
index b85a763..f4e88a0 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-after-removing-scrolling-contents-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-after-removing-scrolling-contents-expected.txt
@@ -25,15 +25,16 @@
           "position": [8, 68],
           "bounds": [300, 500],
           "contentsOpaque": true,
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "backgroundColor": "#0000FF",
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [285, 665],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -137,10 +138,10 @@
 *** iteration 2: ***
 
 {
-  "bounds": [785, 2562],
+  "bounds": [785, 2578],
   "children": [
     {
-      "bounds": [785, 2562],
+      "bounds": [785, 2578],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
@@ -148,15 +149,16 @@
           "position": [8, 68],
           "bounds": [300, 500],
           "contentsOpaque": true,
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "backgroundColor": "#0000FF",
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [285, 665],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -260,24 +262,25 @@
 *** iteration 3: ***
 
 {
-  "bounds": [785, 4530],
+  "bounds": [785, 4562],
   "children": [
     {
-      "bounds": [785, 4530],
+      "bounds": [785, 4562],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
         {
           "position": [8, 68],
           "bounds": [300, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [285, 665],
-                  "shouldFlattenTransform": false
+                  "bounds": [285, 665]
                 }
               ]
             },
@@ -380,24 +383,25 @@
 *** iteration 4: ***
 
 {
-  "bounds": [785, 6450],
+  "bounds": [785, 6498],
   "children": [
     {
-      "bounds": [785, 6450],
+      "bounds": [785, 6498],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
         {
           "position": [8, 68],
           "bounds": [300, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [285, 665],
-                  "shouldFlattenTransform": false
+                  "bounds": [285, 665]
                 }
               ]
             },
diff --git a/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-toggling-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-toggling-expected.txt
index 4a47763..7bb7d757 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-toggling-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-toggling-expected.txt
@@ -24,14 +24,15 @@
         {
           "position": [8, 68],
           "bounds": [300, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [285, 665],
-                  "shouldFlattenTransform": false
+                  "bounds": [285, 665]
                 }
               ]
             },
@@ -134,24 +135,25 @@
 *** iteration 2: ***
 
 {
-  "bounds": [785, 2514],
+  "bounds": [785, 2530],
   "children": [
     {
-      "bounds": [785, 2514],
+      "bounds": [785, 2530],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
         {
           "position": [8, 68],
           "bounds": [300, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [285, 665],
-                  "shouldFlattenTransform": false
+                  "bounds": [285, 665]
                 }
               ]
             },
@@ -254,24 +256,25 @@
 *** iteration 3: ***
 
 {
-  "bounds": [785, 4434],
+  "bounds": [785, 4466],
   "children": [
     {
-      "bounds": [785, 4434],
+      "bounds": [785, 4466],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
         {
           "position": [8, 68],
           "bounds": [300, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [285, 665],
-                  "shouldFlattenTransform": false
+                  "bounds": [285, 665]
                 }
               ]
             },
diff --git a/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-toggling-with-scrolling-contents-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-toggling-with-scrolling-contents-expected.txt
index d6996d2..f6d489f 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-toggling-with-scrolling-contents-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/selection-gaps-toggling-with-scrolling-contents-expected.txt
@@ -24,14 +24,15 @@
         {
           "position": [8, 68],
           "bounds": [300, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [285, 665],
-                  "shouldFlattenTransform": false
+                  "bounds": [285, 665]
                 }
               ]
             },
@@ -134,10 +135,10 @@
 *** iteration 2: ***
 
 {
-  "bounds": [785, 2514],
+  "bounds": [785, 2530],
   "children": [
     {
-      "bounds": [785, 2514],
+      "bounds": [785, 2530],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
@@ -145,15 +146,16 @@
           "position": [8, 68],
           "bounds": [300, 500],
           "contentsOpaque": true,
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "backgroundColor": "#0000FF",
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [285, 665],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -257,10 +259,10 @@
 *** iteration 3: ***
 
 {
-  "bounds": [785, 4482],
+  "bounds": [785, 4514],
   "children": [
     {
-      "bounds": [785, 4482],
+      "bounds": [785, 4514],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
@@ -268,15 +270,16 @@
           "position": [8, 68],
           "bounds": [300, 500],
           "contentsOpaque": true,
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "backgroundColor": "#0000FF",
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [285, 665],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -380,24 +383,25 @@
 *** iteration 4: ***
 
 {
-  "bounds": [785, 6450],
+  "bounds": [785, 6498],
   "children": [
     {
-      "bounds": [785, 6450],
+      "bounds": [785, 6498],
       "contentsOpaque": true,
       "drawsContent": true,
       "children": [
         {
           "position": [8, 68],
           "bounds": [300, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [285, 665],
-                  "shouldFlattenTransform": false
+                  "bounds": [285, 665]
                 }
               ]
             },
diff --git a/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/text-color-change-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/text-color-change-expected.txt
index 52e2586..b08b28b4 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/text-color-change-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/text-color-change-expected.txt
@@ -9,6 +9,7 @@
         {
           "position": [8, 61],
           "bounds": [200, 200],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "repaintRects": [
             [0, 0, 48, 656]
@@ -16,10 +17,10 @@
           "children": [
             {
               "bounds": [185, 185],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [185, 656],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "repaintRects": [
                     [0, 0, 48, 656]
diff --git a/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/text-match-highlight-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/text-match-highlight-expected.txt
index 8336acb..16a6c02 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/text-match-highlight-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/text-match-highlight-expected.txt
@@ -16,6 +16,7 @@
         {
           "position": [0, 60],
           "bounds": [800, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "repaintRects": [
             [244, 0, 40, 19],
@@ -29,10 +30,10 @@
           "children": [
             {
               "bounds": [785, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [785, 1345],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "repaintRects": [
                     [244, 0, 40, 19],
diff --git a/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/textarea-scroll-touch-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/textarea-scroll-touch-expected.txt
index ebcfe549..7569bf1 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/textarea-scroll-touch-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/textarea-scroll-touch-expected.txt
@@ -11,16 +11,17 @@
           "position": [18, 18],
           "bounds": [206, 126],
           "contentsOpaque": true,
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "backgroundColor": "#CCCCCC",
           "children": [
             {
               "position": [1, 1],
               "bounds": [189, 124],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [189, 328],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -45,16 +46,17 @@
           "position": [248, 18],
           "bounds": [206, 126],
           "contentsOpaque": true,
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "backgroundColor": "#CCCCCC",
           "children": [
             {
               "position": [1, 1],
               "bounds": [189, 124],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [189, 328],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
diff --git a/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-container-and-content-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-container-and-content-expected.txt
index 569027b..c36669f 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-container-and-content-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-container-and-content-expected.txt
@@ -9,6 +9,7 @@
         {
           "position": [8, 108],
           "bounds": [200, 200],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "repaintRects": [
             [0, 190, 74, 19],
@@ -28,10 +29,10 @@
           "children": [
             {
               "bounds": [185, 185],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [185, 260],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "repaintRects": [
                     [0, 240, 74, 19],
diff --git a/third_party/WebKit/LayoutTests/platform/linux/virtual/syncpaint/compositing/repaint/should-not-clip-composited-overflow-scrolling-layer-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/virtual/syncpaint/compositing/repaint/should-not-clip-composited-overflow-scrolling-layer-expected.txt
index ee3d294..c45f25aa 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/virtual/syncpaint/compositing/repaint/should-not-clip-composited-overflow-scrolling-layer-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/virtual/syncpaint/compositing/repaint/should-not-clip-composited-overflow-scrolling-layer-expected.txt
@@ -9,6 +9,7 @@
         {
           "position": [8, 8],
           "bounds": [500, 500],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "repaintRects": [
             [-2000, -2000, 5000, 5000]
@@ -16,10 +17,10 @@
           "children": [
             {
               "bounds": [485, 485],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [5000, 5000],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "repaintRects": [
                     [0, 0, 5000, 5000]
diff --git a/third_party/WebKit/LayoutTests/platform/linux/virtual/syncpaint/paint/selection/selection-within-composited-scroller-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/virtual/syncpaint/paint/selection/selection-within-composited-scroller-expected.txt
index b172a4e..33e09c53 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/virtual/syncpaint/paint/selection/selection-within-composited-scroller-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/virtual/syncpaint/paint/selection/selection-within-composited-scroller-expected.txt
@@ -14,6 +14,7 @@
           "position": [8, 8],
           "bounds": [200, 200],
           "contentsOpaque": true,
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "backgroundColor": "#D3D3D3",
           "repaintRects": [
@@ -25,10 +26,10 @@
           "children": [
             {
               "bounds": [185, 185],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [200, 1620],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "repaintRects": [
                     [0, 610, 21, 19]
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/accelerated-overflow-scroll-should-not-affect-perspective-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/accelerated-overflow-scroll-should-not-affect-perspective-expected.txt
index 39c25efe..ad67ede 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/accelerated-overflow-scroll-should-not-affect-perspective-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/accelerated-overflow-scroll-should-not-affect-perspective-expected.txt
@@ -9,6 +9,7 @@
         {
           "position": [8, 8],
           "bounds": [200, 200],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/clear-scroll-parent-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/clear-scroll-parent-expected.txt
index 21ff09a..82736418 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/clear-scroll-parent-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/clear-scroll-parent-expected.txt
@@ -9,15 +9,16 @@
         {
           "position": [8, 8],
           "bounds": [308, 208],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [4, 4],
               "bounds": [285, 200],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [285, 530],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/composited-scrolling-paint-phases-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/composited-scrolling-paint-phases-expected.txt
index 6d86be9..4013b92d 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/composited-scrolling-paint-phases-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/composited-scrolling-paint-phases-expected.txt
@@ -45,6 +45,7 @@
             {
               "position": [28, 20],
               "bounds": [202, 202],
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "paintingPhases": [
                 "GraphicsLayerPaintBackground",
@@ -55,6 +56,7 @@
                 {
                   "position": [1, 1],
                   "bounds": [185, 185],
+                  "shouldFlattenTransform": false,
                   "paintingPhases": [
                     "GraphicsLayerPaintBackground",
                     "GraphicsLayerPaintForeground",
@@ -63,7 +65,6 @@
                   "children": [
                     {
                       "bounds": [185, 715],
-                      "shouldFlattenTransform": false,
                       "drawsContent": true,
                       "paintingPhases": [
                         "GraphicsLayerPaintForeground",
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/content-gains-scrollbars-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/content-gains-scrollbars-expected.txt
index d243ed8b..10f2551 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/content-gains-scrollbars-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/content-gains-scrollbars-expected.txt
@@ -9,14 +9,15 @@
         {
           "position": [8, 13],
           "bounds": [100, 100],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [85, 100],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [85, 200],
-                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [10, 200]
@@ -39,14 +40,15 @@
         {
           "position": [8, 13],
           "bounds": [100, 100],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [100, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [200, 85],
-                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [200, 10]
@@ -69,14 +71,15 @@
         {
           "position": [8, 13],
           "bounds": [100, 100],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [200, 200],
-                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [200, 200]
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-auto-with-touch-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-auto-with-touch-expected.txt
index 9b7a759..e62037c 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-auto-with-touch-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-auto-with-touch-expected.txt
@@ -9,14 +9,15 @@
         {
           "position": [8, 8],
           "bounds": [300, 300],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 285],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [1000, 1000],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-auto-with-touch-toggle-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-auto-with-touch-toggle-expected.txt
index 9b7a759..e62037c 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-auto-with-touch-toggle-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-auto-with-touch-toggle-expected.txt
@@ -9,14 +9,15 @@
         {
           "position": [8, 8],
           "bounds": [300, 300],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 285],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [1000, 1000],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-overlay-with-touch-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-overlay-with-touch-expected.txt
index 9b7a759..e62037c 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-overlay-with-touch-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-overlay-with-touch-expected.txt
@@ -9,14 +9,15 @@
         {
           "position": [8, 8],
           "bounds": [300, 300],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [285, 285],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [1000, 1000],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-scrollbar-layers-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-scrollbar-layers-expected.txt
index d243ed8b..10f2551 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-scrollbar-layers-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/overflow-scrollbar-layers-expected.txt
@@ -9,14 +9,15 @@
         {
           "position": [8, 13],
           "bounds": [100, 100],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [85, 100],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [85, 200],
-                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [10, 200]
@@ -39,14 +40,15 @@
         {
           "position": [8, 13],
           "bounds": [100, 100],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [100, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [200, 85],
-                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [200, 10]
@@ -69,14 +71,15 @@
         {
           "position": [8, 13],
           "bounds": [100, 100],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [200, 200],
-                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [200, 200]
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/reparented-scrollbars-non-sc-anc-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/reparented-scrollbars-non-sc-anc-expected.txt
index b11e3e4..5244c6e 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/reparented-scrollbars-non-sc-anc-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/reparented-scrollbars-non-sc-anc-expected.txt
@@ -24,14 +24,15 @@
                       "children": [
                         {
                           "bounds": [1200, 1000],
+                          "shouldFlattenTransform": false,
                           "drawsContent": true,
                           "children": [
                             {
                               "bounds": [1200, 1000],
+                              "shouldFlattenTransform": false,
                               "children": [
                                 {
                                   "bounds": [1200, 10000],
-                                  "shouldFlattenTransform": false,
                                   "drawsContent": true
                                 }
                               ]
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scroll-parent-absolute-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scroll-parent-absolute-expected.txt
index a861f58..631b21d 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scroll-parent-absolute-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scroll-parent-absolute-expected.txt
@@ -13,15 +13,16 @@
               "position": [8, 8],
               "bounds": [500, 500],
               "contentsOpaque": true,
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "backgroundColor": "#0000FF",
               "children": [
                 {
                   "bounds": [485, 485],
+                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [485, 5000],
-                      "shouldFlattenTransform": false,
                       "drawsContent": true
                     }
                   ]
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scroll-parent-with-non-stacking-context-composited-ancestor-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scroll-parent-with-non-stacking-context-composited-ancestor-expected.txt
index eca105b..de97ec2 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scroll-parent-with-non-stacking-context-composited-ancestor-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scroll-parent-with-non-stacking-context-composited-ancestor-expected.txt
@@ -16,15 +16,16 @@
           "children": [
             {
               "bounds": [102, 102],
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "children": [
                 {
                   "position": [1, 1],
                   "bounds": [100, 100],
+                  "shouldFlattenTransform": false,
                   "children": [
                     {
-                      "bounds": [100, 180],
-                      "shouldFlattenTransform": false
+                      "bounds": [100, 180]
                     }
                   ]
                 }
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scrolling-content-clip-to-viewport-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scrolling-content-clip-to-viewport-expected.txt
index a74270d..e456a58 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scrolling-content-clip-to-viewport-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scrolling-content-clip-to-viewport-expected.txt
@@ -8,14 +8,15 @@
       "children": [
         {
           "bounds": [320, 340],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "bounds": [305, 325],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [305, 1224],
-                  "shouldFlattenTransform": false
+                  "bounds": [305, 1224]
                 }
               ]
             },
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scrolling-without-painting-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scrolling-without-painting-expected.txt
index 466febf8..11f017e2 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scrolling-without-painting-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/scrolling-without-painting-expected.txt
@@ -9,15 +9,16 @@
         {
           "position": [8, 8],
           "bounds": [202, 202],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [1, 1],
               "bounds": [185, 185],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [185, 1025],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/universal-accelerated-overflow-scroll-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/universal-accelerated-overflow-scroll-expected.txt
index 4b59382..6ca1829 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/universal-accelerated-overflow-scroll-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/universal-accelerated-overflow-scroll-expected.txt
@@ -12,15 +12,16 @@
             {
               "position": [10, 10],
               "bounds": [104, 104],
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "children": [
                 {
                   "position": [2, 2],
                   "bounds": [85, 85],
+                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [85, 144],
-                      "shouldFlattenTransform": false,
                       "drawsContent": true
                     }
                   ]
@@ -72,15 +73,16 @@
         {
           "position": [130, 10],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [105, 144],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -128,15 +130,16 @@
             {
               "position": [250, 10],
               "bounds": [104, 104],
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "children": [
                 {
                   "position": [2, 2],
                   "bounds": [85, 85],
+                  "shouldFlattenTransform": false,
                   "children": [
                     {
-                      "bounds": [85, 144],
-                      "shouldFlattenTransform": false
+                      "bounds": [85, 144]
                     }
                   ]
                 },
@@ -190,15 +193,16 @@
             {
               "position": [370, 10],
               "bounds": [104, 104],
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "children": [
                 {
                   "position": [2, 2],
                   "bounds": [85, 85],
+                  "shouldFlattenTransform": false,
                   "children": [
                     {
                       "bounds": [85, 144],
-                      "shouldFlattenTransform": false,
                       "drawsContent": true
                     }
                   ]
@@ -250,15 +254,16 @@
         {
           "position": [10, 130],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [105, 144],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -306,15 +311,16 @@
             {
               "position": [130, 130],
               "bounds": [104, 104],
+              "shouldFlattenTransform": false,
               "drawsContent": true,
               "children": [
                 {
                   "position": [2, 2],
                   "bounds": [85, 85],
+                  "shouldFlattenTransform": false,
                   "children": [
                     {
-                      "bounds": [85, 144],
-                      "shouldFlattenTransform": false
+                      "bounds": [85, 144]
                     }
                   ]
                 },
@@ -365,15 +371,16 @@
         {
           "position": [250, 130],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [105, 144],
-                  "shouldFlattenTransform": false
+                  "bounds": [105, 144]
                 }
               ]
             },
@@ -417,15 +424,16 @@
         {
           "position": [370, 130],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [105, 144],
-                  "shouldFlattenTransform": false
+                  "bounds": [105, 144]
                 }
               ]
             },
@@ -469,15 +477,16 @@
         {
           "position": [10, 250],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [85, 144],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -529,15 +538,16 @@
         {
           "position": [130, 250],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [85, 144],
-                  "shouldFlattenTransform": false
+                  "bounds": [85, 144]
                 }
               ]
             },
@@ -588,15 +598,16 @@
         {
           "position": [250, 250],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [85, 144],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true
                 }
               ]
@@ -648,15 +659,16 @@
         {
           "position": [370, 250],
           "bounds": [104, 104],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "children": [
             {
               "position": [2, 2],
               "bounds": [85, 85],
+              "shouldFlattenTransform": false,
               "children": [
                 {
-                  "bounds": [85, 144],
-                  "shouldFlattenTransform": false
+                  "bounds": [85, 144]
                 }
               ]
             },
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-container-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-container-expected.txt
index 9894d08..fbf2a42f 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-container-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-container-expected.txt
@@ -9,6 +9,7 @@
         {
           "position": [8, 108],
           "bounds": [210, 210],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "repaintRects": [
             [0, 0, 210, 210]
@@ -20,10 +21,10 @@
             {
               "position": [5, 5],
               "bounds": [185, 185],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [400, 400],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "repaintRects": [
                     [-5, -5, 210, 210]
diff --git a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-content-expected.txt b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-content-expected.txt
index 59fbd8e..ecb91aa 100644
--- a/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-content-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/prefer_compositing_to_lcd_text/compositing/overflow/updating-scrolling-content-expected.txt
@@ -9,6 +9,7 @@
         {
           "position": [8, 8],
           "bounds": [200, 200],
+          "shouldFlattenTransform": false,
           "drawsContent": true,
           "repaintRects": [
             [0, 0, 185, 200]
@@ -16,10 +17,10 @@
           "children": [
             {
               "bounds": [185, 185],
+              "shouldFlattenTransform": false,
               "children": [
                 {
                   "bounds": [185, 1200],
-                  "shouldFlattenTransform": false,
                   "drawsContent": true,
                   "repaintRects": [
                     [0, 0, 185, 200]
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
index 11a622a..5a38b9ab 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
@@ -1511,12 +1511,13 @@
         }, ApplyToChildContainingLayers);
     }
 
-    // Regardless, mark the scrolling contents layer and scrolling block
+    // Regardless, mark the graphics layer, scrolling layer and scrolling block
     // selection layer (if they exist) as not flattening. Having them flatten
     // causes unclipped render surfaces which cause bugs.
     // http://crbug.com/521768
     if (hasScrollingLayer()) {
-        m_scrollingContentsLayer->setShouldFlattenTransform(false);
+        m_graphicsLayer->setShouldFlattenTransform(false);
+        m_scrollingLayer->setShouldFlattenTransform(false);
         if (m_scrollingBlockSelectionLayer)
             m_scrollingBlockSelectionLayer->setShouldFlattenTransform(false);
     }
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
index 283be2ff2..c6deda04 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
@@ -34,6 +34,11 @@
         return compositedLayerMapping->computeInterestRect(graphicsLayer, previousInterestRect);
     }
 
+    bool shouldFlattenTransform(const GraphicsLayer& layer) const
+    {
+        return layer.shouldFlattenTransform();
+    }
+
     bool interestRectChangedEnoughToRepaint(const IntRect& previousInterestRect, const IntRect& newInterestRect, const IntSize& layerSize)
     {
         return CompositedLayerMapping::interestRectChangedEnoughToRepaint(previousInterestRect, newInterestRect, layerSize);
@@ -264,6 +269,25 @@
     EXPECT_FALSE(graphicsLayer->contentsClippingMaskLayer());
 }
 
+TEST_F(CompositedLayerMappingTest, ScrollContentsFlattenForScroller)
+{
+    setBodyInnerHTML(
+        "<style>div::-webkit-scrollbar{ width: 5px; }</style>"
+        "<div id='scroller' style='width: 100px; height: 100px; overflow: scroll; will-change: transform'>"
+        "<div style='width: 1000px; height: 1000px;'>Foo</div>Foo</div>");
+
+    document().view()->updateAllLifecyclePhases();
+    Element* element = document().getElementById("scroller");
+    PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
+    CompositedLayerMapping* compositedLayerMapping = paintLayer->compositedLayerMapping();
+
+    ASSERT_TRUE(compositedLayerMapping);
+
+    EXPECT_FALSE(shouldFlattenTransform(*compositedLayerMapping->mainGraphicsLayer()));
+    EXPECT_FALSE(shouldFlattenTransform(*compositedLayerMapping->scrollingLayer()));
+    EXPECT_TRUE(shouldFlattenTransform(*compositedLayerMapping->scrollingContentsLayer()));
+}
+
 TEST_F(CompositedLayerMappingTest, InterestRectChangedEnoughToRepaintEmpty)
 {
     IntSize layerSize(1000, 1000);
diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.h b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.h
index 21c44f0..ee9f73e 100644
--- a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.h
+++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.h
@@ -271,6 +271,7 @@
 
 protected:
     String debugName(cc::Layer*) const;
+    bool shouldFlattenTransform() const { return m_shouldFlattenTransform; }
 
     explicit GraphicsLayer(GraphicsLayerClient*);
     // GraphicsLayerFactoryChromium that wants to create a GraphicsLayer need to be friends.
@@ -278,6 +279,7 @@
     // for testing
     friend class CompositedLayerMappingTest;
     friend class FakeGraphicsLayerFactory;
+    friend class CompositedLayerMappingTest;
 
 private:
     // Adds a child without calling updateChildList(), so that adding children