diff --git a/base/files/file.cc b/base/files/file.cc
index 50b4370d..c1ce182f 100644
--- a/base/files/file.cc
+++ b/base/files/file.cc
@@ -9,6 +9,10 @@
 #include "base/timer/elapsed_timer.h"
 #include "build/build_config.h"
 
+#if defined(OS_POSIX)
+#include <errno.h>
+#endif
+
 namespace base {
 
 File::Info::Info()
@@ -82,6 +86,13 @@
 #if !defined(OS_NACL)
 void File::Initialize(const FilePath& path, uint32_t flags) {
   if (path.ReferencesParent()) {
+#if defined(OS_WIN)
+    ::SetLastError(ERROR_ACCESS_DENIED);
+#elif defined(OS_POSIX)
+    errno = EACCES;
+#else
+#error Unsupported platform
+#endif
     error_details_ = FILE_ERROR_ACCESS_DENIED;
     return;
   }
diff --git a/chrome/VERSION b/chrome/VERSION
index 4fee3b65e..2bb6275 100644
--- a/chrome/VERSION
+++ b/chrome/VERSION
@@ -1,4 +1,4 @@
 MAJOR=65
 MINOR=0
-BUILD=3283
+BUILD=3284
 PATCH=0
diff --git a/ios/chrome/browser/ui/settings/BUILD.gn b/ios/chrome/browser/ui/settings/BUILD.gn
index 8e16f8f..45560e7 100644
--- a/ios/chrome/browser/ui/settings/BUILD.gn
+++ b/ios/chrome/browser/ui/settings/BUILD.gn
@@ -353,6 +353,7 @@
     "//ios/chrome/browser/ui/settings:test_support",
     "//ios/chrome/browser/ui/tools_menu/public",
     "//ios/chrome/browser/ui/util:util",
+    "//ios/chrome/test:test_support",
     "//ios/chrome/test/app:test_support",
     "//ios/chrome/test/earl_grey:test_support",
     "//ios/public/provider/chrome/browser/signin:test_support",
diff --git a/ios/chrome/browser/ui/settings/block_popups_egtest.mm b/ios/chrome/browser/ui/settings/block_popups_egtest.mm
index 145d9a5..7645d29 100644
--- a/ios/chrome/browser/ui/settings/block_popups_egtest.mm
+++ b/ios/chrome/browser/ui/settings/block_popups_egtest.mm
@@ -22,6 +22,7 @@
 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
 #import "ios/chrome/test/earl_grey/chrome_matchers.h"
 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
+#include "ios/chrome/test/scoped_block_popups_pref.h"
 #import "ios/web/public/test/http_server/http_server.h"
 #include "ios/web/public/test/http_server/http_server_util.h"
 #import "ios/web/public/test/web_view_interaction_test_util.h"
@@ -33,6 +34,7 @@
 #endif
 
 using chrome_test_util::ContentSettingsButton;
+using chrome_test_util::GetOriginalBrowserState;
 using chrome_test_util::NavigationBarDoneButton;
 using chrome_test_util::SettingsMenuBackButton;
 
@@ -57,43 +59,6 @@
   return chrome_test_util::ButtonWithAccessibilityLabelId(IDS_IOS_BLOCK_POPUPS);
 }
 
-// ScopedBlockPopupsPref modifies the block popups preference and resets the
-// preference to its original value when this object goes out of scope.
-class ScopedBlockPopupsPref {
- public:
-  ScopedBlockPopupsPref(ContentSetting setting) {
-    original_setting_ = GetPrefValue();
-    SetPrefValue(setting);
-  }
-  ~ScopedBlockPopupsPref() { SetPrefValue(original_setting_); }
-
- private:
-  // Gets the current value of the preference.
-  ContentSetting GetPrefValue() {
-    ContentSetting popupSetting =
-        ios::HostContentSettingsMapFactory::GetForBrowserState(
-            chrome_test_util::GetOriginalBrowserState())
-            ->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, NULL);
-    return popupSetting;
-  }
-
-  // Sets the preference to the given value.
-  void SetPrefValue(ContentSetting setting) {
-    DCHECK(setting == CONTENT_SETTING_BLOCK ||
-           setting == CONTENT_SETTING_ALLOW);
-    ios::ChromeBrowserState* state =
-        chrome_test_util::GetOriginalBrowserState();
-    ios::HostContentSettingsMapFactory::GetForBrowserState(state)
-        ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, setting);
-  }
-
-  // Saves the original pref setting so that it can be restored when the scoper
-  // is destroyed.
-  ContentSetting original_setting_;
-
-  DISALLOW_COPY_AND_ASSIGN(ScopedBlockPopupsPref);
-};
-
 // ScopedBlockPopupsException adds an exception to the block popups exception
 // list for as long as this object is in scope.
 class ScopedBlockPopupsException {
@@ -167,7 +132,8 @@
   responses[openedWindowURL] = kOpenedWindowResponse;
   web::test::SetUpSimpleHttpServer(responses);
 
-  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW);
+  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW,
+                                   GetOriginalBrowserState());
   [ChromeEarlGrey loadURL:blockPopupsURL];
   [ChromeEarlGrey waitForMainTabCount:1];
 
@@ -197,7 +163,8 @@
   responses[openedWindowURL] = kOpenedWindowResponse;
   web::test::SetUpSimpleHttpServer(responses);
 
-  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_BLOCK);
+  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_BLOCK,
+                                   GetOriginalBrowserState());
   [ChromeEarlGrey loadURL:blockPopupsURL];
   [ChromeEarlGrey waitForMainTabCount:1];
 
@@ -227,7 +194,8 @@
 // revealed properly when the preference switch is toggled.
 - (void)testSettingsPageWithExceptions {
   std::string allowedPattern = "[*.]example.com";
-  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_BLOCK);
+  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_BLOCK,
+                                   GetOriginalBrowserState());
   ScopedBlockPopupsException exceptionSetter(allowedPattern);
 
   [ChromeEarlGreyUI openSettingsMenu];
diff --git a/ios/chrome/browser/web/BUILD.gn b/ios/chrome/browser/web/BUILD.gn
index 19323cf5..6fb19257 100644
--- a/ios/chrome/browser/web/BUILD.gn
+++ b/ios/chrome/browser/web/BUILD.gn
@@ -265,16 +265,15 @@
   deps = [
     "//base",
     "//base/test:test_support",
-    "//components/content_settings/core/browser",
     "//components/content_settings/core/common",
     "//components/strings",
     "//components/version_info:version_info",
     "//ios/chrome/app/strings",
     "//ios/chrome/browser",
     "//ios/chrome/browser/browser_state",
-    "//ios/chrome/browser/content_settings",
     "//ios/chrome/browser/ui",
     "//ios/chrome/browser/ui/commands",
+    "//ios/chrome/test:test_support",
     "//ios/chrome/test/app:test_support",
     "//ios/chrome/test/earl_grey:test_support",
     "//ios/testing:ios_test_support",
diff --git a/ios/chrome/browser/web/browsing_egtest.mm b/ios/chrome/browser/web/browsing_egtest.mm
index 48345e1..385a78cb 100644
--- a/ios/chrome/browser/web/browsing_egtest.mm
+++ b/ios/chrome/browser/web/browsing_egtest.mm
@@ -10,9 +10,6 @@
 #include "base/ios/ios_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/sys_string_conversions.h"
-#include "components/content_settings/core/browser/host_content_settings_map.h"
-#include "components/content_settings/core/common/content_settings.h"
-#include "ios/chrome/browser/content_settings/host_content_settings_map_factory.h"
 #include "ios/chrome/browser/ui/ui_util.h"
 #include "ios/chrome/grit/ios_strings.h"
 #import "ios/chrome/test/app/chrome_test_util.h"
@@ -22,6 +19,7 @@
 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
 #import "ios/chrome/test/earl_grey/chrome_matchers.h"
 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
+#include "ios/chrome/test/scoped_block_popups_pref.h"
 #import "ios/testing/wait_util.h"
 #import "ios/web/public/test/earl_grey/web_view_actions.h"
 #import "ios/web/public/test/earl_grey/web_view_matchers.h"
@@ -36,6 +34,7 @@
 #error "This file requires ARC support."
 #endif
 
+using chrome_test_util::GetOriginalBrowserState;
 using chrome_test_util::OmniboxText;
 
 namespace {
@@ -75,43 +74,6 @@
   int request_number_;  // Count of requests received by the response provider.
 };
 
-// ScopedBlockPopupsPref modifies the block popups preference and resets the
-// preference to its original value when this object goes out of scope.
-// TODO(crbug.com/638674): Evaluate if this can move to shared code
-class ScopedBlockPopupsPref {
- public:
-  ScopedBlockPopupsPref(ContentSetting setting) {
-    original_setting_ = GetPrefValue();
-    SetPrefValue(setting);
-  }
-  ~ScopedBlockPopupsPref() { SetPrefValue(original_setting_); }
-
- private:
-  // Gets the current value of the preference.
-  ContentSetting GetPrefValue() {
-    ContentSetting popupSetting =
-        ios::HostContentSettingsMapFactory::GetForBrowserState(
-            chrome_test_util::GetOriginalBrowserState())
-            ->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, NULL);
-    return popupSetting;
-  }
-
-  // Sets the preference to the given value.
-  void SetPrefValue(ContentSetting setting) {
-    DCHECK(setting == CONTENT_SETTING_BLOCK ||
-           setting == CONTENT_SETTING_ALLOW);
-    ios::ChromeBrowserState* state =
-        chrome_test_util::GetOriginalBrowserState();
-    ios::HostContentSettingsMapFactory::GetForBrowserState(state)
-        ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, setting);
-  }
-
-  // Saves the original pref setting so that it can be restored when the scoper
-  // is destroyed.
-  ContentSetting original_setting_;
-
-  DISALLOW_COPY_AND_ASSIGN(ScopedBlockPopupsPref);
-};
 }  // namespace
 
 // Tests web browsing scenarios.
@@ -222,7 +184,8 @@
   responses[destinationURL] = "You've arrived!";
   web::test::SetUpSimpleHttpServer(responses);
 
-  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW);
+  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW,
+                                   GetOriginalBrowserState());
 
   [ChromeEarlGrey loadURL:URL];
   [ChromeEarlGrey waitForMainTabCount:1];
