diff options
author | bokan@chromium.org <bokan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-12 20:15:28 +0000 |
---|---|---|
committer | bokan@chromium.org <bokan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-12 20:15:28 +0000 |
commit | a41f8f60ba86a09490de53a738f2adee9a618ccb (patch) | |
tree | 183429c3329a85e9af57e94c34a50e7e1f1cff1e | |
parent | ce1b85f611d42dd91eab1db7d4e73df7d1a7b51a (diff) | |
download | chromium_src-a41f8f60ba86a09490de53a738f2adee9a618ccb.zip chromium_src-a41f8f60ba86a09490de53a738f2adee9a618ccb.tar.gz chromium_src-a41f8f60ba86a09490de53a738f2adee9a618ccb.tar.bz2 |
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
-rw-r--r-- | chrome/browser/chromeos/login/chrome_restart_request.cc | 2 | ||||
-rw-r--r-- | content/browser/android/content_startup_flags.cc | 3 | ||||
-rw-r--r-- | content/browser/renderer_host/render_process_host_impl.cc | 2 | ||||
-rw-r--r-- | content/browser/renderer_host/render_view_host_impl.cc | 10 | ||||
-rw-r--r-- | content/public/common/common_param_traits_macros.h | 2 | ||||
-rw-r--r-- | content/public/common/content_switches.cc | 11 | ||||
-rw-r--r-- | content/public/common/content_switches.h | 2 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 3 | ||||
-rw-r--r-- | content/renderer/web_preferences.cc | 3 | ||||
-rw-r--r-- | webkit/common/webpreferences.cc | 2 | ||||
-rw-r--r-- | webkit/common/webpreferences.h | 2 |
11 files changed, 39 insertions, 3 deletions
diff --git a/chrome/browser/chromeos/login/chrome_restart_request.cc b/chrome/browser/chromeos/login/chrome_restart_request.cc index 5ac0fee..2742765 100644 --- a/chrome/browser/chromeos/login/chrome_restart_request.cc +++ b/chrome/browser/chromeos/login/chrome_restart_request.cc @@ -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, diff --git a/content/browser/android/content_startup_flags.cc b/content/browser/android/content_startup_flags.cc index 11c7932..8f7e29c 100644 --- a/content/browser/android/content_startup_flags.cc +++ b/content/browser/android/content_startup_flags.cc @@ -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( diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 9272403..9ab8dbe 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -973,6 +973,8 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( switches::kEnableTouchDragDrop, switches::kEnableTouchEditing, switches::kEnableViewport, + switches::kEnableViewportMeta, + switches::kMainFrameResizesAreOrientationChanges, switches::kEnableVtune, switches::kEnableWebAnimationsCSS, switches::kEnableWebAnimationsSVG, diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index 8d36fd2..65b3823 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc @@ -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) || diff --git a/content/public/common/common_param_traits_macros.h b/content/public/common/common_param_traits_macros.h index 4f09837..8118fd4 100644 --- a/content/public/common/common_param_traits_macros.h +++ b/content/public/common/common_param_traits_macros.h @@ -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) diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index 0959799..14dfc5a 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -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"; diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index 157c737..ab127e7 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -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[]; diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index a67524c..dc32223 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -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. diff --git a/content/renderer/web_preferences.cc b/content/renderer/web_preferences.cc index fd91f8c..9797997 100644 --- a/content/renderer/web_preferences.cc +++ b/content/renderer/web_preferences.cc @@ -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); diff --git a/webkit/common/webpreferences.cc b/webkit/common/webpreferences.cc index 1fa918d..fa94a95 100644 --- a/webkit/common/webpreferences.cc +++ b/webkit/common/webpreferences.cc @@ -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), diff --git a/webkit/common/webpreferences.h b/webkit/common/webpreferences.h index a07b258..a8275ca 100644 --- a/webkit/common/webpreferences.h +++ b/webkit/common/webpreferences.h @@ -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; |