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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view_layout.cc

Issue 10828265: Replace views::LocatedEvent with ui::LocatedEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/browser_view_layout.h" 5 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
6 6
7 #include "chrome/browser/ui/find_bar/find_bar.h" 7 #include "chrome/browser/ui/find_bar/find_bar.h"
8 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 8 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
9 #include "chrome/browser/ui/view_ids.h" 9 #include "chrome/browser/ui/view_ids.h"
10 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 10 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
(...skipping 16 matching lines...) Expand all
27 // treated as clicks to the frame, rather than clicks to the tab. 27 // treated as clicks to the frame, rather than clicks to the tab.
28 const int kTabShadowSize = 2; 28 const int kTabShadowSize = 2;
29 // The vertical overlap between the TabStrip and the Toolbar. 29 // The vertical overlap between the TabStrip and the Toolbar.
30 const int kToolbarTabStripVerticalOverlap = 3; 30 const int kToolbarTabStripVerticalOverlap = 3;
31 // The number of pixels the bookmark bar should overlap the spacer by if the 31 // The number of pixels the bookmark bar should overlap the spacer by if the
32 // spacer is visible. 32 // spacer is visible.
33 const int kSpacerBookmarkBarOverlap = 1; 33 const int kSpacerBookmarkBarOverlap = 1;
34 // The number of pixels the metro switcher is offset from the right edge. 34 // The number of pixels the metro switcher is offset from the right edge.
35 const int kWindowSwitcherOffsetX = 7; 35 const int kWindowSwitcherOffsetX = 7;
36 36
37 // Combines View::ConvertPointToView and View::HitTest for a given |point|. 37 // Combines View::ConvertPointToTarget and View::HitTest for a given |point|.
38 // Converts |point| from |src| to |dst| and hit tests it against |dst|. The 38 // Converts |point| from |src| to |dst| and hit tests it against |dst|. The
39 // converted |point| can then be retrieved and used for additional tests. 39 // converted |point| can then be retrieved and used for additional tests.
40 bool ConvertedHitTest(views::View* src, views::View* dst, gfx::Point* point) { 40 bool ConvertedHitTest(views::View* src, views::View* dst, gfx::Point* point) {
41 DCHECK(src); 41 DCHECK(src);
42 DCHECK(dst); 42 DCHECK(dst);
43 DCHECK(point); 43 DCHECK(point);
44 views::View::ConvertPointToView(src, dst, point); 44 views::View::ConvertPointToTarget(src, dst, point);
45 return dst->HitTestPoint(*point); 45 return dst->HitTestPoint(*point);
46 } 46 }
47 47
48 } // namespace 48 } // namespace
49 49
50 //////////////////////////////////////////////////////////////////////////////// 50 ////////////////////////////////////////////////////////////////////////////////
51 // BrowserViewLayout, public: 51 // BrowserViewLayout, public:
52 52
53 BrowserViewLayout::BrowserViewLayout() 53 BrowserViewLayout::BrowserViewLayout()
54 : tabstrip_(NULL), 54 : tabstrip_(NULL),
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 bounding_box.set_width(std::max(0, bounding_box.width() - scrollbar_width)); 125 bounding_box.set_width(std::max(0, bounding_box.width() - scrollbar_width));
126 if (base::i18n::IsRTL()) 126 if (base::i18n::IsRTL())
127 bounding_box.set_x(bounding_box.x() + scrollbar_width); 127 bounding_box.set_x(bounding_box.x() + scrollbar_width);
128 128
129 return bounding_box; 129 return bounding_box;
130 } 130 }
131 131
132 bool BrowserViewLayout::IsPositionInWindowCaption( 132 bool BrowserViewLayout::IsPositionInWindowCaption(
133 const gfx::Point& point) { 133 const gfx::Point& point) {
134 gfx::Point tabstrip_point(point); 134 gfx::Point tabstrip_point(point);
135 views::View::ConvertPointToView(browser_view_, tabstrip_, &tabstrip_point); 135 views::View::ConvertPointToTarget(browser_view_, tabstrip_, &tabstrip_point);
136 return tabstrip_->IsPositionInWindowCaption(tabstrip_point); 136 return tabstrip_->IsPositionInWindowCaption(tabstrip_point);
137 } 137 }
138 138
139 int BrowserViewLayout::NonClientHitTest( 139 int BrowserViewLayout::NonClientHitTest(
140 const gfx::Point& point) { 140 const gfx::Point& point) {
141 // Since the TabStrip only renders in some parts of the top of the window, 141 // Since the TabStrip only renders in some parts of the top of the window,
142 // the un-obscured area is considered to be part of the non-client caption 142 // the un-obscured area is considered to be part of the non-client caption
143 // area of the window. So we need to treat hit-tests in these regions as 143 // area of the window. So we need to treat hit-tests in these regions as
144 // hit-tests of the titlebar. 144 // hit-tests of the titlebar.
145 145
146 views::View* parent = browser_view_->parent(); 146 views::View* parent = browser_view_->parent();
147 147
148 gfx::Point point_in_browser_view_coords(point); 148 gfx::Point point_in_browser_view_coords(point);
149 views::View::ConvertPointToView( 149 views::View::ConvertPointToTarget(
150 parent, browser_view_, &point_in_browser_view_coords); 150 parent, browser_view_, &point_in_browser_view_coords);
151 gfx::Point test_point(point); 151 gfx::Point test_point(point);
152 152
153 // Determine if the TabStrip exists and is capable of being clicked on. We 153 // Determine if the TabStrip exists and is capable of being clicked on. We
154 // might be a popup window without a TabStrip. 154 // might be a popup window without a TabStrip.
155 if (browser_view_->IsTabStripVisible()) { 155 if (browser_view_->IsTabStripVisible()) {
156 // See if the mouse pointer is within the bounds of the TabStrip. 156 // See if the mouse pointer is within the bounds of the TabStrip.
157 if (ConvertedHitTest(parent, tabstrip_, &test_point)) { 157 if (ConvertedHitTest(parent, tabstrip_, &test_point)) {
158 if (tabstrip_->IsPositionInWindowCaption(test_point)) 158 if (tabstrip_->IsPositionInWindowCaption(test_point))
159 return HTCAPTION; 159 return HTCAPTION;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 if (!browser_view_->IsTabStripVisible()) { 302 if (!browser_view_->IsTabStripVisible()) {
303 tabstrip_->SetVisible(false); 303 tabstrip_->SetVisible(false);
304 tabstrip_->SetBounds(0, 0, 0, 0); 304 tabstrip_->SetBounds(0, 0, 0, 0);
305 return 0; 305 return 0;
306 } 306 }
307 // This retrieves the bounds for the tab strip based on whether or not we show 307 // This retrieves the bounds for the tab strip based on whether or not we show
308 // anything to the left of it, like the incognito avatar. 308 // anything to the left of it, like the incognito avatar.
309 gfx::Rect tabstrip_bounds( 309 gfx::Rect tabstrip_bounds(
310 browser_view_->frame()->GetBoundsForTabStrip(tabstrip_)); 310 browser_view_->frame()->GetBoundsForTabStrip(tabstrip_));
311 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); 311 gfx::Point tabstrip_origin(tabstrip_bounds.origin());
312 views::View::ConvertPointToView(browser_view_->parent(), browser_view_, 312 views::View::ConvertPointToTarget(browser_view_->parent(), browser_view_,
313 &tabstrip_origin); 313 &tabstrip_origin);
314 tabstrip_bounds.set_origin(tabstrip_origin); 314 tabstrip_bounds.set_origin(tabstrip_origin);
315 315
316 tabstrip_->SetVisible(true); 316 tabstrip_->SetVisible(true);
317 tabstrip_->SetBoundsRect(tabstrip_bounds); 317 tabstrip_->SetBoundsRect(tabstrip_bounds);
318 int bottom = tabstrip_bounds.bottom(); 318 int bottom = tabstrip_bounds.bottom();
319 319
320 // The metro window switcher sits at the far right edge of the tabstrip 320 // The metro window switcher sits at the far right edge of the tabstrip
321 // a |kWindowSwitcherOffsetX| pixels from the right edge. 321 // a |kWindowSwitcherOffsetX| pixels from the right edge.
322 // Only visible if there is an incognito window because switching between 322 // Only visible if there is an incognito window because switching between
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 bottom -= height; 478 bottom -= height;
479 } 479 }
480 return bottom; 480 return bottom;
481 } 481 }
482 482
483 bool BrowserViewLayout::InfobarVisible() const { 483 bool BrowserViewLayout::InfobarVisible() const {
484 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. 484 // NOTE: Can't check if the size IsEmpty() since it's always 0-width.
485 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && 485 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) &&
486 (infobar_container_->GetPreferredSize().height() != 0); 486 (infobar_container_->GetPreferredSize().height() != 0);
487 } 487 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/browser/ui/views/frame/glass_browser_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698