Skip to content

Commit

Permalink
[Android WebView] Wire up Blink's UseLegacyBackgroundSizeShorthandBeh…
Browse files Browse the repository at this point in the history
…avior setting

R=benm@chromium.org
BUG=277157
TEST=AwSettingsTest#testUseLegacyBackgroundSizeShorthandBehavior

Review URL: https://chromiumcodereview.appspot.com/23483005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220710 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mnaganov@chromium.org committed Aug 31, 2013
1 parent 0784e88 commit d8b3bb4
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public enum LayoutAlgorithm {
private String mDefaultVideoPosterURL;
private float mInitialPageScalePercent = 0;

private final boolean mSupportDeprecatedTargetDensityDPI;
private final boolean mSupportLegacyQuirks;

private final boolean mPasswordEchoEnabled;

Expand Down Expand Up @@ -197,7 +197,7 @@ public AwSettings(Context context, boolean hasInternetPermission,
mPasswordEchoEnabled = Settings.System.getInt(context.getContentResolver(),
Settings.System.TEXT_SHOW_PASSWORD, 1) == 1;

mSupportDeprecatedTargetDensityDPI = supportsLegacyQuirks;
mSupportLegacyQuirks = supportsLegacyQuirks;
}
// Defer initializing the native side until a native WebContents instance is set.
}
Expand Down Expand Up @@ -1036,8 +1036,8 @@ private boolean getSupportMultipleWindowsLocked() {
}

@CalledByNative
private boolean getSupportDeprecatedTargetDensityDPILocked() {
return mSupportDeprecatedTargetDensityDPI;
private boolean getSupportLegacyQuirksLocked() {
return mSupportLegacyQuirks;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2504,6 +2504,36 @@ public void run() {
}
}

@SmallTest
@Feature({"AndroidWebView", "Preferences"})
// background shorthand property must not override background-size when
// it's already set.
public void testUseLegacyBackgroundSizeShorthandBehavior() throws Throwable {
final TestAwContentsClient contentClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentClient);
final AwContents awContents = testContainerView.getAwContents();
AwSettings settings = getAwSettingsOnUiThread(awContents);
CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHelper();
final String expectedBackgroundSize = "cover";
final String page = "<html><head>" +
"<script>" +
"function getBackgroundSize() {" +
" var e = document.getElementById('test'); " +
" e.style.backgroundSize = '" + expectedBackgroundSize + "';" +
" e.style.background = 'center red url(dummy://test.png) no-repeat border-box'; " +
" return e.style.backgroundSize; " +
"}" +
"</script></head>" +
"<body onload='document.title=getBackgroundSize()'>" +
" <div id='test'> </div>" +
"</body></html>";
settings.setJavaScriptEnabled(true);
loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false);
String actualBackgroundSize = getTitleOnUiThread(awContents);
assertEquals(expectedBackgroundSize, actualBackgroundSize);
}

static class ViewPair {
private final AwContents contents0;
private final TestAwContentsClient client0;
Expand Down
5 changes: 3 additions & 2 deletions android_webview/native/aw_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@ void AwSettings::UpdateWebkitPreferencesLocked(JNIEnv* env, jobject obj) {
prefs.default_video_poster_url = url.obj() ?
GURL(ConvertJavaStringToUTF8(url)) : GURL();

prefs.support_deprecated_target_density_dpi =
Java_AwSettings_getSupportDeprecatedTargetDensityDPILocked(env, obj);
bool support_quirks = Java_AwSettings_getSupportLegacyQuirksLocked(env, obj);
prefs.support_deprecated_target_density_dpi = support_quirks;
prefs.use_legacy_background_size_shorthand_behavior = support_quirks;

prefs.password_echo_enabled =
Java_AwSettings_getPasswordEchoEnabled(env, obj);
Expand Down
1 change: 1 addition & 0 deletions content/public/common/common_param_traits_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ IPC_STRUCT_TRAITS_BEGIN(WebPreferences)
IPC_STRUCT_TRAITS_MEMBER(user_gesture_required_for_media_playback)
IPC_STRUCT_TRAITS_MEMBER(default_video_poster_url)
IPC_STRUCT_TRAITS_MEMBER(support_deprecated_target_density_dpi)
IPC_STRUCT_TRAITS_MEMBER(use_legacy_background_size_shorthand_behavior)
IPC_STRUCT_TRAITS_MEMBER(use_wide_viewport)
#endif
IPC_STRUCT_TRAITS_END()
Expand Down
2 changes: 2 additions & 0 deletions content/renderer/web_preferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ void ApplyWebPreferences(const WebPreferences& prefs, WebView* web_view) {
ASCIIToUTF16(prefs.default_video_poster_url.spec()));
settings->setSupportDeprecatedTargetDensityDPI(
prefs.support_deprecated_target_density_dpi);
settings->setUseLegacyBackgroundSizeShorthandBehavior(
prefs.use_legacy_background_size_shorthand_behavior);
settings->setUseWideViewport(prefs.use_wide_viewport);
#endif

Expand Down
1 change: 1 addition & 0 deletions webkit/common/webpreferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ WebPreferences::WebPreferences()
double_tap_to_zoom_enabled(true),
user_gesture_required_for_media_playback(true),
support_deprecated_target_density_dpi(false),
use_legacy_background_size_shorthand_behavior(false),
use_wide_viewport(true)
#endif
{
Expand Down
1 change: 1 addition & 0 deletions webkit/common/webpreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ struct WEBKIT_COMMON_EXPORT WebPreferences {
bool user_gesture_required_for_media_playback;
GURL default_video_poster_url;
bool support_deprecated_target_density_dpi;
bool use_legacy_background_size_shorthand_behavior;
bool use_wide_viewport;
#endif

Expand Down

0 comments on commit d8b3bb4

Please sign in to comment.