From 6cceb1bd4173881d867bba11bd982718b189bcd0 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 8 Apr 2015 15:16:17 +0200 Subject: [PATCH] Mac: Add `disable-scroll-bounce` command-line flag (issue #1597). --- libcef/browser/content_browser_client.cc | 1 + libcef/common/cef_switches.cc | 3 +++ libcef/common/cef_switches.h | 1 + libcef/renderer/content_renderer_client.cc | 22 ++++++++++++++++++++++ patch/patch.cfg | 7 ------- patch/patches/spi_webcore_364.patch | 19 ------------------- 6 files changed, 27 insertions(+), 26 deletions(-) delete mode 100644 patch/patches/spi_webcore_364.patch diff --git a/libcef/browser/content_browser_client.cc b/libcef/browser/content_browser_client.cc index ff142a28f..3c29a9287 100644 --- a/libcef/browser/content_browser_client.cc +++ b/libcef/browser/content_browser_client.cc @@ -664,6 +664,7 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches( // any associated values) if present in the browser command line. static const char* const kSwitchNames[] = { switches::kContextSafetyImplementation, + switches::kDisableScrollBounce, switches::kDisableSpellChecking, switches::kEnableSpeechInput, switches::kEnableSpellingAutoCorrect, diff --git a/libcef/common/cef_switches.cc b/libcef/common/cef_switches.cc index fa189d68d..3240e1a5a 100644 --- a/libcef/common/cef_switches.cc +++ b/libcef/common/cef_switches.cc @@ -97,4 +97,7 @@ const char kOverrideSpellCheckLang[] = "override-spell-check-lang"; // Enable detection and use of a system-wide Pepper Flash install. const char kEnableSystemFlash[] = "enable-system-flash"; +// Disable scroll bounce (rubber-banding) on OS X Lion and newer. +const char kDisableScrollBounce[] = "disable-scroll-bounce"; + } // namespace switches diff --git a/libcef/common/cef_switches.h b/libcef/common/cef_switches.h index c5f15b00a..d9e2cc276 100644 --- a/libcef/common/cef_switches.h +++ b/libcef/common/cef_switches.h @@ -42,6 +42,7 @@ extern const char kDisableSpellChecking[]; extern const char kEnableSpellingService[]; extern const char kOverrideSpellCheckLang[]; extern const char kEnableSystemFlash[]; +extern const char kDisableScrollBounce[]; } // namespace switches diff --git a/libcef/renderer/content_renderer_client.cc b/libcef/renderer/content_renderer_client.cc index 92d0d7bb2..8e283756f 100644 --- a/libcef/renderer/content_renderer_client.cc +++ b/libcef/renderer/content_renderer_client.cc @@ -69,6 +69,11 @@ MSVC_POP_WARNING(); #include "third_party/WebKit/public/web/WebView.h" #include "v8/include/v8.h" +#if defined(OS_MACOSX) +#include "base/mac/mac_util.h" +#include "base/strings/sys_string_conversions.h" +#endif + namespace { // Stub implementation of blink::WebPrerenderingSupport. @@ -455,6 +460,23 @@ void CefContentRendererClient::RenderThreadStarted() { // Cross-origin entries need to be added after WebKit is initialized. cross_origin_whitelist_entries_ = params.cross_origin_whitelist_entries; +#if defined(OS_MACOSX) + if (base::mac::IsOSLionOrLater()) { + base::ScopedCFTypeRef key( + base::SysUTF8ToCFStringRef("NSScrollViewRubberbanding")); + base::ScopedCFTypeRef value; + + // If the command-line switch is specified then set the value that will be + // checked in RenderThreadImpl::Init(). Otherwise, remove the application- + // level value. + if (command_line->HasSwitch(switches::kDisableScrollBounce)) + value.reset(base::SysUTF8ToCFStringRef("false")); + + CFPreferencesSetAppValue(key, value, kCFPreferencesCurrentApplication); + CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication); + } +#endif // defined(OS_MACOSX) + // Notify the render process handler. CefRefPtr application = CefContentClient::Get()->application(); if (application.get()) { diff --git a/patch/patch.cfg b/patch/patch.cfg index 9088f42f5..60b07c187 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -149,11 +149,4 @@ patches = [ 'name': 'chrome_pepper_flash_1586', 'path': '../chrome/common/', }, - { - # Disable scollbar bounce and overlay on OS X. - # http://code.google.com/p/chromiumembedded/issues/detail?id=364 - 'name': 'spi_webcore_364', - 'path': '../third_party/WebKit/Source/', - 'condition': 'CEF_SPI_BUILD', - }, ] diff --git a/patch/patches/spi_webcore_364.patch b/patch/patches/spi_webcore_364.patch deleted file mode 100644 index c2f7ea230..000000000 --- a/patch/patches/spi_webcore_364.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff --git platform/scroll/ScrollbarThemeMacCommon.mm platform/scroll/ScrollbarThemeMacCommon.mm -index 90abb7c..6bb16c6 100644 ---- platform/scroll/ScrollbarThemeMacCommon.mm -+++ platform/scroll/ScrollbarThemeMacCommon.mm -@@ -354,10 +354,14 @@ NSScrollerStyle ScrollbarThemeMacCommon::recommendedScrollerStyle() - // static - bool ScrollbarThemeMacCommon::isOverlayAPIAvailable() - { -+#if 0 - static bool apiAvailable = - [NSClassFromString(@"NSScrollerImp") respondsToSelector:@selector(scrollerImpWithStyle:controlSize:horizontal:replacingScrollerImp:)] - && [NSClassFromString(@"NSScrollerImpPair") instancesRespondToSelector:@selector(scrollerStyle)]; - return apiAvailable; -+#else -+ return false; -+#endif - } - - } // namespace blink