|
| 1 | +--- a/chrome/browser/ui/views/frame/browser_view.cc |
| 2 | ++++ b/chrome/browser/ui/views/frame/browser_view.cc |
| 3 | +@@ -4868,6 +4868,18 @@ int BrowserView::NonClientHitTest(const |
| 4 | + } |
| 5 | + } |
| 6 | + |
| 7 | ++ // The empty spaces in toolbar should allow mouse events to fall |
| 8 | ++ // through to the caption area. |
| 9 | ++ if (toolbar_) { |
| 10 | ++ gfx::Point test_point(point); |
| 11 | ++ if (ConvertedHitTest(parent(), toolbar_, &test_point)) { |
| 12 | ++ if (toolbar_->IsPositionInWindowCaption(test_point)) { |
| 13 | ++ return HTCAPTION; |
| 14 | ++ } |
| 15 | ++ return HTCLIENT; |
| 16 | ++ } |
| 17 | ++ } |
| 18 | ++ |
| 19 | + // Let the frame handle any events that fall within the bounds of the window |
| 20 | + // controls overlay. |
| 21 | + if (IsWindowControlsOverlayEnabled() && GetActiveWebContents()) { |
| 22 | +--- a/chrome/browser/ui/views/toolbar/toolbar_view.cc |
| 23 | ++++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc |
| 24 | +@@ -664,6 +664,44 @@ bool ToolbarView::GetAppMenuFocused() co |
| 25 | + return app_menu_button_ && app_menu_button_->HasFocus(); |
| 26 | + } |
| 27 | + |
| 28 | ++bool ToolbarView::IsRectInWindowCaption(const gfx::Rect& rect) const { |
| 29 | ++ // Clickable elements are only in container view. If the container view is not |
| 30 | ++ // visible, then the rect is in the window caption. |
| 31 | ++ if (!container_view_ || !container_view_->GetVisible()) { |
| 32 | ++ return true; |
| 33 | ++ } |
| 34 | ++ |
| 35 | ++ const auto get_target_rect = [&](views::View* target) { |
| 36 | ++ gfx::RectF rect_in_target_coords_f(rect); |
| 37 | ++ views::View::ConvertRectToTarget(this, target, &rect_in_target_coords_f); |
| 38 | ++ return gfx::ToEnclosingRect(rect_in_target_coords_f); |
| 39 | ++ }; |
| 40 | ++ |
| 41 | ++ // Check each child view in container_view_ to see if the rect intersects with |
| 42 | ++ // any clickable elements. If it does, check if the click is actually on that |
| 43 | ++ // element. False if on a clickable element, true if not on a clickable element. |
| 44 | ++ for (views::View* const child : container_view_->children()) { |
| 45 | ++ if (!child->GetVisible()) { |
| 46 | ++ continue; |
| 47 | ++ } |
| 48 | ++ |
| 49 | ++ const gfx::Rect target_rect = get_target_rect(child); |
| 50 | ++ if (child->GetLocalBounds().Intersects(target_rect)) { |
| 51 | ++ // Check if the rect is actually on the child. |
| 52 | ++ if (child->HitTestRect(target_rect)) { |
| 53 | ++ return false; |
| 54 | ++ } |
| 55 | ++ } |
| 56 | ++ } |
| 57 | ++ |
| 58 | ++ // The rect is not on any clickable element, so it's in the window caption. |
| 59 | ++ return true; |
| 60 | ++} |
| 61 | ++ |
| 62 | ++bool ToolbarView::IsPositionInWindowCaption(const gfx::Point& point) const { |
| 63 | ++ return IsRectInWindowCaption(gfx::Rect(point, gfx::Size(1, 1))); |
| 64 | ++} |
| 65 | ++ |
| 66 | + void ToolbarView::ShowIntentPickerBubble( |
| 67 | + std::vector<IntentPickerBubbleView::AppInfo> app_info, |
| 68 | + bool show_stay_in_chrome, |
| 69 | +--- a/chrome/browser/ui/views/toolbar/toolbar_view.h |
| 70 | ++++ b/chrome/browser/ui/views/toolbar/toolbar_view.h |
| 71 | +@@ -126,6 +126,15 @@ class ToolbarView : public views::Access |
| 72 | + // Returns true if the app menu is focused. |
| 73 | + bool GetAppMenuFocused() const; |
| 74 | + |
| 75 | ++ // Returns true if the specified rect is not on a clickable element, |
| 76 | ++ // aka container view children: toolbar buttons, location bar, etc. |
| 77 | ++ bool IsRectInWindowCaption(const gfx::Rect& rect) const; |
| 78 | ++ |
| 79 | ++ // A convenience function which calls |IsRectInWindowCaption()| with a rect of |
| 80 | ++ // size 1x1 and an origin of |point|. |point| is in the local coordinate space |
| 81 | ++ // of |this|. |
| 82 | ++ bool IsPositionInWindowCaption(const gfx::Point& point) const; |
| 83 | ++ |
| 84 | + void ShowIntentPickerBubble( |
| 85 | + std::vector<IntentPickerBubbleView::AppInfo> app_info, |
| 86 | + bool show_stay_in_chrome, |
0 commit comments