@@ -252,7 +215,8 @@
   responses[destinationURL] = "You've arrived!";
   web::test::SetUpSimpleHttpServer(responses);
 
-  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW);
+  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW,
+                                   GetOriginalBrowserState());
 
   [ChromeEarlGrey loadURL:URL];
   [ChromeEarlGrey waitForMainTabCount:1];
@@ -292,7 +256,8 @@
 
   web::test::SetUpSimpleHttpServer(responses);
 
-  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW);
+  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW,
+                                   GetOriginalBrowserState());
 
   [ChromeEarlGrey loadURL:URL];
   [ChromeEarlGrey waitForMainTabCount:1];
@@ -331,7 +296,8 @@
 
   web::test::SetUpSimpleHttpServer(responses);
 
-  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW);
+  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW,
+                                   GetOriginalBrowserState());
 
   [ChromeEarlGrey loadURL:URL];
   [ChromeEarlGrey waitForMainTabCount:1];
diff --git a/ios/chrome/browser/web/browsing_prevent_default_egtest.mm b/ios/chrome/browser/web/browsing_prevent_default_egtest.mm
index 25bee0c7..32a8f8ca 100644
--- a/ios/chrome/browser/web/browsing_prevent_default_egtest.mm
+++ b/ios/chrome/browser/web/browsing_prevent_default_egtest.mm
@@ -8,14 +8,13 @@
 
 #include "base/ios/ios_util.h"
 #include "base/strings/sys_string_conversions.h"
-#include "components/content_settings/core/browser/host_content_settings_map.h"
 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
-#include "ios/chrome/browser/content_settings/host_content_settings_map_factory.h"
 #import "ios/chrome/test/app/chrome_test_util.h"
 #include "ios/chrome/test/app/web_view_interaction_test_util.h"
 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
 #import "ios/chrome/test/earl_grey/chrome_matchers.h"
 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
+#include "ios/chrome/test/scoped_block_popups_pref.h"
 #import "ios/web/public/test/http_server/http_server.h"
 #include "ios/web/public/test/http_server/http_server_util.h"
 #include "url/url_constants.h"
@@ -24,6 +23,8 @@
 #error "This file requires ARC support."
 #endif
 
+using chrome_test_util::GetOriginalBrowserState;
+
 namespace {
 
 // Timeout to use when waiting for a condition to be true.
@@ -35,44 +36,6 @@
       "http://ios/testing/data/http_server_files/"
       "browsing_prevent_default_test_page.html");
 }
-
-// ScopedBlockPopupsPref modifies the block popups preference and resets the
-// preference to its original value when this object goes out of scope.
-class ScopedBlockPopupsPref {
- public:
-  explicit ScopedBlockPopupsPref(ContentSetting setting) {
-    original_setting_ = GetPrefValue();
-    SetPrefValue(setting);
-  }
-  ~ScopedBlockPopupsPref() { SetPrefValue(original_setting_); }
-
- private:
-  // Gets the current value of the preference.
-  ContentSetting GetPrefValue() {
-    ContentSetting popupSetting =
-        ios::HostContentSettingsMapFactory::GetForBrowserState(
-            chrome_test_util::GetOriginalBrowserState())
-            ->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, NULL);
-    return popupSetting;
-  }
-
-  // Sets the preference to the given value.
-  void SetPrefValue(ContentSetting setting) {
-    DCHECK(setting == CONTENT_SETTING_BLOCK ||
-           setting == CONTENT_SETTING_ALLOW);
-    ios::ChromeBrowserState* state =
-        chrome_test_util::GetOriginalBrowserState();
-    ios::HostContentSettingsMapFactory::GetForBrowserState(state)
-        ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, setting);
-  }
-
-  // Saves the original pref setting so that it can be restored when the scoper
-  // is destroyed.
-  ContentSetting original_setting_;
-
-  DISALLOW_COPY_AND_ASSIGN(ScopedBlockPopupsPref);
-};
-
 }  // namespace
 
 // Tests that the javascript preventDefault() function correctly prevents new
@@ -87,7 +50,8 @@
 - (void)runTestAndVerifyNoNavigationForLinkID:(const std::string&)linkID {
   // Disable popup blocking, because that will mask failures that try to open
   // new tabs.
-  ScopedBlockPopupsPref scoper(CONTENT_SETTING_ALLOW);
+  ScopedBlockPopupsPref scoper(CONTENT_SETTING_ALLOW,
+                               GetOriginalBrowserState());
   web::test::SetUpFileBasedHttpServer();
 
   const GURL testURL = GetTestUrl();
@@ -124,7 +88,8 @@
 - (void)testPreventDefaultOverridesWindowOpen {
   // Disable popup blocking, because that will mask failures that try to open
   // new tabs.
-  ScopedBlockPopupsPref scoper(CONTENT_SETTING_ALLOW);
+  ScopedBlockPopupsPref scoper(CONTENT_SETTING_ALLOW,
+                               GetOriginalBrowserState());
   web::test::SetUpFileBasedHttpServer();
 
   const GURL testURL = GetTestUrl();
diff --git a/ios/chrome/browser/web/cache_egtest.mm b/ios/chrome/browser/web/cache_egtest.mm
index cfa1e0d..9a35923 100644
--- a/ios/chrome/browser/web/cache_egtest.mm
+++ b/ios/chrome/browser/web/cache_egtest.mm
@@ -7,9 +7,6 @@
 #include "base/ios/ios_util.h"
 #include "base/memory/ptr_util.h"
 #include "base/strings/stringprintf.h"
-#include "components/content_settings/core/browser/host_content_settings_map.h"
-#include "components/content_settings/core/common/content_settings.h"
-#include "ios/chrome/browser/content_settings/host_content_settings_map_factory.h"
 #include "ios/chrome/browser/ui/ui_util.h"
 #import "ios/chrome/test/app/chrome_test_util.h"
 #include "ios/chrome/test/app/history_test_util.h"
@@ -18,6 +15,7 @@
 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
 #import "ios/chrome/test/earl_grey/chrome_matchers.h"
 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
+#include "ios/chrome/test/scoped_block_popups_pref.h"
 #import "ios/testing/wait_util.h"
 #include "ios/web/public/test/http_server/html_response_provider.h"
 #import "ios/web/public/test/http_server/http_server.h"
@@ -28,6 +26,7 @@
 #error "This file requires ARC support."
 #endif
 
+using chrome_test_util::GetOriginalBrowserState;
 using web::test::HttpServer;
 
 namespace {
@@ -109,44 +108,6 @@
   GURL third_page_url_;
 };
 
-// ScopedBlockPopupsPref modifies the block popups preference and resets the
-// preference to its original value when this object goes out of scope.
-// TODO(crbug.com/638674): Evaluate if this can move to shared code.
-class ScopedBlockPopupsPref {
- public:
-  explicit ScopedBlockPopupsPref(ContentSetting setting) {
-    original_setting_ = GetPrefValue();
-    SetPrefValue(setting);
-  }
-  ~ScopedBlockPopupsPref() { SetPrefValue(original_setting_); }
-
- private:
-  // Gets the current value of the preference.
-  ContentSetting GetPrefValue() {
-    ContentSetting popupSetting =
-        ios::HostContentSettingsMapFactory::GetForBrowserState(
-            chrome_test_util::GetOriginalBrowserState())
-            ->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, NULL);
-    return popupSetting;
-  }
-
-  // Sets the preference to the given value.
-  void SetPrefValue(ContentSetting setting) {
-    DCHECK(setting == CONTENT_SETTING_BLOCK ||
-           setting == CONTENT_SETTING_ALLOW);
-    ios::ChromeBrowserState* state =
-        chrome_test_util::GetOriginalBrowserState();
-    ios::HostContentSettingsMapFactory::GetForBrowserState(state)
-        ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, setting);
-  }
-
-  // Saves the original pref setting so that it can be restored when the scoper
-  // is destroyed.
-  ContentSetting original_setting_;
-
-  DISALLOW_COPY_AND_ASSIGN(ScopedBlockPopupsPref);
-};
-
 }  // namespace
 
 // Tests the browser cache behavior when navigating to cached pages.
@@ -213,7 +174,8 @@
 
   // Open the first page in a new tab. Verify that cache was not used. Must
   // first allow popups.
-  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW);
+  ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW,
+                                   GetOriginalBrowserState());
   chrome_test_util::TapWebViewElementWithId(kCacheTestLinkID);
   [ChromeEarlGrey waitForMainTabCount:2];
   [ChromeEarlGrey waitForPageToFinishLoading];
diff --git a/ios/chrome/test/BUILD.gn b/ios/chrome/test/BUILD.gn
index 946070f..9a70102 100644
--- a/ios/chrome/test/BUILD.gn
+++ b/ios/chrome/test/BUILD.gn
@@ -28,6 +28,8 @@
     "ios_chrome_scoped_testing_local_state.h",
     "ios_chrome_unit_test_suite.h",
     "ios_chrome_unit_test_suite.mm",
+    "scoped_block_popups_pref.h",
+    "scoped_block_popups_pref.mm",
     "scoped_key_window.h",
     "testing_application_context.h",
     "testing_application_context.mm",
