From 328cf2ed1fa50072894a62dc23db48a9534b44e3 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 | 34 ---------------------- 6 files changed, 27 insertions(+), 41 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 a73698e95..a42d412c8 100644 --- a/libcef/browser/content_browser_client.cc +++ b/libcef/browser/content_browser_client.cc @@ -698,6 +698,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 898696537..d5e2d3da9 100644 --- a/libcef/common/cef_switches.cc +++ b/libcef/common/cef_switches.cc @@ -94,4 +94,7 @@ const char kEnableSpellingService[] = "enable-spelling-service"; // Override the default spellchecking language which comes from locales.pak. const char kOverrideSpellCheckLang[] = "override-spell-check-lang"; +// 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 ddd96bde3..3bccb6af9 100644 --- a/libcef/common/cef_switches.h +++ b/libcef/common/cef_switches.h @@ -41,6 +41,7 @@ extern const char kCrashDumpsDir[]; extern const char kDisableSpellChecking[]; extern const char kEnableSpellingService[]; extern const char kOverrideSpellCheckLang[]; +extern const char kDisableScrollBounce[]; } // namespace switches diff --git a/libcef/renderer/content_renderer_client.cc b/libcef/renderer/content_renderer_client.cc index d9894008d..5b70c0081 100644 --- a/libcef/renderer/content_renderer_client.cc +++ b/libcef/renderer/content_renderer_client.cc @@ -73,6 +73,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 + #if defined(OS_WIN) #include "base/win/iat_patch_function.h" #endif @@ -500,6 +505,23 @@ void CefContentRendererClient::RenderThreadStarted() { pdf_print_client_.reset(new ChromePDFPrintClient()); pdf::PPB_PDF_Impl::SetPrintClient(pdf_print_client_.get()); +#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 32f4baf43..c4df663d2 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -132,11 +132,4 @@ patches = [ 'name': 'webkit_progresstracker_426510', 'path': '../third_party/WebKit/Source/core/loader/', }, - { - # 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 8b788bb4b..000000000 --- a/patch/patches/spi_webcore_364.patch +++ /dev/null @@ -1,34 +0,0 @@ -diff --git core/frame/FrameView.cpp core/frame/FrameView.cpp -index b227b2a..3bc4180 100644 ---- core/frame/FrameView.cpp -+++ core/frame/FrameView.cpp -@@ -144,8 +144,10 @@ FrameView::FrameView(LocalFrame* frame) - if (!m_frame->isMainFrame()) - return; - -+#if 0 - ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed); - ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed); -+#endif - } - - PassRefPtrWillBeRawPtr FrameView::create(LocalFrame* frame) -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