Commit f4efbd05 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

UseCounter: Gather web-compat data for changing <dialog> behaviour.

As per:
https://github.com/w3c/csswg-drafts/issues/4645

This adds two different use-counters:
1) Determine how often we query a non-zero scroll offset.
2) Determine how often a dialog is larger than the viewport.

Change-Id: I2a3532512ad29ad22e997073ae9eed80612bf4ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2258213
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781149}
parent 879efe4a
...@@ -2663,6 +2663,8 @@ enum WebFeature { ...@@ -2663,6 +2663,8 @@ enum WebFeature {
kFetchUploadStreaming = 3326, kFetchUploadStreaming = 3326,
kWebkitLineClampWithoutWebkitBox = 3327, kWebkitLineClampWithoutWebkitBox = 3327,
kWebBluetoothGetDevices = 3328, kWebBluetoothGetDevices = 3328,
kDialogWithNonZeroScrollOffset = 3329,
kDialogHeightLargerThanViewport = 3330,
// Add new features immediately above this line. Don't change assigned // Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots. // numbers of any item, and don't reuse removed slots.
......
...@@ -369,15 +369,21 @@ base::Optional<LayoutUnit> ComputeAbsoluteDialogYPosition( ...@@ -369,15 +369,21 @@ base::Optional<LayoutUnit> ComputeAbsoluteDialogYPosition(
return base::nullopt; return base::nullopt;
} }
auto* scrollable_area = dialog.GetDocument().View()->LayoutViewport(); auto& document = dialog.GetDocument();
auto* scrollable_area = document.View()->LayoutViewport();
LayoutUnit top = LayoutUnit top =
LayoutUnit((dialog.Style()->GetPosition() == EPosition::kFixed) LayoutUnit((dialog.Style()->GetPosition() == EPosition::kFixed)
? 0 ? 0
: scrollable_area->ScrollOffsetInt().Height()); : scrollable_area->ScrollOffsetInt().Height());
int visible_height = dialog.GetDocument().View()->Height(); if (top)
UseCounter::Count(document, WebFeature::kDialogWithNonZeroScrollOffset);
int visible_height = document.View()->Height();
if (height < visible_height) if (height < visible_height)
top += (visible_height - height) / 2; top += (visible_height - height) / 2;
else if (height > visible_height)
UseCounter::Count(document, WebFeature::kDialogHeightLargerThanViewport);
dialog_node->SetCentered(top); dialog_node->SetCentered(top);
return top; return top;
} }
......
...@@ -28064,6 +28064,8 @@ Called by update_use_counter_feature_enum.py.--> ...@@ -28064,6 +28064,8 @@ Called by update_use_counter_feature_enum.py.-->
<int value="3326" label="FetchUploadStreaming"/> <int value="3326" label="FetchUploadStreaming"/>
<int value="3327" label="WebkitLineClampWithoutWebkitBox"/> <int value="3327" label="WebkitLineClampWithoutWebkitBox"/>
<int value="3328" label="WebBluetoothGetDevices"/> <int value="3328" label="WebBluetoothGetDevices"/>
<int value="3329" label="DialogWithNonZeroScrollOffset"/>
<int value="3330" label="DialogHeightLargerThanViewport"/>
</enum> </enum>
<enum name="FeaturePolicyAllowlistType"> <enum name="FeaturePolicyAllowlistType">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment