Add scrollBounce option and disable it by default

This commit is contained in:
Cheng Zhao 2016-05-06 14:57:43 +09:00
Родитель 4ce26dfa68
Коммит df397dab30
5 изменённых файлов: 35 добавлений и 0 удалений

Просмотреть файл

@ -141,6 +141,14 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
command_line->AppendSwitchASCII(switches::kOpenerID,
base::IntToString(opener_id));
#if defined(OS_MACOSX)
// Enable scroll bounce.
bool scroll_bounce;
if (web_preferences.GetBoolean(options::kScrollBounce, &scroll_bounce) &&
scroll_bounce)
command_line->AppendSwitch(switches::kScrollBounce);
#endif
// Enable blink features.
std::string blink_features;
if (web_preferences.GetString(options::kBlinkFeatures, &blink_features))

Просмотреть файл

@ -103,6 +103,9 @@ const char kExperimentalCanvasFeatures[] = "experimentalCanvasFeatures";
// Opener window's ID.
const char kOpenerID[] = "openerId";
// Enable the rubber banding effect.
const char kScrollBounce[] = "scrollBounce";
// Enable blink features.
const char kBlinkFeatures[] = "blinkFeatures";
@ -146,6 +149,7 @@ const char kPreloadURL[] = "preload-url";
const char kNodeIntegration[] = "node-integration";
const char kGuestInstanceID[] = "guest-instance-id";
const char kOpenerID[] = "opener-id";
const char kScrollBounce[] = "scroll-bounce";
// Widevine options
// Path to Widevine CDM binaries.

Просмотреть файл

@ -56,6 +56,7 @@ extern const char kGuestInstanceID[];
extern const char kExperimentalFeatures[];
extern const char kExperimentalCanvasFeatures[];
extern const char kOpenerID[];
extern const char kScrollBounce[];
extern const char kBlinkFeatures[];
} // namespace options
@ -82,6 +83,7 @@ extern const char kPreloadURL[];
extern const char kNodeIntegration[];
extern const char kGuestInstanceID[];
extern const char kOpenerID[];
extern const char kScrollBounce[];
extern const char kWidevineCdmPath[];
extern const char kWidevineCdmVersion[];

Просмотреть файл

@ -36,6 +36,11 @@
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
#include "third_party/WebKit/public/web/WebView.h"
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
#include "base/strings/sys_string_conversions.h"
#endif
#if defined(OS_WIN)
#include <shlobj.h>
#endif
@ -97,6 +102,7 @@ void AtomRendererClient::RenderThreadStarted() {
content::RenderThread::Get()->AddObserver(this);
#if defined(OS_WIN)
// Set ApplicationUserModelID in renderer process.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
base::string16 app_id =
command_line->GetSwitchValueNative(switches::kAppUserModelId);
@ -104,6 +110,19 @@ void AtomRendererClient::RenderThreadStarted() {
SetCurrentProcessExplicitAppUserModelID(app_id.c_str());
}
#endif
#if defined(OS_MACOSX)
// Disable rubber banding by default.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kScrollBounce)) {
base::ScopedCFTypeRef<CFStringRef> key(
base::SysUTF8ToCFStringRef("NSScrollViewRubberbanding"));
base::ScopedCFTypeRef<CFStringRef> value(
base::SysUTF8ToCFStringRef("false"));
CFPreferencesSetAppValue(key, value, kCFPreferencesCurrentApplication);
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
}
#endif
}
void AtomRendererClient::RenderFrameCreated(

Просмотреть файл

@ -170,6 +170,8 @@ The `webPreferences` option is an object that can have following properties:
canvas features. Default is `false`.
* `directWrite` Boolean - Enables DirectWrite font rendering system on
Windows. Default is `true`.
* `scrollBounce` Boolean - Enables scroll bounce (rubber banding) effect on
OS X. Default is `false`.
* `blinkFeatures` String - A list of feature strings separated by `,`, like
`CSSVariables,KeyboardEventKey`. The full list of supported feature strings
can be found in the [setFeatureEnabledFromString][blink-feature-string]