@@ -40,6 +42,7 @@
   deps = [
     "//base",
     "//base/test:test_support",
+    "//components/content_settings/core/browser",
     "//components/content_settings/core/common",
     "//components/network_time",
     "//components/prefs",
@@ -47,6 +50,7 @@
     "//ios/chrome/browser",
     "//ios/chrome/browser/browser_state",
     "//ios/chrome/browser/browser_state:browser_state_impl",
+    "//ios/chrome/browser/content_settings",
     "//ios/chrome/browser/prefs:browser_prefs",
     "//ios/public/provider/chrome/browser",
     "//ios/public/provider/chrome/browser:test_support",
diff --git a/ios/chrome/test/scoped_block_popups_pref.h b/ios/chrome/test/scoped_block_popups_pref.h
new file mode 100644
index 0000000..fd307a9
--- /dev/null
+++ b/ios/chrome/test/scoped_block_popups_pref.h
@@ -0,0 +1,41 @@
+// Copyright 2017 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.
+
+#ifndef IOS_CHROME_TEST_SCOPED_BLOCK_POPUPS_PREF_H_
+#define IOS_CHROME_TEST_SCOPED_BLOCK_POPUPS_PREF_H_
+
+#include "base/macros.h"
+#include "components/content_settings/core/common/content_settings.h"
+
+namespace ios {
+class ChromeBrowserState;
+}
+
+// ScopedBlockPopupsPref modifies the block popups preference
+// and resets the preference to its original value when this object goes out of
+// scope.
+class ScopedBlockPopupsPref {
+ public:
+  explicit ScopedBlockPopupsPref(ContentSetting setting,
+                                 ios::ChromeBrowserState* browser_state);
+  ~ScopedBlockPopupsPref();
+
+ private:
+  // Gets the current value of the preference.
+  ContentSetting GetPrefValue();
+
+  // Sets the preference to the given value.
+  void SetPrefValue(ContentSetting setting);
+
+  // Saves the browser state, which is required when getting and setting prefs.
+  ios::ChromeBrowserState* browser_state_;
+
+  // Saves the original pref setting so that it can be restored when the scoper
+  // is destroyed.
+  ContentSetting original_setting_;
+
+  DISALLOW_COPY_AND_ASSIGN(ScopedBlockPopupsPref);
+};
+
+#endif  // IOS_CHROME_TEST_SCOPED_BLOCK_POPUPS_PREF_H_
diff --git a/ios/chrome/test/scoped_block_popups_pref.mm b/ios/chrome/test/scoped_block_popups_pref.mm
new file mode 100644
index 0000000..96ca9e4
--- /dev/null
+++ b/ios/chrome/test/scoped_block_popups_pref.mm
@@ -0,0 +1,34 @@
+// Copyright 2017 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 "ios/chrome/test/scoped_block_popups_pref.h"
+
+#include "components/content_settings/core/browser/host_content_settings_map.h"
+#include "ios/chrome/browser/content_settings/host_content_settings_map_factory.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+ScopedBlockPopupsPref::ScopedBlockPopupsPref(
+    ContentSetting setting,
+    ios::ChromeBrowserState* browser_state)
+    : browser_state_(browser_state), original_setting_(GetPrefValue()) {
+  SetPrefValue(setting);
+}
+
+ScopedBlockPopupsPref::~ScopedBlockPopupsPref() {
+  SetPrefValue(original_setting_);
+}
+
+ContentSetting ScopedBlockPopupsPref::GetPrefValue() {
+  return ios::HostContentSettingsMapFactory::GetForBrowserState(browser_state_)
+      ->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, NULL);
+}
+
+void ScopedBlockPopupsPref::SetPrefValue(ContentSetting setting) {
+  DCHECK(setting == CONTENT_SETTING_BLOCK || setting == CONTENT_SETTING_ALLOW);
+  ios::HostContentSettingsMapFactory::GetForBrowserState(browser_state_)
+      ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, setting);
+}
diff --git a/third_party/WebKit/LayoutTests/FlagExpectations/enable-slimming-paint-v2 b/third_party/WebKit/LayoutTests/FlagExpectations/enable-slimming-paint-v2
index 3d1df3f..5f6e2fc 100644
--- a/third_party/WebKit/LayoutTests/FlagExpectations/enable-slimming-paint-v2
+++ b/third_party/WebKit/LayoutTests/FlagExpectations/enable-slimming-paint-v2
@@ -955,7 +955,6 @@
 Bug(none) paint/invalidation/overflow/opacity-change-on-overflow-float.html [ Failure ]
 Bug(none) paint/invalidation/position/relative-positioned-movement-repaint.html [ Failure ]
 Bug(none) paint/invalidation/repaint-across-writing-mode-boundary.html [ Failure ]
-Bug(none) paint/invalidation/reflection/scroll-absolute-layer-with-reflection.html [ Failure ]
 Bug(none) paint/invalidation/scroll/scroll-fixed-layer-with-transformed-parent-layer.html [ Failure ]
 Bug(none) paint/invalidation/scroll/scrolled-iframe-scrollbar-change.html [ Failure ]
 Bug(none) paint/invalidation/selection/repaint-rect-for-vertical-writing-mode-with-positioned-root.html [ Failure ]
@@ -1061,7 +1060,6 @@
 crbug.com/757977 paint/invalidation/invalidate-descendants-when-receiving-paint-layer.html [ Failure ]
 
 # Less layers or other different layer trees.
-Bug(none) paint/invalidation/filters/filter-invalidation-with-composited-container-change.html [ Failure ]
 Bug(none) paint/invalidation/compositing/stacked-float-under-composited-inline.html [ Failure ]
 Bug(none) paint/invalidation/compositing/fixed-pos-inside-composited-intermediate-layer.html [ Failure ]
 Bug(none) paint/invalidation/compositing/should-not-repaint-composited-descendants-on-overflow-change.html [ Failure ]
@@ -1072,7 +1070,6 @@
 Bug(none) paint/invalidation/compositing/iframe-inside-squashed-layer.html [ Failure ]
 Bug(none) paint/invalidation/compositing/overlap-test-with-filter.html [ Failure ]
 Bug(none) paint/invalidation/compositing/should-not-repaint-composited-descendants.html [ Failure ]
-Bug(none) paint/invalidation/filters/filter-repaint-accelerated-child-with-filter-child.html [ Failure ]
 Bug(none) paint/invalidation/video-paint-invalidation.html [ Failure ]
 
 # Raster invalidation for background on scrolling contents layer.
@@ -1782,8 +1779,6 @@
 Bug(none) fast/multicol/scale-transform-text.html [ Failure ]
 
 Bug(none) compositing/rendering-contexts.html [ Failure ]
-
-Bug(none) paint/invalidation/filters/effect-reference-repaint-primitive-attr-mutation.html [ Failure ]
 Bug(none) compositing/overflow-trumps-transform-style.html [ Failure ]
 
 Bug(none) css3/blending/mix-blend-mode-simple.html [ Pass Timeout ]
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations
index 064e5bd..6388bb7 100644
--- a/third_party/WebKit/LayoutTests/TestExpectations
+++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -118,16 +118,12 @@
 crbug.com/771643 virtual/spv175/paint/invalidation/compositing/newly-composited-repaint-rect.html [ Failure ]
 crbug.com/771643 virtual/spv175/paint/invalidation/compositing/resize-squashing-layer-that-needs-full-repaint.html [ Failure ]
 crbug.com/771643 virtual/spv175/paint/invalidation/compositing/subpixel-offset-scaled-transform-composited.html [ Failure ]
-# Seems to pass with DCHECK.
-crbug.com/771643 virtual/spv175/paint/invalidation/filters/filter-on-html-element-with-fixed-position-child.html [ Failure Pass ]
 crbug.com/771643 virtual/spv175/paint/invalidation/forms/select-option-background-color.html [ Failure ]
 crbug.com/771643 virtual/spv175/paint/invalidation/multicol/multicol-with-overflowing-block-rl.html [ Failure ]
 crbug.com/771643 virtual/spv175/paint/invalidation/overflow/composited-overflow-with-negative-offset-outline.html [ Failure ]
 crbug.com/771643 virtual/spv175/paint/invalidation/overflow/paged-with-overflowing-block-rl.html [ Failure ]
 crbug.com/771643 virtual/spv175/paint/invalidation/position/position-change-keeping-geometry.html [ Failure ]
 crbug.com/771643 virtual/spv175/paint/invalidation/reflection/reflection-repaint-test.html [ Failure ]
-# Seems to pass with DCHECK.
-crbug.com/771643 virtual/spv175/paint/invalidation/reflection/reflection-redraw.html [ Failure Pass ]
 crbug.com/771643 virtual/spv175/paint/invalidation/scroll/repaint-during-scroll-with-zoom.html [ Failure ]
 crbug.com/771643 virtual/spv175/paint/invalidation/scroll/resize-scrollable-iframe.html [ Failure ]
 crbug.com/771643 virtual/spv175/paint/invalidation/scroll/scroll-descendant-with-cached-cliprects.html [ Failure ]
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-1-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-1-expected.txt
deleted file mode 100644
index 23b19887..0000000
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-1-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='before box'",
-          "rect": [128, 120, 100, 100],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-2-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-2-expected.txt
deleted file mode 100644
index 878badb..0000000
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-2-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='before box'",
-          "rect": [128, 120, 200, 200],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-3-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-3-expected.txt
index 5548f86..3046438 100644
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-3-expected.txt
+++ b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-3-expected.txt
@@ -7,9 +7,9 @@
       "backgroundColor": "#FFFFFF",
       "paintInvalidations": [
         {
-          "object": "LayoutBlockFlow DIV class='before box'",
+          "object": "LayoutBlockFlow DIV class='box'",
           "rect": [0, 0, 328, 320],
-          "reason": "paint property change"
+          "reason": "style change"
         }
       ]
     }
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-4-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-4-expected.txt
deleted file mode 100644
index 878badb..0000000
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-4-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='before box'",
-          "rect": [128, 120, 200, 200],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-5-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-5-expected.txt
deleted file mode 100644
index 23b19887..0000000
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-5-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='before box'",
-          "rect": [128, 120, 100, 100],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-6-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-6-expected.txt
deleted file mode 100644
index 77e9c14..0000000
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-composite-6-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='before box'",
-          "rect": [28, 20, 300, 300],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-gaussianblur-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-gaussianblur-expected.txt
index de030e92..eefd415 100644
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-gaussianblur-expected.txt
+++ b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-gaussianblur-expected.txt
@@ -7,9 +7,9 @@
       "backgroundColor": "#FFFFFF",
       "paintInvalidations": [
         {
-          "object": "LayoutBlockFlow DIV class='box before'",
+          "object": "LayoutBlockFlow DIV class='box'",
           "rect": [0, 0, 318, 310],
-          "reason": "paint property change"
+          "reason": "style change"
         }
       ]
     }
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-gaussianblur-xonly-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-gaussianblur-xonly-expected.txt
index c1ae364..0ab97da 100644
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-gaussianblur-xonly-expected.txt
+++ b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-gaussianblur-xonly-expected.txt
@@ -7,9 +7,9 @@
       "backgroundColor": "#FFFFFF",
       "paintInvalidations": [
         {
-          "object": "LayoutBlockFlow DIV class='box before'",
+          "object": "LayoutBlockFlow DIV class='box'",
           "rect": [0, 50, 318, 200],
-          "reason": "paint property change"
+          "reason": "style change"
         }
       ]
     }
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-gaussianblur-yonly-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-gaussianblur-yonly-expected.txt
index 2949faf2..76b4b43 100644
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-gaussianblur-yonly-expected.txt
+++ b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-gaussianblur-yonly-expected.txt
@@ -7,9 +7,9 @@
       "backgroundColor": "#FFFFFF",
       "paintInvalidations": [
         {
-          "object": "LayoutBlockFlow DIV class='box before'",
+          "object": "LayoutBlockFlow DIV class='box'",
           "rect": [58, 0, 200, 310],
-          "reason": "paint property change"
+          "reason": "style change"
         }
       ]
     }
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-merge-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-merge-expected.txt
deleted file mode 100644
index 77e9c14..0000000
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-merge-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='before box'",
-          "rect": [28, 20, 300, 300],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-morphology-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-morphology-expected.txt
deleted file mode 100644
index 7b2050ee..0000000
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-morphology-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='box before'",
-          "rect": [33, 25, 250, 250],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-morphology-xonly-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-morphology-xonly-expected.txt
deleted file mode 100644
index efb4a12..0000000
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-morphology-xonly-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='box before'",
-          "rect": [33, 50, 250, 200],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-morphology-yonly-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-morphology-yonly-expected.txt
deleted file mode 100644
index 1a9b467..0000000
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-morphology-yonly-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='box before'",
-          "rect": [58, 25, 200, 250],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-offset-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-offset-expected.txt
deleted file mode 100644
index 0faf0760..0000000
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-offset-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='box before'",
-          "rect": [198, 198, 110, 110],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-displacement-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-primitive-attr-mutation-expected.txt
similarity index 63%
rename from third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-displacement-expected.txt
rename to third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-primitive-attr-mutation-expected.txt
index f2dcdc4..57b04ac2 100644
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-displacement-expected.txt
+++ b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/effect-reference-repaint-primitive-attr-mutation-expected.txt
@@ -7,8 +7,8 @@
       "backgroundColor": "#FFFFFF",
       "paintInvalidations": [
         {
-          "object": "LayoutBlockFlow DIV class='before box'",
-          "rect": [8, 0, 240, 240],
+          "object": "LayoutBlockFlow DIV class='target'",
+          "rect": [8, 8, 100, 100],
           "reason": "paint property change"
         }
       ]
