Skip to content

Commit

Permalink
Update naming of interactive-widgets meta property
Browse files Browse the repository at this point in the history
This CL updates the names of some properties in the
`interactive-widgets` property of the viewport meta tag to reflect
updated spec text[1]:

"interactive-widgets" --> "interactive-widget"
"resize-layout" --> "resizes-content"
"resize-visual" --> "resizes-visual"

[1] w3c/csswg-drafts#7826

Bug: 1353728
Change-Id: I6a07dd9d8e2c018a107ab045a3c181946129b033
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3940786
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1057574}
  • Loading branch information
bokand authored and Chromium LUCI CQ committed Oct 11, 2022
1 parent 56935ac commit 4e1884d
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 72 deletions.
Expand Up @@ -197,8 +197,8 @@ void initializeCompositorContent(LayoutManagerImpl layoutManager, View urlBar,
@VirtualKeyboardMode.EnumType
private int mVirtualKeyboardMode =
ChromeFeatureList.sOSKResizesVisualViewportByDefault.isEnabled()
? VirtualKeyboardMode.RESIZE_VISUAL
: VirtualKeyboardMode.RESIZE_LAYOUT;
? VirtualKeyboardMode.RESIZES_VISUAL
: VirtualKeyboardMode.RESIZES_CONTENT;

private OnscreenContentProvider mOnscreenContentProvider;

Expand Down Expand Up @@ -918,7 +918,7 @@ private boolean oskResizesVisualViewport() {
// UNSET means the author hasn't explicitly set a preference but the mode should have been
// set to the default in that case.
assert mVirtualKeyboardMode != VirtualKeyboardMode.UNSET;
return mVirtualKeyboardMode == VirtualKeyboardMode.RESIZE_VISUAL;
return mVirtualKeyboardMode == VirtualKeyboardMode.RESIZES_VISUAL;
}

/**
Expand Down Expand Up @@ -1550,8 +1550,8 @@ private void updateViewStateListener(ContentView newContentView) {
void updateVirtualKeyboardMode(@VirtualKeyboardMode.EnumType int newMode) {
if (newMode == VirtualKeyboardMode.UNSET) {
newMode = ChromeFeatureList.sOSKResizesVisualViewportByDefault.isEnabled()
? VirtualKeyboardMode.RESIZE_VISUAL
: VirtualKeyboardMode.RESIZE_LAYOUT;
? VirtualKeyboardMode.RESIZES_VISUAL
: VirtualKeyboardMode.RESIZES_CONTENT;
}

if (mVirtualKeyboardMode == newMode) return;
Expand All @@ -1563,8 +1563,8 @@ void updateVirtualKeyboardMode(@VirtualKeyboardMode.EnumType int newMode) {
// If we're going into or out of the default OSK resizes visual viewport mode
// we're changing whether the ApplicationViewportInsetSupplier needs to listen to
// the keyboard since its responsible for insetting the visual viewport.
if (oldMode == VirtualKeyboardMode.RESIZE_VISUAL
|| newMode == VirtualKeyboardMode.RESIZE_VISUAL) {
if (oldMode == VirtualKeyboardMode.RESIZES_VISUAL
|| newMode == VirtualKeyboardMode.RESIZES_VISUAL) {
updateApplicationViewportInsetSuppliers();
}
}
Expand Down
Expand Up @@ -215,14 +215,15 @@ public void testVirtualKeyboardResizesVisualViewportFlag() throws Throwable {
}

/**
* Tests the <meta name="viewport" content="interactive-widgets=resize-visual"> tag causes the
* Tests the <meta name="viewport" content="interactive-widget=resizes-visual"> tag causes the
* page to resize only the visual viewport.
*/
@Test
@MediumTest
@EnableFeatures({ChromeFeatureList.OSK_RESIZES_VISUAL_VIEWPORT})
public void testResizeVisualMetaTag() throws Throwable {
startMainActivityWithURL("/chrome/test/data/android/page_with_editable.html?resize-visual");
public void testResizesVisualMetaTag() throws Throwable {
startMainActivityWithURL(
"/chrome/test/data/android/page_with_editable.html?resizes-visual");

int initialHeight = getPageInnerHeight();
double initialVVHeight = getVisualViewportHeight();
Expand Down Expand Up @@ -257,8 +258,9 @@ public void testResizeVisualMetaTag() throws Throwable {
@MediumTest
@DisableFeatures({ChromeFeatureList.OSK_RESIZES_VISUAL_VIEWPORT})
@CommandLineFlags.Add({"enable-blink-features=ViewportMetaInteractiveWidgetProperty"})
public void testResizeVisualMetaTagFlagDisabled() throws Throwable {
startMainActivityWithURL("/chrome/test/data/android/page_with_editable.html?resize-visual");
public void testResizesVisualMetaTagFlagDisabled() throws Throwable {
startMainActivityWithURL(
"/chrome/test/data/android/page_with_editable.html?resizes-visual");

int initialHeight = getPageInnerHeight();
double initialVVHeight = getVisualViewportHeight();
Expand All @@ -283,14 +285,15 @@ public void testResizeVisualMetaTagFlagDisabled() throws Throwable {
}

/**
* Tests the <meta name="viewport" content="interactive-widgets=resize-layout"> tag opts the
* Tests the <meta name="viewport" content="interactive-widget=resizes-content"> tag opts the
* page back into a mode where the keyboard resizes layout.
*/
@Test
@MediumTest
@EnableFeatures({ChromeFeatureList.OSK_RESIZES_VISUAL_VIEWPORT})
public void testResizeLayoutMetaTag() throws Throwable {
startMainActivityWithURL("/chrome/test/data/android/page_with_editable.html?resize-layout");
public void testResizesLayoutMetaTag() throws Throwable {
startMainActivityWithURL(
"/chrome/test/data/android/page_with_editable.html?resizes-content");
int initialHeight = getPageInnerHeight();
double initialVVHeight = getVisualViewportHeight();

Expand All @@ -316,7 +319,7 @@ public void testResizeLayoutMetaTag() throws Throwable {
}

/**
* Tests the <meta name="viewport" content="interactive-widgets=overlays-content"> tag causes
* Tests the <meta name="viewport" content="interactive-widget=overlays-content"> tag causes
* the page to avoid resizing any viewports.
*/
@Test
Expand Down Expand Up @@ -356,20 +359,20 @@ public void testModeAfterNavigation() throws Throwable {
Assert.assertEquals(mActivityTestRule.getActivity()
.getCompositorViewHolderForTesting()
.getVirtualKeyboardModeForTesting(),
VirtualKeyboardMode.RESIZE_VISUAL);
VirtualKeyboardMode.RESIZES_VISUAL);

navigateToURL("/chrome/test/data/android/page_with_editable.html?resize-layout");
navigateToURL("/chrome/test/data/android/page_with_editable.html?resizes-content");
Assert.assertEquals(mActivityTestRule.getActivity()
.getCompositorViewHolderForTesting()
.getVirtualKeyboardModeForTesting(),
VirtualKeyboardMode.RESIZE_LAYOUT);
VirtualKeyboardMode.RESIZES_CONTENT);

navigateToURL("/chrome/test/data/android/page_with_editable.html");

Assert.assertEquals(mActivityTestRule.getActivity()
.getCompositorViewHolderForTesting()
.getVirtualKeyboardModeForTesting(),
VirtualKeyboardMode.RESIZE_VISUAL);
VirtualKeyboardMode.RESIZES_VISUAL);

navigateToURL("/chrome/test/data/android/page_with_editable.html?overlays-content");

Expand All @@ -378,11 +381,11 @@ public void testModeAfterNavigation() throws Throwable {
.getVirtualKeyboardModeForTesting(),
VirtualKeyboardMode.OVERLAYS_CONTENT);

openInNewTab("/chrome/test/data/android/page_with_editable.html?resize-layout");
openInNewTab("/chrome/test/data/android/page_with_editable.html?resizes-content");
Assert.assertEquals(mActivityTestRule.getActivity()
.getCompositorViewHolderForTesting()
.getVirtualKeyboardModeForTesting(),
VirtualKeyboardMode.RESIZE_LAYOUT);
VirtualKeyboardMode.RESIZES_CONTENT);

// Ensure showing the keyboard and going through the resize flow uses the current virtual
// keyboard mode.
Expand Down
Expand Up @@ -331,7 +331,7 @@ public void testOverlayGeometryNotTriggeredDueToNoKeyboard() {
@EnableFeatures(ChromeFeatureList.OSK_RESIZES_VISUAL_VIEWPORT)
public void testWebContentResizeWhenInOSKResizeVisualMode() {
// Ensure the default virtual keyboard mode is used.
mCompositorViewHolder.updateVirtualKeyboardMode(VirtualKeyboardMode.RESIZE_VISUAL);
mCompositorViewHolder.updateVirtualKeyboardMode(VirtualKeyboardMode.RESIZES_VISUAL);
// show the keyboard and set height of the webcontent.
// totalAdjustedHeight = height passed to #setSize (200).
// The reduced height is because of the keyboard taking up the bottom space.
Expand All @@ -342,7 +342,7 @@ public void testWebContentResizeWhenInOSKResizeVisualMode() {
mCompositorViewHolder.setSize(
mWebContents, mContainerView, totalAdjustedWidth, totalAdjustedHeight);

// In RESIZE_VISUAL mode, the virtual keyboard will not resize the web contents.
// In RESIZES_VISUAL mode, the virtual keyboard will not resize the web contents.
int expectedWebContentsHeight = 941;
verify(mWebContents, times(1)).setSize(totalAdjustedWidth, expectedWebContentsHeight);
verify(mCompositorViewHolder, times(0))
Expand All @@ -352,7 +352,7 @@ public void testWebContentResizeWhenInOSKResizeVisualMode() {
@Test
public void testWebContentResizeWhenInOSKResizeLayoutMode() {
// Ensure the default virtual keyboard mode is used.
mCompositorViewHolder.updateVirtualKeyboardMode(VirtualKeyboardMode.RESIZE_LAYOUT);
mCompositorViewHolder.updateVirtualKeyboardMode(VirtualKeyboardMode.RESIZES_CONTENT);
// show the keyboard and set height of the webcontent.
// totalAdjustedHeight = height passed to #setSize (200).
// The reduced height is because of the keyboard taking up the bottom space.
Expand All @@ -363,7 +363,7 @@ public void testWebContentResizeWhenInOSKResizeLayoutMode() {
mCompositorViewHolder.setSize(
mWebContents, mContainerView, totalAdjustedWidth, totalAdjustedHeight);

// In RESIZE_LAYOUT mode, the web contents are resized to exclude the keyboard height.
// In RESIZES_CONTENT mode, the web contents are resized to exclude the keyboard height.
int expectedWebContentsHeight = totalAdjustedHeight;
verify(mWebContents, times(1)).setSize(totalAdjustedWidth, expectedWebContentsHeight);
verify(mCompositorViewHolder, times(0))
Expand Down
10 changes: 5 additions & 5 deletions chrome/test/data/android/page_with_editable.html
Expand Up @@ -4,12 +4,12 @@
<script>
const params = new URLSearchParams(window.location.search);
let metaTagContent = 'width=device-width';
if (params.has('resize-layout'))
metaTagContent += ',interactive-widgets=resize-layout';
else if (params.has('resize-visual'))
metaTagContent += ',interactive-widgets=resize-visual';
if (params.has('resizes-content'))
metaTagContent += ',interactive-widget=resizes-content';
else if (params.has('resizes-visual'))
metaTagContent += ',interactive-widget=resizes-visual';
else if (params.has('overlays-content')) {
metaTagContent += ',interactive-widgets=overlays-content';
metaTagContent += ',interactive-widget=overlays-content';

window.numGeometryChangeEvents = 0;
navigator.virtualKeyboard.addEventListener('geometrychange', () => {
Expand Down
10 changes: 5 additions & 5 deletions third_party/blink/renderer/core/html/html_meta_element.cc
Expand Up @@ -333,10 +333,10 @@ blink::mojom::ViewportFit HTMLMetaElement::ParseViewportFitValueAsEnum(
// static
absl::optional<ui::mojom::blink::VirtualKeyboardMode>
HTMLMetaElement::ParseVirtualKeyboardValueAsEnum(const String& value) {
if (EqualIgnoringASCIICase(value, "resize-layout"))
return ui::mojom::blink::VirtualKeyboardMode::kResizeLayout;
else if (EqualIgnoringASCIICase(value, "resize-visual"))
return ui::mojom::blink::VirtualKeyboardMode::kResizeVisual;
if (EqualIgnoringASCIICase(value, "resizes-content"))
return ui::mojom::blink::VirtualKeyboardMode::kResizesContent;
else if (EqualIgnoringASCIICase(value, "resizes-visual"))
return ui::mojom::blink::VirtualKeyboardMode::kResizesVisual;
else if (EqualIgnoringASCIICase(value, "overlays-content"))
return ui::mojom::blink::VirtualKeyboardMode::kOverlaysContent;

Expand Down Expand Up @@ -404,7 +404,7 @@ void HTMLMetaElement::ProcessViewportKeyValuePair(
// Ignore vendor-specific argument.
} else if (RuntimeEnabledFeatures::
ViewportMetaInteractiveWidgetPropertyEnabled() &&
key_string == "interactive-widgets") {
key_string == "interactive-widget") {
absl::optional<ui::mojom::blink::VirtualKeyboardMode> resize_type =
ParseVirtualKeyboardValueAsEnum(value_string);

Expand Down

0 comments on commit 4e1884d

Please sign in to comment.