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

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

Issue 19115003: Make the maximize button more easily hittable when there is a huge amount of tabs present (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "base/observer_list.h" 7 #include "base/observer_list.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // Finally decrease the width of the bounding box by the width of 236 // Finally decrease the width of the bounding box by the width of
237 // the vertical scroll bar. 237 // the vertical scroll bar.
238 int scrollbar_width = gfx::scrollbar_size(); 238 int scrollbar_width = gfx::scrollbar_size();
239 bounding_box.set_width(std::max(0, bounding_box.width() - scrollbar_width)); 239 bounding_box.set_width(std::max(0, bounding_box.width() - scrollbar_width));
240 if (base::i18n::IsRTL()) 240 if (base::i18n::IsRTL())
241 bounding_box.set_x(bounding_box.x() + scrollbar_width); 241 bounding_box.set_x(bounding_box.x() + scrollbar_width);
242 242
243 return bounding_box; 243 return bounding_box;
244 } 244 }
245 245
246 bool BrowserViewLayout::IsPositionInWindowCaption( 246 int BrowserViewLayout::NonClientHitTest(const gfx::Point& point) {
247 const gfx::Point& point) {
248 // Tab strip may transiently have no parent between the RemoveChildView() and
249 // AddChildView() caused by reparenting during an immersive mode reveal.
250 // During this window report that the point didn't hit a tab.
251 if (!tab_strip_->parent())
252 return true;
253 gfx::Point tabstrip_point(point);
254 views::View::ConvertPointToTarget(browser_view_, tab_strip_, &tabstrip_point);
255 return tab_strip_->IsPositionInWindowCaption(tabstrip_point);
256 }
257
258 int BrowserViewLayout::NonClientHitTest(
259 const gfx::Point& point) {
260 // Since the TabStrip only renders in some parts of the top of the window, 247 // Since the TabStrip only renders in some parts of the top of the window,
261 // the un-obscured area is considered to be part of the non-client caption 248 // the un-obscured area is considered to be part of the non-client caption
262 // area of the window. So we need to treat hit-tests in these regions as 249 // area of the window. So we need to treat hit-tests in these regions as
263 // hit-tests of the titlebar. 250 // hit-tests of the titlebar.
264 251
265 views::View* parent = browser_view_->parent(); 252 views::View* parent = browser_view_->parent();
266 253
267 gfx::Point point_in_browser_view_coords(point); 254 gfx::Point point_in_browser_view_coords(point);
268 views::View::ConvertPointToTarget( 255 views::View::ConvertPointToTarget(
269 parent, browser_view_, &point_in_browser_view_coords); 256 parent, browser_view_, &point_in_browser_view_coords);
270 gfx::Point test_point(point); 257 gfx::Point test_point(point);
271 258
272 // Determine if the TabStrip exists and is capable of being clicked on. We 259 // Determine if the TabStrip exists and is capable of being clicked on. We
273 // might be a popup window without a TabStrip. 260 // might be a popup window without a TabStrip.
274 if (browser_view_->IsTabStripVisible()) { 261 if (browser_view_->IsTabStripVisible()) {
275 // See if the mouse pointer is within the bounds of the TabStrip. 262 // See if the mouse pointer is within the bounds of the TabStrip.
276 if (ConvertedHitTest(parent, tab_strip_, &test_point)) { 263 if (ConvertedHitTest(parent, tab_strip_, &test_point)) {
277 if (tab_strip_->IsPositionInWindowCaption(test_point)) 264 if (tab_strip_->IsPositionInWindowCaption(test_point))
278 return HTCAPTION; 265 return HTCAPTION;
279 return HTCLIENT; 266 return HTCLIENT;
280 } 267 }
281 268
282 // The top few pixels of the TabStrip are a drop-shadow - as we're pretty 269 // The top few pixels of the TabStrip are a drop-shadow - as we're pretty
283 // starved of dragable area, let's give it to window dragging (this also 270 // starved of dragable area, let's give it to window dragging (this also
284 // makes sense visually). 271 // makes sense visually).
285 if (!browser_view_->IsMaximized() && 272 if (!(browser_view_->IsMaximized() || browser_view_->IsFullscreen()) &&
286 (point_in_browser_view_coords.y() < 273 (point_in_browser_view_coords.y() <
287 (tab_strip_->y() + kTabShadowSize))) { 274 (tab_strip_->y() + kTabShadowSize))) {
288 // We return HTNOWHERE as this is a signal to our containing 275 // We return HTNOWHERE as this is a signal to our containing
289 // NonClientView that it should figure out what the correct hit-test 276 // NonClientView that it should figure out what the correct hit-test
290 // code is given the mouse position... 277 // code is given the mouse position...
291 return HTNOWHERE; 278 return HTNOWHERE;
292 } 279 }
293 } 280 }
294 281
295 // If the point's y coordinate is below the top of the toolbar and otherwise 282 // If the point's y coordinate is below the top of the toolbar and otherwise
296 // within the bounds of this view, the point is considered to be within the 283 // within the bounds of this view, the point is considered to be within the
297 // client area. 284 // client area.
298 gfx::Rect bv_bounds = browser_view_->bounds(); 285 gfx::Rect bv_bounds = browser_view_->bounds();
299 bv_bounds.Offset(0, toolbar_->y()); 286 bv_bounds.Offset(0, toolbar_->y());
300 bv_bounds.set_height(bv_bounds.height() - toolbar_->y()); 287 bv_bounds.set_height(bv_bounds.height() - toolbar_->y());
301 if (bv_bounds.Contains(point)) 288 if (bv_bounds.Contains(point))
302 return HTCLIENT; 289 return HTCLIENT;
303 290
304 // If the point's y coordinate is above the top of the toolbar, but not in 291 // If the point is within the bounds of the window switcher button, the point
305 // the tabstrip (per previous checking in this function), then we consider it 292 // is considered to be within the client area.
306 // in the window caption (e.g. the area to the right of the tabstrip 293 views::View* window_switcher_button = delegate_->GetWindowSwitcherButton();
307 // underneath the window controls). However, note that we DO NOT return 294 if (window_switcher_button && window_switcher_button->visible()) {
308 // HTCAPTION here, because when the window is maximized the window controls 295 gfx::Point window_switcher_point(point_in_browser_view_coords);
309 // will fall into this space (since the BrowserView is sized to entire size 296 views::View::ConvertPointToTarget(browser_view_, window_switcher_button,
310 // of the window at that point), and the HTCAPTION value will cause the 297 &window_switcher_point);
311 // window controls not to work. So we return HTNOWHERE so that the caller 298 if (window_switcher_button->HitTestPoint(window_switcher_point))
312 // will hit-test the window controls before finally falling back to 299 return HTCLIENT;
313 // HTCAPTION. 300 }
301
302 // If the point's y coordinate is above the top of the toolbar, but neither
303 // over the tabstrip nor over the window switcher button (per previous
304 // checking in this function), then we consider it in the window caption
305 // (e.g. the area to the right of the tabstrip underneath the window
306 // controls). However, note that we DO NOT return HTCAPTION here, because
307 // when the window is maximized the window controls will fall into this
308 // space (since the BrowserView is sized to entire size of the window at that
309 // point), and the HTCAPTION value will cause the window controls not to work.
310 // So we return HTNOWHERE so that the caller will hit-test the window controls
311 // before finally falling back to HTCAPTION.
314 bv_bounds = browser_view_->bounds(); 312 bv_bounds = browser_view_->bounds();
315 bv_bounds.set_height(toolbar_->y()); 313 bv_bounds.set_height(toolbar_->y());
316 if (bv_bounds.Contains(point)) 314 if (bv_bounds.Contains(point))
317 return HTNOWHERE; 315 return HTNOWHERE;
318 316
319 // If the point is somewhere else, delegate to the default implementation. 317 // If the point is somewhere else, delegate to the default implementation.
320 return browser_view_->views::ClientView::NonClientHitTest(point); 318 return browser_view_->views::ClientView::NonClientHitTest(point);
321 } 319 }
322 320
323 ////////////////////////////////////////////////////////////////////////////// 321 //////////////////////////////////////////////////////////////////////////////
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 return bottom; 556 return bottom;
559 } 557 }
560 558
561 bool BrowserViewLayout::InfobarVisible() const { 559 bool BrowserViewLayout::InfobarVisible() const {
562 // Cast to a views::View to access GetPreferredSize(). 560 // Cast to a views::View to access GetPreferredSize().
563 views::View* infobar_container = infobar_container_; 561 views::View* infobar_container = infobar_container_;
564 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. 562 // NOTE: Can't check if the size IsEmpty() since it's always 0-width.
565 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && 563 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) &&
566 (infobar_container->GetPreferredSize().height() != 0); 564 (infobar_container->GetPreferredSize().height() != 0);
567 } 565 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view_layout.h ('k') | chrome/browser/ui/views/frame/opaque_browser_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698