Commit 00d2ced4 authored by Ionel Popescu's avatar Ionel Popescu Committed by Commit Bot

Add UseCounters for popup bounds and interactions.

Scenarios that we are interested in:
 - how often is the popup exceeding the owner window bounds
 - how often does the popup receive tap/mouse down/ mouse wheel events
outside the owner window bounds

This CL has no user visible behavior changes.

Bug: 1066241
Change-Id: I0f88e75b452a2c7490045b31f0b9e773314a2d50
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2200425
Commit-Queue: Ionel Popescu <iopopesc@microsoft.com>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#769035}
parent aa281e0a
...@@ -2632,6 +2632,12 @@ enum WebFeature { ...@@ -2632,6 +2632,12 @@ enum WebFeature {
kForceEncodedVideoInsertableStreams = 3295, kForceEncodedVideoInsertableStreams = 3295,
kTransformStyleContainingBlockComputedUsedMismatch = 3296, kTransformStyleContainingBlockComputedUsedMismatch = 3296,
kAdditionalGroupingPropertiesForCompat = 3297, kAdditionalGroupingPropertiesForCompat = 3297,
kPopupDoesNotExceedOwnerWindowBounds = 3298,
kPopupExceedsOwnerWindowBounds = 3299,
kPopupExceedsOwnerWindowBoundsForIframe = 3300,
kPopupGestureTapExceedsOwnerWindowBounds = 3301,
kPopupMouseDownExceedsOwnerWindowBounds = 3302,
kPopupMouseWheelExceedsOwnerWindowBounds = 3303,
// 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.
......
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
#include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h" #include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/keyboard_codes.h" #include "third_party/blink/renderer/platform/keyboard_codes.h"
#include "third_party/blink/renderer/platform/text/text_direction.h" #include "third_party/blink/renderer/platform/text/text_direction.h"
#include "third_party/blink/renderer/platform/web_test_support.h" #include "third_party/blink/renderer/platform/web_test_support.h"
...@@ -413,6 +414,21 @@ AXObject* WebPagePopupImpl::RootAXObject() { ...@@ -413,6 +414,21 @@ AXObject* WebPagePopupImpl::RootAXObject() {
} }
void WebPagePopupImpl::SetWindowRect(const IntRect& rect_in_screen) { void WebPagePopupImpl::SetWindowRect(const IntRect& rect_in_screen) {
if (!closing_) {
IntRect owner_window_rect_in_screen = OwnerWindowRectInScreen();
Document& document = popup_client_->OwnerElement().GetDocument();
if (owner_window_rect_in_screen.Contains(rect_in_screen)) {
UseCounter::Count(document,
WebFeature::kPopupDoesNotExceedOwnerWindowBounds);
} else {
WebFeature feature =
document.GetFrame()->IsMainFrame()
? WebFeature::kPopupExceedsOwnerWindowBounds
: WebFeature::kPopupExceedsOwnerWindowBoundsForIframe;
UseCounter::Count(document, feature);
}
}
WidgetClient()->SetWindowRect(rect_in_screen); WidgetClient()->SetWindowRect(rect_in_screen);
} }
...@@ -509,12 +525,16 @@ WebInputEventResult WebPagePopupImpl::HandleGestureEvent( ...@@ -509,12 +525,16 @@ WebInputEventResult WebPagePopupImpl::HandleGestureEvent(
const WebGestureEvent& event) { const WebGestureEvent& event) {
if (closing_) if (closing_)
return WebInputEventResult::kNotHandled; return WebInputEventResult::kNotHandled;
if ((event.GetType() == WebInputEvent::Type::kGestureTap || if (event.GetType() == WebInputEvent::Type::kGestureTap ||
event.GetType() == WebInputEvent::Type::kGestureTapDown) && event.GetType() == WebInputEvent::Type::kGestureTapDown) {
!IsViewportPointInWindow(event.PositionInWidget().x(), if (!IsViewportPointInWindow(event.PositionInWidget().x(),
event.PositionInWidget().y())) { event.PositionInWidget().y())) {
Cancel(); Cancel();
return WebInputEventResult::kNotHandled; return WebInputEventResult::kNotHandled;
}
CheckScreenPointInOwnerWindowAndCount(
event.PositionInScreen(),
WebFeature::kPopupGestureTapExceedsOwnerWindowBounds);
} }
WebGestureEvent scaled_event = WebGestureEvent scaled_event =
TransformWebGestureEvent(MainFrame().View(), event); TransformWebGestureEvent(MainFrame().View(), event);
...@@ -524,18 +544,26 @@ WebInputEventResult WebPagePopupImpl::HandleGestureEvent( ...@@ -524,18 +544,26 @@ WebInputEventResult WebPagePopupImpl::HandleGestureEvent(
void WebPagePopupImpl::HandleMouseDown(LocalFrame& main_frame, void WebPagePopupImpl::HandleMouseDown(LocalFrame& main_frame,
const WebMouseEvent& event) { const WebMouseEvent& event) {
if (IsViewportPointInWindow(event.PositionInWidget().x(), if (IsViewportPointInWindow(event.PositionInWidget().x(),
event.PositionInWidget().y())) event.PositionInWidget().y())) {
CheckScreenPointInOwnerWindowAndCount(
event.PositionInScreen(),
WebFeature::kPopupMouseDownExceedsOwnerWindowBounds);
PageWidgetEventHandler::HandleMouseDown(main_frame, event); PageWidgetEventHandler::HandleMouseDown(main_frame, event);
else } else {
Cancel(); Cancel();
}
} }
WebInputEventResult WebPagePopupImpl::HandleMouseWheel( WebInputEventResult WebPagePopupImpl::HandleMouseWheel(
LocalFrame& main_frame, LocalFrame& main_frame,
const WebMouseWheelEvent& event) { const WebMouseWheelEvent& event) {
if (IsViewportPointInWindow(event.PositionInWidget().x(), if (IsViewportPointInWindow(event.PositionInWidget().x(),
event.PositionInWidget().y())) event.PositionInWidget().y())) {
CheckScreenPointInOwnerWindowAndCount(
event.PositionInScreen(),
WebFeature::kPopupMouseWheelExceedsOwnerWindowBounds);
return PageWidgetEventHandler::HandleMouseWheel(main_frame, event); return PageWidgetEventHandler::HandleMouseWheel(main_frame, event);
}
Cancel(); Cancel();
return WebInputEventResult::kNotHandled; return WebInputEventResult::kNotHandled;
} }
...@@ -569,6 +597,23 @@ bool WebPagePopupImpl::IsViewportPointInWindow(int x, int y) { ...@@ -569,6 +597,23 @@ bool WebPagePopupImpl::IsViewportPointInWindow(int x, int y) {
.Contains(IntPoint(point_in_window.x, point_in_window.y)); .Contains(IntPoint(point_in_window.x, point_in_window.y));
} }
void WebPagePopupImpl::CheckScreenPointInOwnerWindowAndCount(
const gfx::PointF& point_in_screen,
WebFeature feature) const {
if (closing_)
return;
IntRect owner_window_rect = OwnerWindowRectInScreen();
if (!owner_window_rect.Contains(point_in_screen.x(), point_in_screen.y()))
UseCounter::Count(popup_client_->OwnerElement().GetDocument(), feature);
}
IntRect WebPagePopupImpl::OwnerWindowRectInScreen() const {
LocalFrameView* view = popup_client_->OwnerElement().GetDocument().View();
IntRect frame_rect = view->FrameRect();
return view->FrameToScreen(frame_rect);
}
WebInputEventResult WebPagePopupImpl::DispatchBufferedTouchEvents() { WebInputEventResult WebPagePopupImpl::DispatchBufferedTouchEvents() {
if (closing_) if (closing_)
return WebInputEventResult::kNotHandled; return WebInputEventResult::kNotHandled;
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "third_party/blink/public/platform/cross_variant_mojo_util.h" #include "third_party/blink/public/platform/cross_variant_mojo_util.h"
#include "third_party/blink/public/web/web_page_popup.h" #include "third_party/blink/public/web/web_page_popup.h"
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/frame/web_feature_forward.h"
#include "third_party/blink/renderer/core/page/page_popup.h" #include "third_party/blink/renderer/core/page/page_popup.h"
#include "third_party/blink/renderer/core/page/page_widget_delegate.h" #include "third_party/blink/renderer/core/page/page_widget_delegate.h"
#include "third_party/blink/renderer/platform/heap/persistent.h" #include "third_party/blink/renderer/platform/heap/persistent.h"
...@@ -158,6 +159,9 @@ class CORE_EXPORT WebPagePopupImpl final : public WebPagePopup, ...@@ -158,6 +159,9 @@ class CORE_EXPORT WebPagePopupImpl final : public WebPagePopup,
Element* FocusedElement() const; Element* FocusedElement() const;
bool IsViewportPointInWindow(int x, int y); bool IsViewportPointInWindow(int x, int y);
void CheckScreenPointInOwnerWindowAndCount(const gfx::PointF& point_in_screen,
WebFeature feature) const;
IntRect OwnerWindowRectInScreen() const;
// PagePopup function // PagePopup function
AXObject* RootAXObject() override; AXObject* RootAXObject() override;
......
...@@ -27369,6 +27369,12 @@ Called by update_use_counter_feature_enum.py.--> ...@@ -27369,6 +27369,12 @@ Called by update_use_counter_feature_enum.py.-->
<int value="3295" label="ForceEncodedVideoInsertableStreams"/> <int value="3295" label="ForceEncodedVideoInsertableStreams"/>
<int value="3296" label="TransformStyleContainingBlockComputedUsedMismatch"/> <int value="3296" label="TransformStyleContainingBlockComputedUsedMismatch"/>
<int value="3297" label="AdditionalGroupingPropertiesForCompat"/> <int value="3297" label="AdditionalGroupingPropertiesForCompat"/>
<int value="3298" label="PopupDoesNotExceedOwnerWindowBounds"/>
<int value="3299" label="PopupExceedsOwnerWindowBounds"/>
<int value="3300" label="PopupExceedsOwnerWindowBoundsForIframe"/>
<int value="3301" label="PopupGestureTapExceedsOwnerWindowBounds"/>
<int value="3302" label="PopupMouseDownExceedsOwnerWindowBounds"/>
<int value="3303" label="PopupMouseWheelExceedsOwnerWindowBounds"/>
</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