diff options
author | fsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-22 23:08:05 +0000 |
---|---|---|
committer | fsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-22 23:08:05 +0000 |
commit | 7ddea98038d04e31da38f5420ddb1b56ebcfb93e (patch) | |
tree | b5ca4553ac2cefeaf1cb843ded35c492b0cbd956 | |
parent | e58c1b8db87ac5536ed93daa49513bad4b35f99e (diff) | |
download | chromium_src-7ddea98038d04e31da38f5420ddb1b56ebcfb93e.zip chromium_src-7ddea98038d04e31da38f5420ddb1b56ebcfb93e.tar.gz chromium_src-7ddea98038d04e31da38f5420ddb1b56ebcfb93e.tar.bz2 |
Compute pageScaleFactor on page so that fixed layout page fits width of window.
Fixed layout mode can now be enabled with the command line
flag --enable-fixed-layout.
This mode does not interact well with zoom at this point in time. This will be fixed shortly.
This bug replaces http://codereview.chromium.org/7764006/ which is no longer relevant.
BUG=none
TEST=manually
Review URL: http://codereview.chromium.org/7831028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123126 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | build/common.gypi | 9 | ||||
-rw-r--r-- | content/browser/renderer_host/render_process_host_impl.cc | 2 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_aura.cc | 2 | ||||
-rw-r--r-- | content/public/common/content_switches.cc | 8 | ||||
-rw-r--r-- | content/public/common/content_switches.h | 2 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 14 | ||||
-rw-r--r-- | content/renderer/render_view_impl.h | 2 |
7 files changed, 39 insertions, 0 deletions
diff --git a/build/common.gypi b/build/common.gypi index 056d797..fa82663 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -42,6 +42,9 @@ # Disable Virtual keyboard support by default. 'use_virtual_keyboard%': 0, + # Disable viewport meta tag by default. + 'enable_viewport%': 0, + # Default setting for use_skia on mac platform. # This is typically overridden in use_skia_on_mac.gypi. 'use_skia_on_mac%': 0, @@ -53,6 +56,7 @@ 'use_ash%': '<(use_ash)', 'use_openssl%': '<(use_openssl)', 'use_virtual_keyboard%': '<(use_virtual_keyboard)', + 'enable_viewport%': '<(enable_viewport)', 'use_skia_on_mac%': '<(use_skia_on_mac)', # Compute the architecture that we're building on. @@ -95,6 +99,7 @@ 'use_ash%': '<(use_ash)', 'use_openssl%': '<(use_openssl)', 'use_virtual_keyboard%': '<(use_virtual_keyboard)', + 'enable_viewport%': '<(enable_viewport)', 'use_skia_on_mac%': '<(use_skia_on_mac)', # We used to provide a variable for changing how libraries were built. @@ -426,6 +431,7 @@ 'chromeos%': '<(chromeos)', 'chromeos_gtk%': '<(chromeos_gtk)', 'use_virtual_keyboard%': '<(use_virtual_keyboard)', + 'enable_viewport%': '<(enable_viewport)', 'use_skia_on_mac%': '<(use_skia_on_mac)', 'use_xi2_mt%':'<(use_xi2_mt)', 'file_manager_extension%': '<(file_manager_extension)', @@ -1110,6 +1116,9 @@ ['enable_pepper_threading==1', { 'defines': ['ENABLE_PEPPER_THREADING'], }], + ['enable_viewport==1', { + 'defines': ['ENABLE_VIEWPORT'], + }], ['configuration_policy==1', { 'defines': ['ENABLE_CONFIGURATION_POLICY'], }], diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index ccd1ece..34901fe 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -637,6 +637,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( switches::kAuditAllHandles, switches::kAuditHandles, switches::kChromeFrame, + switches::kDefaultDeviceScaleFactor, switches::kDisable3DAPIs, switches::kDisableAcceleratedCompositing, switches::kDisableApplicationCache, @@ -667,6 +668,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( switches::kDomAutomationController, switches::kEnableAccessibilityLogging, switches::kEnableDCHECK, + switches::kEnableFixedLayout, switches::kEnableGamepad, switches::kEnableGPUServiceLogging, switches::kEnableGPUClientLogging, diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 8ff2a0b..4d55177 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -1096,4 +1096,6 @@ void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( // TODO(derat): Don't hardcode this? results->depth = 24; results->depthPerComponent = 8; + results->verticalDPI = 96; + results->horizontalDPI = 96; } diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index 7c7849b..51879ef 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -36,6 +36,10 @@ const char kBrowserSubprocessPath[] = "browser-subprocess-path"; // as a dependent process of the Chrome Frame plugin. const char kChromeFrame[] = "chrome-frame"; +// The default device scale factor to apply to contents in the absence of +// a viewport meta tag. +const char kDefaultDeviceScaleFactor[] = "default-device-scale-factor"; + // Disables client-visible 3D APIs, in particular WebGL and Pepper 3D. // This is controlled by policy and is kept separate from the other // enable/disable switches to avoid accidentally regressing the policy @@ -235,6 +239,10 @@ const char kEnableDeviceMotion[] = "enable-device-motion"; // Enables the fastback page cache. const char kEnableFastback[] = "enable-fastback"; +// By default, a page is laid out to fill the entire width of the window. +// This flag fixes the layout of the page to a default of 980 CSS pixels. +const char kEnableFixedLayout[] = "enable-fixed-layout"; + // Enable the JavaScript Full Screen API. const char kDisableFullScreen[] = "disable-fullscreen"; diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index 5b4a624..106a716 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -23,6 +23,7 @@ CONTENT_EXPORT extern const char kBrowserCrashTest[]; CONTENT_EXPORT extern const char kBrowserSubprocessPath[]; // TODO(jam): this doesn't belong in content. CONTENT_EXPORT extern const char kChromeFrame[]; +CONTENT_EXPORT extern const char kDefaultDeviceScaleFactor[]; CONTENT_EXPORT extern const char kDisable3DAPIs[]; CONTENT_EXPORT extern const char kDisableAccelerated2dCanvas[]; CONTENT_EXPORT extern const char kDisableAcceleratedCompositing[]; @@ -82,6 +83,7 @@ CONTENT_EXPORT extern const char kEnableDeferred2dCanvas[]; extern const char kEnableCompositeToTexture[]; CONTENT_EXPORT extern const char kEnableDeviceMotion[]; extern const char kEnableFastback[]; +CONTENT_EXPORT extern const char kEnableFixedLayout[]; CONTENT_EXPORT extern const char kDisableFullScreen[]; extern const char kEnablePointerLock[]; extern const char kEnableGamepad[]; diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 5c73dfc..74af1c5 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -20,6 +20,7 @@ #include "base/path_service.h" #include "base/process_util.h" #include "base/string_piece.h" +#include "base/string_number_conversions.h" #include "base/string_split.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" @@ -527,6 +528,15 @@ RenderViewImpl::RenderViewImpl( if (command_line.HasSwitch(switches::kDomAutomationController)) enabled_bindings_ |= content::BINDINGS_POLICY_DOM_AUTOMATION; + bool enable_fixed_layout = + command_line.HasSwitch(switches::kEnableFixedLayout); + webview()->enableFixedLayoutMode(enable_fixed_layout); + if (enable_fixed_layout) + webview()->settings()->setFixedElementsLayoutRelativeToFrame(true); + base::StringToInt(command_line.GetSwitchValueASCII( + switches::kDefaultDeviceScaleFactor), + &default_device_scale_factor_); + content::GetContentClient()->renderer()->RenderViewCreated(this); } @@ -4382,6 +4392,10 @@ void RenderViewImpl::OnResize(const gfx::Size& new_size, const gfx::Rect& resizer_rect, bool is_fullscreen) { if (webview()) { + // This setting has no effect if fixed layout is not enabled. + if (default_device_scale_factor_) + webview()->settings()->setLayoutFallbackWidth( + new_size.width() / default_device_scale_factor_); webview()->hidePopups(); if (send_preferred_size_changes_) { webview()->mainFrame()->setCanHaveScrollbars( diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index 4e98228..c79204c 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -1015,6 +1015,8 @@ class RenderViewImpl : public RenderWidget, // should be drawn. gfx::Size disable_scrollbars_size_limit_; + int default_device_scale_factor_; + // Loading state ------------------------------------------------------------- // True if the top level frame is currently being loaded. |