@@ -16,8 +16,8 @@
   ],
   "objectPaintInvalidations": [
     {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
+      "object": "LayoutBlockFlow DIV class='target'",
+      "reason": "full"
     }
   ]
 }
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/filter-invalidation-with-composited-container-change-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/filter-invalidation-with-composited-container-change-expected.txt
new file mode 100644
index 0000000..62bda85
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/filter-invalidation-with-composited-container-change-expected.txt
@@ -0,0 +1,42 @@
+{
+  "layers": [
+    {
+      "name": "LayoutView #document",
+      "bounds": [800, 600],
+      "contentsOpaque": true,
+      "backgroundColor": "#FFFFFF",
+      "paintInvalidations": [
+        {
+          "object": "LayoutBlockFlow DIV id='box' class='green drop-shadowed box'",
+          "rect": [8, 8, 330, 330],
+          "reason": "disappeared"
+        }
+      ]
+    },
+    {
+      "name": "LayoutBlockFlow DIV id='box' class='green box blurry'",
+      "position": [-30, -30],
+      "bounds": [260, 260],
+      "backgroundColor": "#008000",
+      "transform": 1
+    }
+  ],
+  "transforms": [
+    {
+      "id": 1,
+      "transform": [
+        [1, 0, 0, 0],
+        [0, 1, 0, 0],
+        [0, 0, 1, 0],
+        [8, 8, 0, 1]
+      ]
+    }
+  ],
+  "objectPaintInvalidations": [
+    {
+      "object": "LayoutBlockFlow DIV id='box' class='green box blurry'",
+      "reason": "geometry"
+    }
+  ]
+}
+
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/filter-repaint-accelerated-child-with-filter-child-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/filter-repaint-accelerated-child-with-filter-child-expected.txt
new file mode 100644
index 0000000..5b96792
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/filters/filter-repaint-accelerated-child-with-filter-child-expected.txt
@@ -0,0 +1,42 @@
+{
+  "layers": [
+    {
+      "name": "LayoutView #document",
+      "bounds": [800, 600],
+      "contentsOpaque": true,
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "LayoutBlockFlow DIV id='resize' class='drop-shadow'",
+      "position": [-14, -14],
+      "bounds": [160, 260],
+      "backgroundColor": "#008000",
+      "paintInvalidations": [
+        {
+          "object": "LayoutBlockFlow DIV id='resize' class='drop-shadow'",
+          "rect": [0, 0, 160, 260],
+          "reason": "geometry"
+        }
+      ],
+      "transform": 1
+    }
+  ],
+  "transforms": [
+    {
+      "id": 1,
+      "transform": [
+        [1, 0, 0, 0],
+        [0, 1, 0, 0],
+        [0, 0, 1, 0],
+        [8, 8, 0, 1]
+      ]
+    }
+  ],
+  "objectPaintInvalidations": [
+    {
+      "object": "LayoutBlockFlow DIV id='resize' class='drop-shadow'",
+      "reason": "geometry"
+    }
+  ]
+}
+
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/reflection/reflection-redraw-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/reflection/reflection-redraw-expected.txt
index 02c9dc6..63c0b80 100644
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/reflection/reflection-redraw-expected.txt
+++ b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/reflection/reflection-redraw-expected.txt
@@ -7,44 +7,64 @@
       "backgroundColor": "#FFFFFF",
       "paintInvalidations": [
         {
-          "object": "LayoutBlockFlow (positioned) DIV class='box reflect-right'",
-          "rect": [368, 240, 310, 100],
-          "reason": "paint property change"
-        },
-        {
-          "object": "LayoutBlockFlow (positioned) DIV class='box reflect-left'",
-          "rect": [58, 240, 310, 100],
-          "reason": "paint property change"
-        },
-        {
-          "object": "LayoutBlockFlow (positioned) DIV class='box reflect-right'",
+          "object": "InlineTextBox 'The color of this'",
           "rect": [380, 267, 286, 59],
-          "reason": "paint property change"
+          "reason": "style change"
         },
         {
-          "object": "LayoutBlockFlow (positioned) DIV class='box reflect-left'",
+          "object": "InlineTextBox 'should be green'",
+          "rect": [380, 267, 286, 59],
+          "reason": "style change"
+        },
+        {
+          "object": "InlineTextBox 'text in the reflection'",
+          "rect": [380, 267, 286, 59],
+          "reason": "style change"
+        },
+        {
+          "object": "InlineTextBox 'The color of this'",
           "rect": [70, 267, 286, 59],
-          "reason": "paint property change"
+          "reason": "style change"
         },
         {
-          "object": "LayoutBlockFlow (positioned) DIV class='box reflect-bottom'",
-          "rect": [293, 350, 150, 210],
-          "reason": "paint property change"
+          "object": "InlineTextBox 'should be green'",
+          "rect": [70, 267, 286, 59],
+          "reason": "style change"
         },
         {
-          "object": "LayoutBlockFlow (positioned) DIV class='box reflect-top'",
-          "rect": [293, 20, 150, 210],
-          "reason": "paint property change"
+          "object": "InlineTextBox 'text in the reflection'",
+          "rect": [70, 267, 286, 59],
+          "reason": "style change"
         },
         {
-          "object": "LayoutBlockFlow (positioned) DIV class='box reflect-top'",
+          "object": "InlineTextBox 'The color of this'",
           "rect": [305, 34, 126, 182],
-          "reason": "paint property change"
+          "reason": "style change"
         },
         {
-          "object": "LayoutBlockFlow (positioned) DIV class='box reflect-bottom'",
+          "object": "InlineTextBox 'should be green'",
+          "rect": [305, 34, 126, 182],
+          "reason": "style change"
+        },
+        {
+          "object": "InlineTextBox 'text in the reflection'",
+          "rect": [305, 34, 126, 182],
+          "reason": "style change"
+        },
+        {
+          "object": "InlineTextBox 'The color of this'",
           "rect": [305, 377, 126, 156],
-          "reason": "paint property change"
+          "reason": "style change"
+        },
+        {
+          "object": "InlineTextBox 'should be green'",
+          "rect": [305, 377, 126, 156],
+          "reason": "style change"
+        },
+        {
+          "object": "InlineTextBox 'text in the reflection'",
+          "rect": [305, 377, 126, 156],
+          "reason": "style change"
         }
       ]
     }
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/reflection/reflection-repaint-test-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/reflection/reflection-repaint-test-expected.txt
index bdcef2f..c7374bb 100644
--- a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/reflection/reflection-repaint-test-expected.txt
+++ b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/reflection/reflection-repaint-test-expected.txt
@@ -9,17 +9,17 @@
         {
           "object": "LayoutBlockFlow DIV id='target'",
           "rect": [22, 50, 226, 167],
-          "reason": "paint property change"
+          "reason": "geometry"
         },
         {
-          "object": "LayoutBlockFlow DIV id='target'",
+          "object": "InlineTextBox 'PASS'",
           "rect": [23, 51, 72, 110],
-          "reason": "paint property change"
+          "reason": "appeared"
         },
         {
-          "object": "LayoutBlockFlow DIV id='target'",
+          "object": "InlineTextBox 'FAIL'",
           "rect": [23, 51, 69, 109],
-          "reason": "paint property change"
+          "reason": "disappeared"
         }
       ]
     }
