Commit ea3afc24 authored by Liviu Tinta's avatar Liviu Tinta Committed by Commit Bot

[ScrollUnification] Cannot scroll <select> popup

Select html element uses WebPagePopupImpl widget which handles scroll
gestures differently than other widgets. We need to handle scroll differently.
Because this is a simple widget, we'll try to use the underlying
LayoutViewport to scroll directly.

Bug: 1113863
Change-Id: I762bee3746704f98c69d6e6d5cc8f2ab7b22ac21
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2481356Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Commit-Queue: Liviu Tinta <liviutinta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822968}
parent 94fc2765
...@@ -79,6 +79,41 @@ ...@@ -79,6 +79,41 @@
#include "third_party/blink/renderer/platform/widget/widget_base.h" #include "third_party/blink/renderer/platform/widget/widget_base.h"
namespace blink { namespace blink {
namespace {
ScrollableArea* ToScrollableArea(Node* node) {
DCHECK(node);
LayoutBox* scrolling_box = node->GetLayoutBox();
if (auto* element = DynamicTo<Element>(node))
scrolling_box = element->GetLayoutBoxForScrolling();
return scrolling_box ? scrolling_box->GetScrollableArea() : nullptr;
}
bool CanScroll(Node* node) {
if (!node)
return false;
return ToScrollableArea(node);
}
Node* FindFirstScroller(Node* event_target) {
DCHECK(event_target);
Node* cur_node = nullptr;
bool found = false;
LayoutBox* cur_box = event_target->GetLayoutObject()
? event_target->GetLayoutObject()->EnclosingBox()
: nullptr;
while (cur_box) {
cur_node = cur_box->GetNode();
if (CanScroll(cur_node)) {
found = true;
break;
}
cur_box = cur_box->ContainingBlock();
}
if (found && cur_node)
return cur_node;
return nullptr;
}
} // namespace
class PagePopupChromeClient final : public EmptyChromeClient { class PagePopupChromeClient final : public EmptyChromeClient {
public: public:
...@@ -693,6 +728,33 @@ WebInputEventResult WebPagePopupImpl::HandleGestureEvent( ...@@ -693,6 +728,33 @@ WebInputEventResult WebPagePopupImpl::HandleGestureEvent(
event.PositionInScreen(), event.PositionInScreen(),
WebFeature::kPopupGestureTapExceedsOwnerWindowBounds); WebFeature::kPopupGestureTapExceedsOwnerWindowBounds);
} }
if (RuntimeEnabledFeatures::ScrollUnificationEnabled()) {
if (event.GetType() == WebInputEvent::Type::kGestureScrollBegin) {
HitTestLocation locationScroll(FloatPoint(event.PositionInWidget()));
HitTestResult resultScroll =
MainFrame().GetEventHandler().HitTestResultAtLocation(locationScroll);
scrollable_node_ = FindFirstScroller(resultScroll.InnerNode());
return WebInputEventResult::kHandledSystem;
}
if (event.GetType() == WebInputEvent::Type::kGestureScrollUpdate) {
if (!scrollable_node_)
return WebInputEventResult::kNotHandled;
ScrollableArea* scrollable = ToScrollableArea(scrollable_node_);
if (!scrollable)
return WebInputEventResult::kNotHandled;
ScrollOffset scroll_offset(-event.data.scroll_update.delta_x,
-event.data.scroll_update.delta_y);
scrollable->UserScroll(event.data.scroll_update.delta_units,
scroll_offset, ScrollableArea::ScrollCallback());
return WebInputEventResult::kHandledSystem;
}
if (event.GetType() == WebInputEvent::Type::kGestureScrollEnd) {
scrollable_node_ = nullptr;
return WebInputEventResult::kHandledSystem;
}
}
WebGestureEvent scaled_event = WebGestureEvent scaled_event =
TransformWebGestureEvent(MainFrame().View(), event); TransformWebGestureEvent(MainFrame().View(), event);
return MainFrame().GetEventHandler().HandleGestureEvent(scaled_event); return MainFrame().GetEventHandler().HandleGestureEvent(scaled_event);
......
...@@ -272,6 +272,10 @@ class CORE_EXPORT WebPagePopupImpl final : public WebPagePopup, ...@@ -272,6 +272,10 @@ class CORE_EXPORT WebPagePopupImpl final : public WebPagePopup,
// complicated inheritance structures. // complicated inheritance structures.
std::unique_ptr<WidgetBase> widget_base_; std::unique_ptr<WidgetBase> widget_base_;
// Only used for Scroll Unification.
// Will be set in GestureScrollBegin
WeakPersistent<Node> scrollable_node_;
friend class WebPagePopup; friend class WebPagePopup;
friend class PagePopupChromeClient; friend class PagePopupChromeClient;
......
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