Skip to content

Commit

Permalink
UseCounter: Gather web-compat data for changing <dialog> behaviour.
Browse files Browse the repository at this point in the history
As per:
w3c/csswg-drafts#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: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: Aleks Totic <atotic@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#781149}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: f4efbd052053ec693a6fe2298067ba400e14ec59
  • Loading branch information
bfgeek authored and Commit Bot committed Jun 23, 2020
1 parent 7a22037 commit df62036
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions blink/public/mojom/web_feature/web_feature.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -2663,6 +2663,8 @@ enum WebFeature {
kFetchUploadStreaming = 3326,
kWebkitLineClampWithoutWebkitBox = 3327,
kWebBluetoothGetDevices = 3328,
kDialogWithNonZeroScrollOffset = 3329,
kDialogHeightLargerThanViewport = 3330,

// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots.
Expand Down
10 changes: 8 additions & 2 deletions blink/renderer/core/layout/ng/ng_absolute_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,21 @@ base::Optional<LayoutUnit> ComputeAbsoluteDialogYPosition(
return base::nullopt;
}

auto* scrollable_area = dialog.GetDocument().View()->LayoutViewport();
auto& document = dialog.GetDocument();
auto* scrollable_area = document.View()->LayoutViewport();
LayoutUnit top =
LayoutUnit((dialog.Style()->GetPosition() == EPosition::kFixed)
? 0
: 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)
top += (visible_height - height) / 2;
else if (height > visible_height)
UseCounter::Count(document, WebFeature::kDialogHeightLargerThanViewport);
dialog_node->SetCentered(top);
return top;
}
Expand Down

0 comments on commit df62036

Please sign in to comment.