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

Side by Side Diff: chrome/browser/ui/views/tabs/touch_tab_strip_layout.cc

Issue 10291002: Fix crash in touch layout code. Without this can end up indexing into (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/touch_tab_strip_layout_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/tabs/touch_tab_strip_layout.h" 5 #include "chrome/browser/ui/views/tabs/touch_tab_strip_layout.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 } 305 }
306 306
307 void TouchTabStripLayout::AdjustTrailingStackedTabs() { 307 void TouchTabStripLayout::AdjustTrailingStackedTabs() {
308 int index = tab_count() - 1; 308 int index = tab_count() - 1;
309 int max_stacked_x = width_ - size_.width() - max_stacked_width(); 309 int max_stacked_x = width_ - size_.width() - max_stacked_width();
310 while (index > active_index() && 310 while (index > active_index() &&
311 ideal_x(index) - ideal_x(index - 1) <= stacked_padding_ && 311 ideal_x(index) - ideal_x(index - 1) <= stacked_padding_ &&
312 ideal_x(index - 1) >= max_stacked_x) { 312 ideal_x(index - 1) >= max_stacked_x) {
313 index--; 313 index--;
314 } 314 }
315 if (ideal_x(index) - ideal_x(index - 1) <= stacked_padding_ && 315 if (index > active_index() &&
316 ideal_x(index) - ideal_x(index - 1) <= stacked_padding_ &&
316 ideal_x(index - 1) >= max_stacked_x) { 317 ideal_x(index - 1) >= max_stacked_x) {
317 index--; 318 index--;
318 } 319 }
319 if (index >= tab_count() - max_stacked_count_) 320 if (index >= tab_count() - max_stacked_count_)
320 return; 321 return;
321 int first_stacked = index; 322 int first_stacked = index;
322 int x = width_ - size_.width() - 323 int x = width_ - size_.width() -
323 std::min(tab_count() - first_stacked, max_stacked_count_) * 324 std::min(tab_count() - first_stacked, max_stacked_count_) *
324 stacked_padding_; 325 stacked_padding_;
325 for (; index < first_stacked + max_stacked_count_; 326 for (; index < first_stacked + max_stacked_count_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 result += " "; 378 result += " ";
378 if (i == active_index()) 379 if (i == active_index())
379 result += "["; 380 result += "[";
380 result += base::IntToString(view_model_->ideal_bounds(i).x()); 381 result += base::IntToString(view_model_->ideal_bounds(i).x());
381 if (i == active_index()) 382 if (i == active_index())
382 result += "]"; 383 result += "]";
383 } 384 }
384 return result; 385 return result;
385 } 386 }
386 #endif 387 #endif
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/touch_tab_strip_layout_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698