diff --git a/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/reflection/scroll-absolute-layer-with-reflection-expected.txt b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/reflection/scroll-absolute-layer-with-reflection-expected.txt
new file mode 100644
index 0000000..74ffc9b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/flag-specific/enable-slimming-paint-v2/paint/invalidation/reflection/scroll-absolute-layer-with-reflection-expected.txt
@@ -0,0 +1,54 @@
+{
+  "layers": [
+    {
+      "name": "LayoutView #document",
+      "bounds": [800, 2016],
+      "contentsOpaque": true,
+      "backgroundColor": "#FFFFFF",
+      "paintInvalidations": [
+        {
+          "object": "LayoutBlockFlow (positioned) DIV class='absolute red'",
+          "rect": [250, 230, 100, 100],
+          "reason": "disappeared"
+        },
+        {
+          "object": "LayoutBlockFlow (relative positioned) DIV class='relative reflected'",
+          "rect": [250, 230, 100, 100],
+          "reason": "appeared"
+        }
+      ],
+      "transform": 1
+    }
+  ],
+  "transforms": [
+    {
+      "id": 1,
+      "transform": [
+        [1, 0, 0, 0],
+        [0, 1, 0, 0],
+        [0, 0, 1, 0],
+        [0, -180, 0, 1]
+      ],
+      "flattenInheritedTransform": false
+    }
+  ],
+  "objectPaintInvalidations": [
+    {
+      "object": "LayoutBlockFlow (positioned) DIV id='moveMe' class='absolute clipped'",
+      "reason": "geometry"
+    },
+    {
+      "object": "LayoutBlockFlow (relative positioned) DIV class='relative reflected'",
+      "reason": "geometry"
+    },
+    {
+      "object": "LayoutBlockFlow DIV class='green'",
+      "reason": "geometry"
+    },
+    {
+      "object": "LayoutBlockFlow (positioned) DIV class='absolute red'",
+      "reason": "geometry"
+    }
+  ]
+}
+
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-pause/set-return-value-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-pause/set-return-value-expected.txt
new file mode 100644
index 0000000..95f05fd
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-pause/set-return-value-expected.txt
@@ -0,0 +1,47 @@
+Check that return value can be changed.
+Set timer for test function.
+Script execution paused.
+Dump current
+Expanded property: Return value
+Scope variables sidebar pane:
+Local
+    Return value: 42
+    this: undefined
+    x: 42
+WindowGlobal
+    <section collapsed>
+Set return value to {a:1}
+Expanded property: Return value
+Scope variables sidebar pane:
+Local
+    Return value: Object
+        a: 1
+        __proto__: Object
+    this: undefined
+    x: 42
+WindowGlobal
+    <section collapsed>
+Try to remove return value
+Expanded property: Return value
+Scope variables sidebar pane:
+Local
+    Return value: Object
+        a: 1
+        __proto__: Object
+    this: undefined
+    x: 42
+WindowGlobal
+    <section collapsed>
+Set return value to 239
+Expanded property: Return value
+Scope variables sidebar pane:
+Local
+    Return value: 239
+    this: undefined
+    x: 42
+WindowGlobal
+    <section collapsed>
+Script execution resumed.
+Actual return value:
+239
+
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-pause/set-return-value.js b/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-pause/set-return-value.js
new file mode 100644
index 0000000..8f349e5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-pause/set-return-value.js
@@ -0,0 +1,51 @@
+// Copyright 2017 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.
+
+(async function() {
+  TestRunner.addResult('Check that return value can be changed.');
+  await TestRunner.loadModule('console_test_runner');
+  await TestRunner.loadModule('sources_test_runner');
+  await TestRunner.showPanel('sources');
+  await TestRunner.evaluateInPagePromise(`
+    function testFunction() {
+      Promise.resolve(42).then(x => x).then(console.log);
+    }
+    //# sourceURL=test.js
+  `);
+  await SourcesTestRunner.startDebuggerTestPromise();
+  await TestRunner.DebuggerAgent.invoke_setBreakpointByUrl({lineNumber: 11, url: 'test.js', columnNumber: 37});
+  let sidebarUpdated = TestRunner.addSnifferPromise(
+        Sources.ScopeChainSidebarPane.prototype, '_sidebarPaneUpdatedForTest');
+  await Promise.all([SourcesTestRunner.runTestFunctionAndWaitUntilPausedPromise(), sidebarUpdated]);
+  let localScope = SourcesTestRunner.scopeChainSections()[0].objectTreeElement();
+
+  TestRunner.addResult('Dump current');
+  await new Promise(resolve => SourcesTestRunner.expandProperties([localScope, ['Return value']], resolve));
+  SourcesTestRunner.dumpScopeVariablesSidebarPane();
+
+  TestRunner.addResult('Set return value to {a:1}');
+  let returnValueElement = localScope.children().find(x => x.property.name === 'Return value');
+  await returnValueElement._applyExpression('{a:1}');
+  await new Promise(resolve => SourcesTestRunner.expandProperties([localScope, ['Return value']], resolve));
+  SourcesTestRunner.dumpScopeVariablesSidebarPane();
+
+  TestRunner.addResult('Try to remove return value');
+  returnValueElement = localScope.children().find(x => x.property.name === 'Return value');
+  await returnValueElement._applyExpression('');
+  await new Promise(resolve => SourcesTestRunner.expandProperties([localScope, ['Return value']], resolve));
+  SourcesTestRunner.dumpScopeVariablesSidebarPane();
+
+  TestRunner.addResult('Set return value to 239');
+  returnValueElement = localScope.children().find(x => x.property.name === 'Return value');
+  await returnValueElement._applyExpression('239');
+  await new Promise(resolve => SourcesTestRunner.expandProperties([localScope, ['Return value']], resolve));
+  SourcesTestRunner.dumpScopeVariablesSidebarPane();
+
+  SourcesTestRunner.resumeExecution();
+  await ConsoleTestRunner.waitUntilMessageReceivedPromise();
+  TestRunner.addResult('Actual return value:');
+  ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames();
+
+  SourcesTestRunner.completeDebuggerTest();
+})();
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-1-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-1-expected.txt
deleted file mode 100644
index 23b19887..0000000
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-1-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='before box'",
-          "rect": [128, 120, 100, 100],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-2-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-2-expected.txt
deleted file mode 100644
index 878badb..0000000
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-2-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='before box'",
-          "rect": [128, 120, 200, 200],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-3-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-3-expected.txt
index 5548f86..3046438 100644
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-3-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-3-expected.txt
@@ -7,9 +7,9 @@
       "backgroundColor": "#FFFFFF",
       "paintInvalidations": [
         {
-          "object": "LayoutBlockFlow DIV class='before box'",
+          "object": "LayoutBlockFlow DIV class='box'",
           "rect": [0, 0, 328, 320],
-          "reason": "paint property change"
+          "reason": "style change"
         }
       ]
     }
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-4-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-4-expected.txt
deleted file mode 100644
index 878badb..0000000
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-4-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='before box'",
-          "rect": [128, 120, 200, 200],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-5-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-5-expected.txt
deleted file mode 100644
index 23b19887..0000000
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-5-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='before box'",
-          "rect": [128, 120, 100, 100],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-6-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-6-expected.txt
deleted file mode 100644
index 77e9c14..0000000
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-composite-6-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='before box'",
-          "rect": [28, 20, 300, 300],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-displacement-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-displacement-expected.txt
deleted file mode 100644
index f2dcdc4..0000000
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-displacement-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='before box'",
-          "rect": [8, 0, 240, 240],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-gaussianblur-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-gaussianblur-expected.txt
index de030e92..eefd415 100644
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-gaussianblur-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-gaussianblur-expected.txt
@@ -7,9 +7,9 @@
       "backgroundColor": "#FFFFFF",
       "paintInvalidations": [
         {
-          "object": "LayoutBlockFlow DIV class='box before'",
+          "object": "LayoutBlockFlow DIV class='box'",
           "rect": [0, 0, 318, 310],
-          "reason": "paint property change"
+          "reason": "style change"
         }
       ]
     }
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-gaussianblur-xonly-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-gaussianblur-xonly-expected.txt
index c1ae364..0ab97da 100644
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-gaussianblur-xonly-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-gaussianblur-xonly-expected.txt
@@ -7,9 +7,9 @@
       "backgroundColor": "#FFFFFF",
       "paintInvalidations": [
         {
-          "object": "LayoutBlockFlow DIV class='box before'",
+          "object": "LayoutBlockFlow DIV class='box'",
           "rect": [0, 50, 318, 200],
-          "reason": "paint property change"
+          "reason": "style change"
         }
       ]
     }
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-gaussianblur-yonly-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-gaussianblur-yonly-expected.txt
index 2949faf2..76b4b43 100644
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-gaussianblur-yonly-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-gaussianblur-yonly-expected.txt
@@ -7,9 +7,9 @@
       "backgroundColor": "#FFFFFF",
       "paintInvalidations": [
         {
-          "object": "LayoutBlockFlow DIV class='box before'",
+          "object": "LayoutBlockFlow DIV class='box'",
           "rect": [58, 0, 200, 310],
-          "reason": "paint property change"
+          "reason": "style change"
         }
       ]
     }
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-merge-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-merge-expected.txt
deleted file mode 100644
index 77e9c14..0000000
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-merge-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='before box'",
-          "rect": [28, 20, 300, 300],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-morphology-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-morphology-expected.txt
deleted file mode 100644
index 7b2050ee..0000000
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-morphology-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='box before'",
-          "rect": [33, 25, 250, 250],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-morphology-xonly-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-morphology-xonly-expected.txt
deleted file mode 100644
index efb4a12..0000000
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-morphology-xonly-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='box before'",
-          "rect": [33, 50, 250, 200],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-morphology-yonly-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-morphology-yonly-expected.txt
deleted file mode 100644
index 1a9b467..0000000
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-morphology-yonly-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='box before'",
-          "rect": [58, 25, 200, 250],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-offset-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-offset-expected.txt
deleted file mode 100644
index 0faf0760..0000000
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/effect-reference-repaint-offset-expected.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "layers": [
-    {
-      "name": "LayoutView #document",
-      "bounds": [800, 600],
-      "contentsOpaque": true,
-      "backgroundColor": "#FFFFFF",
-      "paintInvalidations": [
-        {
-          "object": "LayoutBlockFlow DIV class='box before'",
-          "rect": [198, 198, 110, 110],
-          "reason": "paint property change"
-        }
-      ]
-    }
-  ],
-  "objectPaintInvalidations": [
-    {
-      "object": "LayoutBlockFlow DIV class='box'",
-      "reason": "style change"
-    }
-  ]
-}
-
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/filter-on-html-element-with-fixed-position-child-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/filter-on-html-element-with-fixed-position-child-expected.txt
index 702f11f9..40f912d 100644
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/filter-on-html-element-with-fixed-position-child-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/filters/filter-on-html-element-with-fixed-position-child-expected.txt
@@ -12,11 +12,6 @@
           "reason": "full"
         },
         {
-          "object": "LayoutBlockFlow HTML",
-          "rect": [8, 8, 200, 10000],
-          "reason": "paint property change"
-        },
-        {
           "object": "LayoutBlockFlow (positioned) DIV",
           "rect": [100, 110, 100, 100],
           "reason": "paint property change"
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/reflection/reflection-redraw-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/reflection/reflection-redraw-expected.txt
index 016f58b2..63c0b80 100644
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/reflection/reflection-redraw-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/reflection/reflection-redraw-expected.txt
@@ -7,24 +7,64 @@
       "backgroundColor": "#FFFFFF",
       "paintInvalidations": [
         {
-          "object": "LayoutBlockFlow (positioned) DIV class='box reflect-right'",
-          "rect": [368, 240, 310, 100],
-          "reason": "paint property change"
+          "object": "InlineTextBox 'The color of this'",
+          "rect": [380, 267, 286, 59],
+          "reason": "style change"
         },
         {
-          "object": "LayoutBlockFlow (positioned) DIV class='box reflect-left'",
-          "rect": [58, 240, 310, 100],
-          "reason": "paint property change"
+          "object": "InlineTextBox 'should be green'",
+          "rect": [380, 267, 286, 59],
+          "reason": "style change"
         },
         {
-          "object": "LayoutBlockFlow (positioned) DIV class='box reflect-bottom'",
-          "rect": [293, 350, 150, 210],
-          "reason": "paint property change"
+          "object": "InlineTextBox 'text in the reflection'",
+          "rect": [380, 267, 286, 59],
+          "reason": "style change"
         },
         {
-          "object": "LayoutBlockFlow (positioned) DIV class='box reflect-top'",
-          "rect": [293, 20, 150, 210],
-          "reason": "paint property change"
+          "object": "InlineTextBox 'The color of this'",
+          "rect": [70, 267, 286, 59],
+          "reason": "style change"
+        },
+        {
+          "object": "InlineTextBox 'should be green'",
+          "rect": [70, 267, 286, 59],
+          "reason": "style change"
+        },
+        {
+          "object": "InlineTextBox 'text in the reflection'",
+          "rect": [70, 267, 286, 59],
+          "reason": "style change"
+        },
+        {
+          "object": "InlineTextBox 'The color of this'",
+          "rect": [305, 34, 126, 182],
+          "reason": "style change"
+        },
+        {
+          "object": "InlineTextBox 'should be green'",
+          "rect": [305, 34, 126, 182],
+          "reason": "style change"
+        },
+        {
+          "object": "InlineTextBox 'text in the reflection'",
+          "rect": [305, 34, 126, 182],
+          "reason": "style change"
+        },
+        {
+          "object": "InlineTextBox 'The color of this'",
+          "rect": [305, 377, 126, 156],
+          "reason": "style change"
+        },
+        {
+          "object": "InlineTextBox 'should be green'",
+          "rect": [305, 377, 126, 156],
+          "reason": "style change"
+        },
+        {
+          "object": "InlineTextBox 'text in the reflection'",
+          "rect": [305, 377, 126, 156],
+          "reason": "style change"
         }
       ]
     }
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/reflection/reflection-repaint-test-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/reflection/reflection-repaint-test-expected.txt
index e739d7c..c7374bb 100644
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/reflection/reflection-repaint-test-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/reflection/reflection-repaint-test-expected.txt
@@ -9,7 +9,17 @@
         {
           "object": "LayoutBlockFlow DIV id='target'",
           "rect": [22, 50, 226, 167],
-          "reason": "paint property change"
+          "reason": "geometry"
+        },
+        {
+          "object": "InlineTextBox 'PASS'",
+          "rect": [23, 51, 72, 110],
+          "reason": "appeared"
+        },
+        {
+          "object": "InlineTextBox 'FAIL'",
+          "rect": [23, 51, 69, 109],
+          "reason": "disappeared"
         }
       ]
     }
