diff options
author | bokan <bokan@chromium.org> | 2015-01-15 18:09:20 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-16 02:10:01 +0000 |
commit | 28eb1a5697dbfae079985fbbeb6118245fbd3e01 (patch) | |
tree | c63addd72e4446453e20c1c3e6c3aaa20f040e97 | |
parent | 1db647cca504c5c84c4b3498922363d78a0adace (diff) | |
download | chromium_src-28eb1a5697dbfae079985fbbeb6118245fbd3e01.zip chromium_src-28eb1a5697dbfae079985fbbeb6118245fbd3e01.tar.gz chromium_src-28eb1a5697dbfae079985fbbeb6118245fbd3e01.tar.bz2 |
Refactor of page scale limit initialization. Part 2/5
This patch cleans up how default page scale limits are initialized. This patch
is part 2/5; it adds uses of the new API stubs on the Chromium side but keeps
the old API until the Blink implementation lands. The combined changes can be
seen in https://codereview.chromium.org/843623002/ and
https://codereview.chromium.org/827423006
Page scale limits in Blink are defined inside the PageScaleConstraintsSet
class. This class has three PageScaleConstraints objects:
defaultConstraints
pageDefinedConstraints
userAgentConstraints
Each overriding the constraint above it. Prior to this patch, the default
constraints were statically set so the minimum scale was 0.25 and maximum was
5.0, Android's desired limits. To prevent desktop browsers from scaling below 1,
RenderViewImpl would set the userAgentConstraints to [1,4]. This is fragmented
and problematic if we ever want to allow pages to set constraints on desktop
browsers.
This patch does a number of things:
1) Make the default constraints mutable so they can be made different for
different platforms. Expose a method in WebView to allow the content layer to
modify it. Move the platform-specific default values into WebPreferences in
the content layer and out of Blink. Hook up initialization to set the
defaults when initializing Blink. Both desktop and Android now set the
desired limits to the defaultConstraints. For desktop, this is equivalent to
the existing behavior since the viewport meta tag is disabled,
pageDefinedConstraints will never be set.
2) Rename setPageScaleFactorLimits to setPageScaleFactorLimitsOverride. This
method is ambiguous. Since it sets the userAgentConstraints, adding
"override" makes it clear that these will supersede other constraints. It's
also consistent with setInitialPageScaleOverride which sets the initial scale
on userAgentConstraints. Also removed some related methods from the WebView
interface that are no longer needed.
3) Since a minimum scale is now always available, remove the condition in
PageScaleConstraintsSet::mainFrameSize that sets the frame size to the
content width.
4) Use -1 as the default initial scale on all platforms. Previously, this was
used on Android so that the absence of initial scale would use min-scale and
pages would load fully zoomed out. Since the min-scale on desktop is 1, we
can use -1 as the initial scale as well.
TBR=avi@chromium.org,aelias@chromium.org,kenrb@chromium.org
BUG=413285, 437034
Review URL: https://codereview.chromium.org/848423002
Cr-Commit-Position: refs/heads/master@{#311816}
-rw-r--r-- | content/public/common/common_param_traits_macros.h | 2 | ||||
-rw-r--r-- | content/public/common/web_preferences.cc | 12 | ||||
-rw-r--r-- | content/public/common/web_preferences.h | 6 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 4 | ||||
-rw-r--r-- | content/shell/renderer/layout_test/webkit_test_runner.cc | 1 | ||||
-rw-r--r-- | content/shell/renderer/test_runner/event_sender.cc | 1 |
6 files changed, 23 insertions, 3 deletions
diff --git a/content/public/common/common_param_traits_macros.h b/content/public/common/common_param_traits_macros.h index 3f071ba..12ea351 100644 --- a/content/public/common/common_param_traits_macros.h +++ b/content/public/common/common_param_traits_macros.h @@ -219,6 +219,8 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences) IPC_STRUCT_TRAITS_MEMBER(ignore_main_frame_overflow_hidden_quirk) IPC_STRUCT_TRAITS_MEMBER(report_screen_size_in_physical_pixels_quirk) #endif + IPC_STRUCT_TRAITS_MEMBER(default_minimum_page_scale_factor) + IPC_STRUCT_TRAITS_MEMBER(default_maximum_page_scale_factor) IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(blink::WebWindowFeatures) diff --git a/content/public/common/web_preferences.cc b/content/public/common/web_preferences.cc index 5a76b1a..7327fea 100644 --- a/content/public/common/web_preferences.cc +++ b/content/public/common/web_preferences.cc @@ -185,9 +185,8 @@ WebPreferences::WebPreferences() v8_script_streaming_mode(V8_SCRIPT_STREAMING_MODE_ALL), slimming_paint_enabled(false), cookie_enabled(true), - pepper_accelerated_video_decode_enabled(false) + pepper_accelerated_video_decode_enabled(false), #if defined(OS_ANDROID) - , text_autosizing_enabled(true), font_scale_factor(1.0f), device_scale_adjustment(1.0f), @@ -206,7 +205,14 @@ WebPreferences::WebPreferences() viewport_meta_zero_values_quirk(false), clobber_user_agent_initial_scale_quirk(false), ignore_main_frame_overflow_hidden_quirk(false), - report_screen_size_in_physical_pixels_quirk(false) + report_screen_size_in_physical_pixels_quirk(false), +#endif +#if defined(OS_ANDROID) + default_minimum_page_scale_factor(0.25f), + default_maximum_page_scale_factor(5.f) +#else + default_minimum_page_scale_factor(1.f), + default_maximum_page_scale_factor(4.f) #endif { standard_font_family_map[kCommonScript] = diff --git a/content/public/common/web_preferences.h b/content/public/common/web_preferences.h index 9582a0b..5b9474a 100644 --- a/content/public/common/web_preferences.h +++ b/content/public/common/web_preferences.h @@ -212,6 +212,12 @@ struct CONTENT_EXPORT WebPreferences { bool report_screen_size_in_physical_pixels_quirk; #endif + // Default (used if the page or UA doesn't override these) values for page + // scale limits. These are set directly on the WebView so there's no analogue + // in WebSettings. + float default_minimum_page_scale_factor; + float default_maximum_page_scale_factor; + // We try to keep the default values the same as the default values in // chrome, except for the cases where it would require lots of extra work for // the embedder to use the same default value. diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 59b6a58..e9787cb 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -1134,6 +1134,10 @@ void RenderView::ApplyWebPreferences(const WebPreferences& prefs, #if defined(OS_WIN) settings->setShowContextMenuOnMouseUp(true); #endif + + web_view->setDefaultPageScaleLimits( + prefs.default_minimum_page_scale_factor, + prefs.default_maximum_page_scale_factor); } /*static*/ diff --git a/content/shell/renderer/layout_test/webkit_test_runner.cc b/content/shell/renderer/layout_test/webkit_test_runner.cc index cb9530b..c6eb176 100644 --- a/content/shell/renderer/layout_test/webkit_test_runner.cc +++ b/content/shell/renderer/layout_test/webkit_test_runner.cc @@ -656,6 +656,7 @@ void WebKitTestRunner::Reset() { render_view()->GetWebView()->mainFrame()->setName(WebString()); render_view()->GetWebView()->mainFrame()->clearOpener(); render_view()->GetWebView()->setPageScaleFactorLimits(1, 4); + render_view()->GetWebView()->setDefaultPageScaleLimits(1, 4); render_view()->GetWebView()->setPageScaleFactor(1, WebPoint(0, 0)); // Resetting the internals object also overrides the WebPreferences, so we diff --git a/content/shell/renderer/test_runner/event_sender.cc b/content/shell/renderer/test_runner/event_sender.cc index 3f19551..bbaf528 100644 --- a/content/shell/renderer/test_runner/event_sender.cc +++ b/content/shell/renderer/test_runner/event_sender.cc @@ -1492,6 +1492,7 @@ void EventSender::SetPageScaleFactor(float scale_factor, int x, int y) { void EventSender::SetPageScaleFactorLimits(float min_scale, float max_scale) { view_->setPageScaleFactorLimits(min_scale, max_scale); + view_->setDefaultPageScaleLimits(min_scale, max_scale); } void EventSender::ClearTouchPoints() { |