New issue
Advanced search Search tips

Issue 753535 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Aug 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Task



Sign in to add a comment

TabStripModel should use size_t to represent tab indexes / count.

Project Member Reported by sebmarchand@chromium.org, Aug 8 2017

Issue description

... Or maybe not, in which case a comment in the code will be helpful (I might have missed it).

Looking at tab_strip_model.h it looks like we're mostly using signed integers (a.k.a. int) to represent values that shouldn't be signed:
- The indexes are represented as int but are always assumed to be > 0 (by calling TabStripModel::ContainsIndex)
- The number of WebContents is returned as an int (casted from a size_t, https://cs.chromium.org/chromium/src/chrome/browser/ui/tabs/tab_strip_model.h?sq=package:chromium&l=132)

Is there any particular reason for this? If not it's probably not worth fixing this (or the priority of this is pretty low) but it'd be good to add a comment to explain the reasons for this.
 
Labels: -Type-Bug Type-Task
Summary: TabStripModel should use size_t to represent tab indexes / count. (was: TabStripModel should use unsigned values to represent tab indexes / count.)
I think the choice is int vs. size_t.

I think the biggest reason to not use size_t would be if we're using -1 as a signal value somewhere.  But that could still be done with some kind of kNoTab = SIZE_MAX.

Another reason is that I think some of the underlying views objects use ints for indexes.  But that makes this more of a question of where the casts lie, not whether to have casts at all.

Comment 2 by sky@chromium.org, Aug 8 2017

Owner: sky@chromium.org
Status: WontFix (was: Untriaged)
Given views is int based converting TabStripModel to be size_t would mean we need a bunch of casts for the code that interacts with the two. This would rapidly spiral into the need to touch a bunch of other related ui code (such as ListSelectionModel). While views is int based (which I stand behind) I see little value in doing this.
I consider it a bug that views uses ints for things our style guide says should be size_t, but I don't think it's a bug worth trying to fix.  Tons of labor for very little benefit if any.
Yeah, I agree that this isn't something worth to fix, the risk of breaking something largely outweigh the benefits. The fact that the "count" method returns an int still bothers me but I can live with this.

Thanks for the quick response anyway, I'm not familiar with the views so I was lacking some context here.

Sign in to add a comment