diff --git a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/reflection/scroll-fixed-reflected-layer-expected.txt b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/reflection/scroll-fixed-reflected-layer-expected.txt
index f1ff7826..6e4452c 100644
--- a/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/reflection/scroll-fixed-reflected-layer-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/spv175/paint/invalidation/reflection/scroll-fixed-reflected-layer-expected.txt
@@ -14,7 +14,7 @@
         {
           "object": "LayoutBlockFlow (positioned) DIV id='hideMe' class='absolute red'",
           "rect": [250, 280, 100, 100],
-          "reason": "paint property change"
+          "reason": "style change"
         }
       ],
       "transform": 1
diff --git a/third_party/WebKit/Source/core/paint/FilterEffectBuilder.cpp b/third_party/WebKit/Source/core/paint/FilterEffectBuilder.cpp
index 1c769775..f566fb9 100644
--- a/third_party/WebKit/Source/core/paint/FilterEffectBuilder.cpp
+++ b/third_party/WebKit/Source/core/paint/FilterEffectBuilder.cpp
@@ -120,29 +120,26 @@
 
 }  // namespace
 
-FilterEffectBuilder::FilterEffectBuilder(const FloatRect& zoomed_reference_box,
+FilterEffectBuilder::FilterEffectBuilder(const FloatRect& reference_box,
                                          float zoom,
                                          const PaintFlags* fill_flags,
                                          const PaintFlags* stroke_flags)
     : FilterEffectBuilder(nullptr,
-                          zoomed_reference_box,
+                          reference_box,
                           zoom,
                           fill_flags,
                           stroke_flags) {}
 
 FilterEffectBuilder::FilterEffectBuilder(Node* target,
-                                         const FloatRect& zoomed_reference_box,
+                                         const FloatRect& reference_box,
                                          float zoom,
                                          const PaintFlags* fill_flags,
                                          const PaintFlags* stroke_flags)
     : target_context_(target),
-      reference_box_(zoomed_reference_box),
+      reference_box_(reference_box),
       zoom_(zoom),
       fill_flags_(fill_flags),
-      stroke_flags_(stroke_flags) {
-  if (zoom_ != 1)
-    reference_box_.Scale(1 / zoom_);
-}
+      stroke_flags_(stroke_flags) {}
 
 FilterEffect* FilterEffectBuilder::BuildFilterEffect(
     const FilterOperations& operations) const {
@@ -407,6 +404,10 @@
         nullptr, current_interpolation_space, kInterpolationSpaceSRGB);
     filters.AppendReferenceFilter(std::move(filter));
   }
+
+  if (!filters.IsEmpty())
+    filters.SetReferenceBox(reference_box_);
+
   return filters;
 }
 
diff --git a/third_party/WebKit/Source/core/paint/FilterEffectBuilder.h b/third_party/WebKit/Source/core/paint/FilterEffectBuilder.h
index e832365..839704b 100644
--- a/third_party/WebKit/Source/core/paint/FilterEffectBuilder.h
+++ b/third_party/WebKit/Source/core/paint/FilterEffectBuilder.h
@@ -48,12 +48,12 @@
   STACK_ALLOCATED();
 
  public:
-  FilterEffectBuilder(const FloatRect& zoomed_reference_box,
+  FilterEffectBuilder(const FloatRect& reference_box,
                       float zoom,
                       const PaintFlags* fill_flags = nullptr,
                       const PaintFlags* stroke_flags = nullptr);
   FilterEffectBuilder(Node*,
-                      const FloatRect& zoomed_reference_box,
+                      const FloatRect& reference_box,
                       float zoom,
                       const PaintFlags* fill_flags = nullptr,
                       const PaintFlags* stroke_flags = nullptr);
diff --git a/third_party/WebKit/Source/core/paint/FilterPainter.cpp b/third_party/WebKit/Source/core/paint/FilterPainter.cpp
index 3c387295..5a7e59f9 100644
--- a/third_party/WebKit/Source/core/paint/FilterPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/FilterPainter.cpp
@@ -57,9 +57,9 @@
   }
 
   if (!context.GetPaintController().DisplayItemConstructionIsDisabled()) {
-    CompositorFilterOperations compositor_filter_operations =
-        layer.CreateCompositorFilterOperationsForFilter(
-            layout_object_.StyleRef());
+    CompositorFilterOperations compositor_filter_operations;
+    layer.UpdateCompositorFilterOperationsForFilter(
+        compositor_filter_operations);
     // FIXME: It's possible to have empty CompositorFilterOperations here even
     // though the PaintFilter produced above is non-null, since the
     // layer's FilterEffectBuilder can have a stale representation of
diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.cpp b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
index d312a611..c8d0378 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayer.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
@@ -161,6 +161,7 @@
       has_non_isolated_descendant_with_blend_mode_(false),
       has_ancestor_with_clip_path_(false),
       self_painting_status_changed_(false),
+      filter_on_effect_node_dirty_(false),
       layout_object_(layout_object),
       parent_(nullptr),
       previous_(nullptr),
@@ -2468,10 +2469,17 @@
   return result_layer;
 }
 
