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

Unified Diff: chrome/browser/ui/cocoa/table_model_array_controller.mm

Issue 5831001: Objective-C Readability CL for bauerb. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/table_model_array_controller.mm
diff --git a/chrome/browser/ui/cocoa/table_model_array_controller.mm b/chrome/browser/ui/cocoa/table_model_array_controller.mm
index e7321276e695e549a09f78d3d21cd6d1ab3e61d5..9d4a401ed81ff60d3e4a0a5c497a67395872e44b 100644
--- a/chrome/browser/ui/cocoa/table_model_array_controller.mm
+++ b/chrome/browser/ui/cocoa/table_model_array_controller.mm
@@ -9,7 +9,7 @@
#include "base/sys_string_conversions.h"
#include "chrome/browser/remove_rows_table_model.h"
-@interface TableModelArrayController (PrivateMethods)
+@interface TableModelArrayController ()
- (NSUInteger)offsetForGroupID:(int)groupID;
- (NSUInteger)offsetForGroupID:(int)groupID startingOffset:(NSUInteger)offset;
@@ -150,14 +150,18 @@ static NSString* const kGroupID = @"_group_id";
}
- (void)modelDidAddItemsInRange:(NSRange)range {
+ if (range.length == 0)
+ return;
NSMutableArray* rows = [NSMutableArray arrayWithCapacity:range.length];
- for (NSUInteger i=range.location; i<NSMaxRange(range); ++i)
+ for (NSUInteger i = range.location; i < NSMaxRange(range); ++i)
[rows addObject:[self columnValuesForRow:i]];
- [self insertObjects:rows
- atArrangedObjectIndexes:[self controllerRowsForModelRowsInRange:range]];
+ NSArray* indexes = [self controllerRowsForModelRowsInRange:range];
+ [self insertObjects:rows atArrangedObjectIndexes:indexes];
}
- (void)modelDidRemoveItemsInRange:(NSRange)range {
+ if (range.length == 0)
+ return;
NSMutableIndexSet* indexes =
[NSMutableIndexSet indexSetWithIndexesInRange:range];
if (model_->HasGroups()) {
@@ -197,7 +201,7 @@ static NSString* const kGroupID = @"_group_id";
return dict;
}
-// Overridden from NSArrayController -----------------------------------------
+#pragma mark Overridden from NSArrayController
- (BOOL)canRemove {
if (!model_)
@@ -213,9 +217,9 @@ static NSString* const kGroupID = @"_group_id";
model_->RemoveRows(rows);
}
-// Table View Delegate --------------------------------------------------------
+#pragma mark NSTableView delegate methods
-- (BOOL)tableView:(NSTableView*)tv isGroupRow:(NSInteger)row {
+- (BOOL)tableView:(NSTableView*)tableView isGroupRow:(NSInteger)row {
NSDictionary* values = [[self arrangedObjects] objectAtIndex:row];
return [[values objectForKey:kIsGroupRow] boolValue];
}
@@ -237,10 +241,11 @@ static NSString* const kGroupID = @"_group_id";
return indexes;
}
-// Actions --------------------------------------------------------------------
+#pragma mark Actions
- (IBAction)removeAll:(id)sender {
model_->RemoveAll();
}
@end
+

Powered by Google App Engine
This is Rietveld 408576698