Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4803)

Unified Diff: chrome/browser/ui/views/frame/opaque_browser_frame_view.cc

Issue 22891016: Add support for rect-based event targeting in views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
index 4de7694c3db636ced686c9fa578ec81c3498ce12..0ca60a3dff72ee044f0b0ef0e231904c4af59a96 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
@@ -42,6 +42,7 @@
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/path.h"
+#include "ui/gfx/rect_conversions.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
@@ -330,12 +331,11 @@ bool OpaqueBrowserFrameView::HitTestRect(const gfx::Rect& rect) const {
}
// If the rect is outside the bounds of the client area, claim it.
- // TODO(tdanderson): Implement View::ConvertRectToTarget().
- gfx::Point rect_in_client_view_coords_origin(rect.origin());
- View::ConvertPointToTarget(this, frame()->client_view(),
- &rect_in_client_view_coords_origin);
- gfx::Rect rect_in_client_view_coords(
- rect_in_client_view_coords_origin, rect.size());
+ gfx::RectF rect_in_client_view_coords_f(rect);
+ View::ConvertRectToTarget(this, frame()->client_view(),
+ &rect_in_client_view_coords_f);
+ gfx::Rect rect_in_client_view_coords = gfx::ToEnclosingRect(
+ rect_in_client_view_coords_f);
if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords))
return true;
@@ -345,12 +345,10 @@ bool OpaqueBrowserFrameView::HitTestRect(const gfx::Rect& rect) const {
if (!tabstrip || !browser_view()->IsTabStripVisible())
return false;
- gfx::Point rect_in_tabstrip_coords_origin(rect.origin());
- View::ConvertPointToTarget(this, tabstrip,
- &rect_in_tabstrip_coords_origin);
- gfx::Rect rect_in_tabstrip_coords(
- rect_in_tabstrip_coords_origin, rect.size());
-
+ gfx::RectF rect_in_tabstrip_coords_f(rect);
+ View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f);
+ gfx::Rect rect_in_tabstrip_coords = gfx::ToEnclosingRect(
+ rect_in_tabstrip_coords_f);
if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) {
// |rect| is below the tabstrip.
return false;
@@ -358,11 +356,7 @@ bool OpaqueBrowserFrameView::HitTestRect(const gfx::Rect& rect) const {
if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) {
// Claim |rect| if it is in a non-tab portion of the tabstrip.
- // TODO(tdanderson): Pass |rect_in_tabstrip_coords| instead of its center
- // point to TabStrip::IsPositionInWindowCaption() once
- // GetEventHandlerForRect() is implemented.
- return tabstrip->IsPositionInWindowCaption(
- rect_in_tabstrip_coords.CenterPoint());
+ return tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords);
}
// The window switcher button is to the right of the tabstrip but is
@@ -370,11 +364,11 @@ bool OpaqueBrowserFrameView::HitTestRect(const gfx::Rect& rect) const {
views::View* window_switcher_button =
browser_view()->window_switcher_button();
if (window_switcher_button && window_switcher_button->visible()) {
- gfx::Point rect_in_window_switcher_coords_origin(rect.origin());
- View::ConvertPointToTarget(this, window_switcher_button,
- &rect_in_window_switcher_coords_origin);
- gfx::Rect rect_in_window_switcher_coords(
- rect_in_window_switcher_coords_origin, rect.size());
+ gfx::RectF rect_in_window_switcher_coords_f(rect);
+ View::ConvertRectToTarget(this, window_switcher_button,
+ &rect_in_window_switcher_coords_f);
+ gfx::Rect rect_in_window_switcher_coords = gfx::ToEnclosingRect(
+ rect_in_window_switcher_coords_f);
if (window_switcher_button->HitTestRect(rect_in_window_switcher_coords))
return false;

Powered by Google App Engine
This is Rietveld 408576698