Commit ea0f6cfd authored by manukh's avatar manukh Committed by Chromium LUCI CQ

[omnibox] [rich-autocompletion] Adjust LBV drag events to OVV's origin.

Background:

Rich autocompletion adds the |omnibox_additional_text_view_| label
adjacent to the |omnibox_view_| in the LocationBarView. When the
|omnibox_view_| displays a suggestion's contents, the label (if visible)
displays its description and vice versa. The LocationBarView directs
mouse button events from |omnibox_additional_text_view_| to
|omnibox_view_| so that, e.g., clicking the former will focus the
latter.

This CL:

Drag MouseEvent's have a location relative to the target view. This CL
makes locationBarView adjust the drag event's location relative to the
|omnibox_view_|'s origin before redirecting them. Otherwise, the event
location would be incorrectly offset by about 40 px and the text
selection would trail to the right of the mouse cursor when selection
began on the LocationBarView.

Bug: 1158649, 1062446
Change-Id: Iadbb3bc0a5742f6e5031a44175036991a55bd6b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2601160Reviewed-by: default avatarOrin Jaworski <orinj@chromium.org>
Commit-Queue: manuk hovanesian <manukh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839143}
parent 30702684
...@@ -1086,15 +1086,17 @@ void LocationBarView::OnPaintBorder(gfx::Canvas* canvas) { ...@@ -1086,15 +1086,17 @@ void LocationBarView::OnPaintBorder(gfx::Canvas* canvas) {
} }
bool LocationBarView::OnMousePressed(const ui::MouseEvent& event) { bool LocationBarView::OnMousePressed(const ui::MouseEvent& event) {
return omnibox_view_->OnMousePressed(event); return omnibox_view_->OnMousePressed(
AdjustMouseEventLocationForOmniboxView(event));
} }
bool LocationBarView::OnMouseDragged(const ui::MouseEvent& event) { bool LocationBarView::OnMouseDragged(const ui::MouseEvent& event) {
return omnibox_view_->OnMouseDragged(event); return omnibox_view_->OnMouseDragged(
AdjustMouseEventLocationForOmniboxView(event));
} }
void LocationBarView::OnMouseReleased(const ui::MouseEvent& event) { void LocationBarView::OnMouseReleased(const ui::MouseEvent& event) {
omnibox_view_->OnMouseReleased(event); omnibox_view_->OnMouseReleased(AdjustMouseEventLocationForOmniboxView(event));
} }
void LocationBarView::OnMouseMoved(const ui::MouseEvent& event) { void LocationBarView::OnMouseMoved(const ui::MouseEvent& event) {
...@@ -1313,3 +1315,10 @@ void LocationBarView::UpdatePermissionChipVisibility() { ...@@ -1313,3 +1315,10 @@ void LocationBarView::UpdatePermissionChipVisibility() {
permission_chip()->Reshow(); permission_chip()->Reshow();
} }
} }
ui::MouseEvent LocationBarView::AdjustMouseEventLocationForOmniboxView(
const ui::MouseEvent& event) const {
ui::MouseEvent adjusted(event);
adjusted.ConvertLocationToTarget<View>(this, omnibox_view_);
return adjusted;
}
...@@ -354,6 +354,11 @@ class LocationBarView : public LocationBar, ...@@ -354,6 +354,11 @@ class LocationBarView : public LocationBar,
// mode. // mode.
void UpdatePermissionChipVisibility(); void UpdatePermissionChipVisibility();
// Adjusts |event|'s location to be relative to |omnibox_view_|'s origin; used
// for directing LocationBarView events to the |omnibox_view_|.
ui::MouseEvent AdjustMouseEventLocationForOmniboxView(
const ui::MouseEvent& event) const;
// The Browser this LocationBarView is in. Note that at least // The Browser this LocationBarView is in. Note that at least
// chromeos::SimpleWebViewDialog uses a LocationBarView outside any browser // chromeos::SimpleWebViewDialog uses a LocationBarView outside any browser
// window, so this may be NULL. // window, so this may be NULL.
......
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