0

Experimental viewport meta tag support for desktop

Added flag to allow desktop builds to experimentally turn
on support for the viewport meta tag. The --enable-viewport
flag now turns on only support for @viewport.
--enable-viewport-meta turns on viewport meta and @viewport
support.

On Android, the viewport gets rescaled when the view is
resized, i.e. phone is rotated between landscape and
portrait. On desktop, enabling the viewport causes the page
to zoom out when the window is shrunk, rather than adding
scrollbars. To support viewport on both devices, I've added
a --main-frame-resizes-are-orientation-changes flag that should be set on
Android and not desktop. This prevents the viewport scaling
code in WebViewImpl::resize().

Enabling viewport on desktop means the page scale can
change. This causes a known issue with scrollbars where
mouse events are scaled with the page, making mouse
interaction with scrollbars broken.

This is the Chromium side of a 2-side patch
(Blink-side at https://codereview.chromium.org/40423003/)

BUG=232102

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234617 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
bokan@chromium.org
2013-11-12 20:15:28 +00:00
parent ce1b85f611
commit a41f8f60ba
11 changed files with 39 additions and 3 deletions

@ -108,6 +108,8 @@ std::string DeriveCommandLine(const GURL& start_url,
::switches::kEnableTouchEditing,
::switches::kEnableUniversalAcceleratedOverflowScroll,
::switches::kEnableViewport,
::switches::kEnableViewportMeta,
::switches::kMainFrameResizesAreOrientationChanges,
::switches::kForceDeviceScaleFactor,
::switches::kGpuStartupDialog,
::switches::kGpuSandboxAllowSysVShm,

@ -73,6 +73,9 @@ void SetContentCommandLineFlags(int max_render_process_count,
parsed_command_line->AppendSwitch(switches::kDisableGpuShaderDiskCache);
parsed_command_line->AppendSwitch(switches::kEnableViewport);
parsed_command_line->AppendSwitch(switches::kEnableViewportMeta);
parsed_command_line->AppendSwitch(
switches::kMainFrameResizesAreOrientationChanges);
// Disable anti-aliasing.
parsed_command_line->AppendSwitch(

@ -973,6 +973,8 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
switches::kEnableTouchDragDrop,
switches::kEnableTouchEditing,
switches::kEnableViewport,
switches::kEnableViewportMeta,
switches::kMainFrameResizesAreOrientationChanges,
switches::kEnableVtune,
switches::kEnableWebAnimationsCSS,
switches::kEnableWebAnimationsSVG,

@ -508,7 +508,15 @@ WebPreferences RenderViewHostImpl::GetWebkitPrefs(const GURL& url) {
prefs.number_of_cpu_cores = base::SysInfo::NumberOfProcessors();
prefs.viewport_enabled = command_line.HasSwitch(switches::kEnableViewport);
prefs.viewport_meta_enabled =
command_line.HasSwitch(switches::kEnableViewportMeta);
prefs.viewport_enabled =
command_line.HasSwitch(switches::kEnableViewport) ||
prefs.viewport_meta_enabled;
prefs.main_frame_resizes_are_orientation_changes =
command_line.HasSwitch(switches::kMainFrameResizesAreOrientationChanges);
prefs.deferred_image_decoding_enabled =
command_line.HasSwitch(switches::kEnableDeferredImageDecoding) ||

@ -166,6 +166,8 @@ IPC_STRUCT_TRAITS_BEGIN(WebPreferences)
IPC_STRUCT_TRAITS_MEMBER(editing_behavior)
IPC_STRUCT_TRAITS_MEMBER(supports_multiple_windows)
IPC_STRUCT_TRAITS_MEMBER(viewport_enabled)
IPC_STRUCT_TRAITS_MEMBER(viewport_meta_enabled)
IPC_STRUCT_TRAITS_MEMBER(main_frame_resizes_are_orientation_changes)
IPC_STRUCT_TRAITS_MEMBER(initialize_at_minimum_page_scale)
IPC_STRUCT_TRAITS_MEMBER(smart_insert_delete_enabled)
IPC_STRUCT_TRAITS_MEMBER(compositor_touch_hit_testing)

@ -556,11 +556,20 @@ const char kEnableUniversalAcceleratedOverflowScroll[] =
const char kEnableUserMediaScreenCapturing[] =
"enable-usermedia-screen-capturing";
// Enables the use of the viewport meta tag, which allows
// Enables the use of the @viewport CSS rule, which allows
// pages to control aspects of their own layout. This also turns on touch-screen
// pinch gestures.
const char kEnableViewport[] = "enable-viewport";
// Enables the use of the legacy viewport meta tag. Turning this on also
// turns on the @viewport CSS rule
const char kEnableViewportMeta[] = "enable-viewport-meta";
// Resizes of the main frame are the caused by changing between landscape
// and portrait mode (i.e. Android) so the page should be rescaled to fit
const char kMainFrameResizesAreOrientationChanges[] =
"main-frame-resizes-are-orientation-changes";
// Enables moving cursor by word in visual order.
const char kEnableVisualWordMovement[] = "enable-visual-word-movement";

@ -168,6 +168,8 @@ CONTENT_EXPORT extern const char kEnableThreadedCompositing[];
CONTENT_EXPORT extern const char kEnableUniversalAcceleratedOverflowScroll[];
extern const char kEnableUserMediaScreenCapturing[];
extern const char kEnableViewport[];
extern const char kEnableViewportMeta[];
extern const char kMainFrameResizesAreOrientationChanges[];
extern const char kEnableVisualWordMovement[];
CONTENT_EXPORT extern const char kEnableVtune[];
extern const char kEnableWebAnimationsCSS[];

@ -3577,7 +3577,8 @@ NavigationState* RenderViewImpl::CreateNavigationStateFromPending() {
void RenderViewImpl::ProcessViewLayoutFlags(const CommandLine& command_line) {
bool enable_viewport =
command_line.HasSwitch(switches::kEnableViewport);
command_line.HasSwitch(switches::kEnableViewport) ||
command_line.HasSwitch(switches::kEnableViewportMeta);
// If viewport tag is enabled, then the WebKit side will take care
// of setting the fixed layout size and page scale limits.

@ -314,6 +314,9 @@ void ApplyWebPreferences(const WebPreferences& prefs, WebView* web_view) {
settings->setViewportEnabled(prefs.viewport_enabled);
settings->setLoadWithOverviewMode(prefs.initialize_at_minimum_page_scale);
settings->setViewportMetaEnabled(prefs.viewport_meta_enabled);
settings->setMainFrameResizesAreOrientationChanges(
prefs.main_frame_resizes_are_orientation_changes);
settings->setSmartInsertDeleteEnabled(prefs.smart_insert_delete_enabled);

@ -107,6 +107,8 @@ WebPreferences::WebPreferences()
#endif
supports_multiple_windows(true),
viewport_enabled(false),
viewport_meta_enabled(false),
main_frame_resizes_are_orientation_changes(false),
initialize_at_minimum_page_scale(true),
#if defined(OS_MACOSX)
smart_insert_delete_enabled(true),

@ -146,6 +146,8 @@ struct WEBKIT_COMMON_EXPORT WebPreferences {
webkit_glue::EditingBehavior editing_behavior;
bool supports_multiple_windows;
bool viewport_enabled;
bool viewport_meta_enabled;
bool main_frame_resizes_are_orientation_changes;
bool initialize_at_minimum_page_scale;
bool smart_insert_delete_enabled;
bool spatial_navigation_enabled;