-FloatRect PaintLayer::BoxForFilterOrMask() const {
-  return FloatRect(PhysicalBoundingBoxIncludingStackingChildren(
+FloatRect PaintLayer::FilterReferenceBox(const FilterOperations& filter,
+                                         float zoom) const {
+  if (!filter.HasReferenceFilter())
+    return FloatRect();
+
+  FloatRect reference_box(PhysicalBoundingBoxIncludingStackingChildren(
       LayoutPoint(), PaintLayer::CalculateBoundsOptions::
                          kIncludeTransformsAndCompositedChildLayers));
+  if (zoom != 1)
+    reference_box.Scale(1 / zoom);
+  return reference_box;
 }
 
 bool PaintLayer::HitTestClippedOutByClipPath(
@@ -3057,9 +3065,17 @@
 
 void PaintLayer::UpdateFilters(const ComputedStyle* old_style,
                                const ComputedStyle& new_style) {
+  if (!filter_on_effect_node_dirty_) {
+    filter_on_effect_node_dirty_ =
+        old_style ? !old_style->FilterDataEquivalent(new_style) ||
+                        !old_style->ReflectionDataEquivalent(new_style)
+                  : new_style.HasFilterInducingProperty();
+  }
+
   if (!new_style.HasFilterInducingProperty() &&
       (!old_style || !old_style->HasFilterInducingProperty()))
     return;
+
   const bool had_resource_info = ResourceInfo();
   if (new_style.HasFilterInducingProperty())
     new_style.Filter().AddClient(&EnsureResourceInfo());
@@ -3193,8 +3209,8 @@
   return false;
 }
 
-FilterOperations PaintLayer::AddReflectionToFilterOperations(
-    const ComputedStyle& style) const {
+FilterOperations PaintLayer::FilterOperationsIncludingReflection() const {
+  const auto& style = GetLayoutObject().StyleRef();
   FilterOperations filter_operations = style.Filter();
   if (GetLayoutObject().HasReflection() && GetLayoutObject().IsBox()) {
     BoxReflection reflection = BoxReflectionForPaintLayer(*this, style);
@@ -3204,26 +3220,27 @@
   return filter_operations;
 }
 
-CompositorFilterOperations
-PaintLayer::CreateCompositorFilterOperationsForFilter(
-    const ComputedStyle& style) {
-  FloatRect zoomed_reference_box;
-  if (style.Filter().HasReferenceFilter())
-    zoomed_reference_box = BoxForFilterOrMask();
-  FilterEffectBuilder builder(EnclosingNode(), zoomed_reference_box,
-                              style.EffectiveZoom());
-  return builder.BuildFilterOperations(AddReflectionToFilterOperations(style));
+void PaintLayer::UpdateCompositorFilterOperationsForFilter(
+    CompositorFilterOperations& operations) const {
+  const auto& style = GetLayoutObject().StyleRef();
+  float zoom = style.EffectiveZoom();
+  FloatRect reference_box = FilterReferenceBox(style.Filter(), zoom);
+  if (!operations.IsEmpty() && !filter_on_effect_node_dirty_ &&
+      reference_box == operations.ReferenceBox())
+    return;
+
+  operations =
+      FilterEffectBuilder(EnclosingNode(), reference_box, zoom)
+          .BuildFilterOperations(FilterOperationsIncludingReflection());
 }
 
 CompositorFilterOperations
-PaintLayer::CreateCompositorFilterOperationsForBackdropFilter(
-    const ComputedStyle& style) {
-  FloatRect zoomed_reference_box;
-  if (style.BackdropFilter().HasReferenceFilter())
-    zoomed_reference_box = BoxForFilterOrMask();
-  FilterEffectBuilder builder(EnclosingNode(), zoomed_reference_box,
-                              style.EffectiveZoom());
-  return builder.BuildFilterOperations(style.BackdropFilter());
+PaintLayer::CreateCompositorFilterOperationsForBackdropFilter() const {
+  const auto& style = GetLayoutObject().StyleRef();
+  float zoom = style.EffectiveZoom();
+  FloatRect reference_box = FilterReferenceBox(style.BackdropFilter(), zoom);
+  return FilterEffectBuilder(EnclosingNode(), reference_box, zoom)
+      .BuildFilterOperations(style.BackdropFilter());
 }
 
 PaintLayerResourceInfo& PaintLayer::EnsureResourceInfo() {
@@ -3275,14 +3292,12 @@
   if (resource_info->LastEffect())
     return resource_info->LastEffect();
 
-  const ComputedStyle& style = GetLayoutObject().StyleRef();
-  FloatRect zoomed_reference_box;
-  if (style.Filter().HasReferenceFilter())
-    zoomed_reference_box = BoxForFilterOrMask();
-  FilterEffectBuilder builder(EnclosingNode(), zoomed_reference_box,
-                              style.EffectiveZoom());
+  const auto& style = GetLayoutObject().StyleRef();
+  float zoom = style.EffectiveZoom();
+  FilterEffectBuilder builder(EnclosingNode(),
+                              FilterReferenceBox(style.Filter(), zoom), zoom);
   resource_info->SetLastEffect(
-      builder.BuildFilterEffect(AddReflectionToFilterOperations(style)));
+      builder.BuildFilterEffect(FilterOperationsIncludingReflection()));
   return resource_info->LastEffect();
 }
 
@@ -3294,9 +3309,7 @@
   // TODO(fs): Avoid having this side-effect inducing call.
   LastFilterEffect();
 
-  FilterOperations filter_operations =
-      AddReflectionToFilterOperations(GetLayoutObject().StyleRef());
-  return filter_operations.MapRect(rect);
+  return FilterOperationsIncludingReflection().MapRect(rect);
 }
 
 LayoutRect PaintLayer::MapLayoutRectForFilter(const LayoutRect& rect) const {
diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.h b/third_party/WebKit/Source/core/paint/PaintLayer.h
index 3782fec..b65e0f3 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayer.h
+++ b/third_party/WebKit/Source/core/paint/PaintLayer.h
@@ -444,8 +444,6 @@
       CalculateBoundsOptions = kMaybeIncludeTransformForAncestorLayer) const;
   LayoutRect FragmentsBoundingBox(const PaintLayer* ancestor_layer) const;
 
-  FloatRect BoxForFilterOrMask() const;
-
   LayoutRect BoundingBoxForCompositingOverlapTest() const;
   LayoutRect BoundingBoxForCompositing() const;
 
@@ -618,10 +616,17 @@
     contains_dirty_overlay_scrollbars_ = dirty_scrollbars;
   }
 
-  CompositorFilterOperations CreateCompositorFilterOperationsForFilter(
-      const ComputedStyle&);
-  CompositorFilterOperations CreateCompositorFilterOperationsForBackdropFilter(
-      const ComputedStyle&);
+  // If the input CompositorFilterOperation is not empty, it will be populated
+  // only if |filter_on_effect_node_dirty_| is true or the reference box has
+  // changed. Otherwise it will be populated unconditionally.
+  void UpdateCompositorFilterOperationsForFilter(
+      CompositorFilterOperations&) const;
+  void SetFilterOnEffectNodeDirty() { filter_on_effect_node_dirty_ = true; }
+  void ClearFilterOnEffectNodeDirty() { filter_on_effect_node_dirty_ = false; }
+
+  CompositorFilterOperations CreateCompositorFilterOperationsForBackdropFilter()
+      const;
+
   bool PaintsWithFilters() const;
   bool PaintsWithBackdropFilters() const;
   FilterEffect* LastFilterEffect() const;
@@ -1144,7 +1149,7 @@
   bool RequiresStackingNode() const { return true; }
   void UpdateStackingNode();
 
-  FilterOperations AddReflectionToFilterOperations(const ComputedStyle&) const;
+  FilterOperations FilterOperationsIncludingReflection() const;
 
   bool RequiresScrollableArea() const;
   void UpdateScrollableArea();
@@ -1189,6 +1194,8 @@
       const PaintLayer* stacking_parent,
       CalculateBoundsOptions) const;
 
+  FloatRect FilterReferenceBox(const FilterOperations&, float zoom) const;
+
   // Self-painting layer is an optimization where we avoid the heavy Layer
   // painting machinery for a Layer allocated only to handle the overflow clip
   // case.
@@ -1259,6 +1266,11 @@
 
   unsigned self_painting_status_changed_ : 1;
 
+  // It's set to true when filter style or filter resource changes, indicating
+  // that we need to update the filter field of the effect paint property node.
+  // It's cleared when the effect paint property node is updated.
+  unsigned filter_on_effect_node_dirty_ : 1;
+
   LayoutBoxModelObject& layout_object_;
 
   PaintLayer* parent_;
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerResourceInfo.cpp b/third_party/WebKit/Source/core/paint/PaintLayerResourceInfo.cpp
index f8c1fb6..ba886cec 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerResourceInfo.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerResourceInfo.cpp
@@ -54,6 +54,7 @@
   // The effect paint property nodes depend on SVG filters so we need
   // to update these properties when filter resources change.
   layout_object.SetNeedsPaintPropertyUpdate();
+  layer_->SetFilterOnEffectNodeDirty();
   const ComputedStyle& style = layout_object.StyleRef();
   if (style.HasFilter() && style.Filter().HasReferenceFilter())
     InvalidateFilterChain();
@@ -66,6 +67,7 @@
   // The effect paint property nodes depend on SVG filters so we need
   // to update these properties when filter resources change.
   layout_object.SetNeedsPaintPropertyUpdate();
+  layer_->SetFilterOnEffectNodeDirty();
   const ComputedStyle& style = layout_object.StyleRef();
   if (style.HasFilter() && style.Filter().HasReferenceFilter())
     InvalidateFilterChain();
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
index f22d717..09b2b68 100644
--- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
@@ -764,10 +764,13 @@
   if (object_.NeedsPaintPropertyUpdate() ||
       full_context_.force_subtree_update) {
     if (NeedsFilter(object_)) {
-      CompositorFilterOperations filter =
-          ToLayoutBoxModelObject(object_)
-              .Layer()
-              ->CreateCompositorFilterOperationsForFilter(style);
+      CompositorFilterOperations filter;
+      // Try to use the cached filter.
+      if (properties_->Filter())
+        filter = properties_->Filter()->Filter();
+      auto& layer = *ToLayoutBoxModelObject(object_).Layer();
+      layer.UpdateCompositorFilterOperationsForFilter(filter);
+      layer.ClearFilterOnEffectNodeDirty();
 
       // The CSS filter spec didn't specify how filters interact with overflow
       // clips. The implementation here mimics the old Blink/WebKit behavior for
diff --git a/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMapping.cpp
index f64a0083..9c74bfd 100644
--- a/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMapping.cpp
+++ b/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMapping.cpp
@@ -268,8 +268,8 @@
   UpdateHitTestableWithoutDrawsContent(true);
   UpdateOpacity(GetLayoutObject().StyleRef());
   UpdateTransform(GetLayoutObject().StyleRef());
-  UpdateFilters(GetLayoutObject().StyleRef());
-  UpdateBackdropFilters(GetLayoutObject().StyleRef());
+  UpdateFilters();
+  UpdateBackdropFilters();
   UpdateLayerBlendMode(GetLayoutObject().StyleRef());
   UpdateIsRootForIsolatedGroup();
 }
@@ -317,14 +317,15 @@
   graphics_layer_->SetTransform(t);
 }
 
-void CompositedLayerMapping::UpdateFilters(const ComputedStyle& style) {
-  graphics_layer_->SetFilters(
-      OwningLayer().CreateCompositorFilterOperationsForFilter(style));
+void CompositedLayerMapping::UpdateFilters() {
+  CompositorFilterOperations operations;
+  OwningLayer().UpdateCompositorFilterOperationsForFilter(operations);
+  graphics_layer_->SetFilters(std::move(operations));
 }
 
-void CompositedLayerMapping::UpdateBackdropFilters(const ComputedStyle& style) {
+void CompositedLayerMapping::UpdateBackdropFilters() {
   graphics_layer_->SetBackdropFilters(
-      OwningLayer().CreateCompositorFilterOperationsForBackdropFilter(style));
+      OwningLayer().CreateCompositorFilterOperationsForBackdropFilter());
 }
 
 void CompositedLayerMapping::UpdateStickyConstraints(
@@ -1135,12 +1136,12 @@
     UpdateOpacity(GetLayoutObject().StyleRef());
 
   if (!GetLayoutObject().Style()->IsRunningFilterAnimationOnCompositor())
-    UpdateFilters(GetLayoutObject().StyleRef());
+    UpdateFilters();
 
   if (!GetLayoutObject()
            .Style()
            ->IsRunningBackdropFilterAnimationOnCompositor())
-    UpdateBackdropFilters(GetLayoutObject().StyleRef());
+    UpdateBackdropFilters();
 
   // We compute everything relative to the enclosing compositing layer.
   IntRect ancestor_compositing_bounds;
diff --git a/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMapping.h b/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMapping.h
index 35a68bf..7ee70d9 100644
--- a/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMapping.h
+++ b/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMapping.h
@@ -251,8 +251,8 @@
   // position.
   GraphicsLayer* DetachLayerForOverflowControls();
 
-  void UpdateFilters(const ComputedStyle&);
-  void UpdateBackdropFilters(const ComputedStyle&);
+  void UpdateFilters();
+  void UpdateBackdropFilters();
 
   void SetBlendMode(WebBlendMode);
 
diff --git a/third_party/WebKit/Source/devtools/front_end/object_ui/ObjectPropertiesSection.js b/third_party/WebKit/Source/devtools/front_end/object_ui/ObjectPropertiesSection.js
index f4d4641..3cb5a90 100644
--- a/third_party/WebKit/Source/devtools/front_end/object_ui/ObjectPropertiesSection.js
+++ b/third_party/WebKit/Source/devtools/front_end/object_ui/ObjectPropertiesSection.js
@@ -895,6 +895,21 @@
   async _applyExpression(expression) {
     var property = SDK.RemoteObject.toCallArgument(this.property.symbol || this.property.name);
     expression = SDK.RuntimeModel.wrapObjectLiteralExpressionIfNeeded(expression.trim());
+
+    if (this.property.synthetic) {
+      var invalidate = false;
+      if (expression)
+        invalidate = await this.property.setSyntheticValue(expression);
+      if (invalidate) {
+        var parent = this.parent;
+        parent.invalidateChildren();
+        parent.onpopulate();
+      } else {
+        this.update();
+      }
+      return;
+    }
+
     var errorPromise = expression ? this.property.parentObject.setPropertyValue(property, expression) :
                                     this.property.parentObject.deleteProperty(property);
     var error = await errorPromise;
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js
index 1604dee10..05f473a20 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js
@@ -1188,6 +1188,8 @@
     }
     if (payload.functionLocation)
       this._functionLocation = SDK.DebuggerModel.Location.fromPayload(debuggerModel, payload.functionLocation);
+    this._returnValue =
+        payload.returnValue ? this.debuggerModel._runtimeModel.createRemoteObject(payload.returnValue) : null;
   }
 
   /**
@@ -1245,8 +1247,26 @@
    * @return {?SDK.RemoteObject}
    */
   returnValue() {
-    return this._payload.returnValue ? this.debuggerModel._runtimeModel.createRemoteObject(this._payload.returnValue) :
-                                       null;
+    return this._returnValue;
+  }
+
+  /**
+   * @param {string} expression
+   * @return {!Promise<?SDK.RemoteObject>}
+   */
+  async setReturnValue(expression) {
+    if (!this._returnValue)
+      return null;
+
+    var evaluateResponse = await this.debuggerModel._agent.invoke_evaluateOnCallFrame(
+        {callFrameId: this.id, expression: expression, silent: true, objectGroup: 'backtrace'});
+    if (evaluateResponse[Protocol.Error] || evaluateResponse.exceptionDetails)
+      return null;
+    var response = await this.debuggerModel._agent.invoke_setReturnValue({newValue: evaluateResponse.result});
+    if (response[Protocol.Error])
+      return null;
+    this._returnValue = this.debuggerModel._runtimeModel.createRemoteObject(evaluateResponse.result);
+    return this._returnValue;
   }
 
   /**
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js b/third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js
index 88a36dc..6080f78 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js
@@ -888,20 +888,37 @@
    * @param {boolean=} writable
    * @param {boolean=} isOwn
    * @param {boolean=} wasThrown
-   * @param {boolean=} synthetic
    * @param {?SDK.RemoteObject=} symbol
+   * @param {boolean=} synthetic
+   * @param {function(string):!Promise<?SDK.RemoteObject>=} syntheticSetter
    */
-  constructor(name, value, enumerable, writable, isOwn, wasThrown, symbol, synthetic) {
+  constructor(name, value, enumerable, writable, isOwn, wasThrown, symbol, synthetic, syntheticSetter) {
     this.name = name;
     if (value !== null)
       this.value = value;
     this.enumerable = typeof enumerable !== 'undefined' ? enumerable : true;
-    this.writable = typeof writable !== 'undefined' ? writable : true;
+    var isNonSyntheticOrSyntheticWritable = !synthetic || !!syntheticSetter;
+    this.writable = typeof writable !== 'undefined' ? writable : isNonSyntheticOrSyntheticWritable;
     this.isOwn = !!isOwn;
     this.wasThrown = !!wasThrown;
     if (symbol)
       this.symbol = symbol;
     this.synthetic = !!synthetic;
+    if (syntheticSetter)
+      this.syntheticSetter = syntheticSetter;
+  }
+
+  /**
+   * @param {string} expression
+   * @return {!Promise<boolean>}
+   */
+  async setSyntheticValue(expression) {
+    if (!this.syntheticSetter)
+      return false;
+    var result = await this.syntheticSetter(expression);
+    if (result)
+      this.value = result;
+    return !!result;
   }
 
   /**
diff --git a/third_party/WebKit/Source/devtools/front_end/sources/ScopeChainSidebarPane.js b/third_party/WebKit/Source/devtools/front_end/sources/ScopeChainSidebarPane.js
index bb46298..6e5be1f 100644
--- a/third_party/WebKit/Source/devtools/front_end/sources/ScopeChainSidebarPane.js
+++ b/third_party/WebKit/Source/devtools/front_end/sources/ScopeChainSidebarPane.js
@@ -92,7 +92,7 @@
             if (returnValue) {
               extraProperties.push(new SDK.RemoteObjectProperty(
                   Common.UIString('Return value'), returnValue, undefined, undefined, undefined, undefined, undefined,
-                  true));
+                  true, callFrame.setReturnValue.bind(callFrame)));
             }
           }
           break;
diff --git a/third_party/WebKit/Source/platform/graphics/CompositorFilterOperations.cpp b/third_party/WebKit/Source/platform/graphics/CompositorFilterOperations.cpp
index fb629ddc..e2d46255 100644
--- a/third_party/WebKit/Source/platform/graphics/CompositorFilterOperations.cpp
+++ b/third_party/WebKit/Source/platform/graphics/CompositorFilterOperations.cpp
@@ -5,6 +5,7 @@
 #include "platform/graphics/CompositorFilterOperations.h"
 
 #include "platform/geometry/IntRect.h"
+#include "platform/runtime_enabled_features.h"
 #include "third_party/skia/include/core/SkImageFilter.h"
 #include "ui/gfx/geometry/rect.h"
 
@@ -108,13 +109,15 @@
 
 bool CompositorFilterOperations::operator==(
     const CompositorFilterOperations& o) const {
-  return filter_operations_ == o.filter_operations_;
+  return reference_box_ == o.reference_box_ &&
+         filter_operations_ == o.filter_operations_;
 }
 
 bool CompositorFilterOperations::EqualsIgnoringReferenceFilters(
     const CompositorFilterOperations& o) const {
+  DCHECK(!RuntimeEnabledFeatures::SlimmingPaintV175Enabled());
   size_t size = filter_operations_.size();
-  if (size != o.filter_operations_.size())
+  if (size != o.filter_operations_.size() || reference_box_ != o.reference_box_)
     return false;
   for (size_t i = 0; i < size; ++i) {
     const auto& operation = filter_operations_.at(i);
diff --git a/third_party/WebKit/Source/platform/graphics/CompositorFilterOperations.h b/third_party/WebKit/Source/platform/graphics/CompositorFilterOperations.h
index ab6a17b..415db6f3 100644
--- a/third_party/WebKit/Source/platform/graphics/CompositorFilterOperations.h
+++ b/third_party/WebKit/Source/platform/graphics/CompositorFilterOperations.h
@@ -47,6 +47,9 @@
 
   bool HasFilterThatMovesPixels() const;
 
+  void SetReferenceBox(const FloatRect& r) { reference_box_ = r; }
+  FloatRect ReferenceBox() const { return reference_box_; }
+
   // For reference filters, this equality operator compares pointers of the
   // image_filter fields instead of their values.
   bool operator==(const CompositorFilterOperations&) const;
@@ -60,6 +63,7 @@
 
  private:
   cc::FilterOperations filter_operations_;
+  FloatRect reference_box_;
 };
 
 }  // namespace blink
diff --git a/third_party/WebKit/Source/platform/graphics/paint/EffectPaintPropertyNode.h b/third_party/WebKit/Source/platform/graphics/paint/EffectPaintPropertyNode.h
index f296881..596271f 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/EffectPaintPropertyNode.h
+++ b/third_party/WebKit/Source/platform/graphics/paint/EffectPaintPropertyNode.h
@@ -119,8 +119,8 @@
     return Parent() == o.Parent() &&
            local_transform_space_ == o.local_transform_space_ &&
            output_clip_ == o.output_clip_ && color_filter_ == o.color_filter_ &&
-           filter_.EqualsIgnoringReferenceFilters(o.filter_) &&
-           opacity_ == o.opacity_ && blend_mode_ == o.blend_mode_ &&
+           filter_ == o.filter_ && opacity_ == o.opacity_ &&
+           blend_mode_ == o.blend_mode_ &&
            direct_compositing_reasons_ == o.direct_compositing_reasons_ &&
            compositor_element_id_ == o.compositor_element_id_ &&
            paint_offset_ == o.paint_offset_;