summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-01 16:11:27 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-01 16:11:27 +0000
commitc702d70890ab023ce723dde7aea8c66adb7ef98e (patch)
tree7c8065a793e71e841b59cc605efb5a14dee540aa
parentd8fd6faa7cdccb77c2d496e1ebb9d5f1b9ede717 (diff)
downloadchromium_src-c702d70890ab023ce723dde7aea8c66adb7ef98e.zip
chromium_src-c702d70890ab023ce723dde7aea8c66adb7ef98e.tar.gz
chromium_src-c702d70890ab023ce723dde7aea8c66adb7ef98e.tar.bz2
[Mac] Reduce jank in the cookie manager by lazily creating child nodes for the UI.
Also selects the first cookie node whene expanding an origin node. BUG=33248 TEST=With a lot of cookies in your profile: Chromium-->Preferences-->Under the Hood-->Show cookies... Filter by a domain, expand the domain and the first cookie should be selected. Clear the filter and list should reappear speadily. Review URL: http://codereview.chromium.org/554151 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37695 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/cocoa/cookie_tree_node.h4
-rw-r--r--chrome/browser/cocoa/cookie_tree_node.mm22
-rw-r--r--chrome/browser/cocoa/cookies_window_controller.mm7
-rw-r--r--chrome/browser/cocoa/cookies_window_controller_unittest.mm2
4 files changed, 23 insertions, 12 deletions
diff --git a/chrome/browser/cocoa/cookie_tree_node.h b/chrome/browser/cocoa/cookie_tree_node.h
index 5ff6695..1f161d5 100644
--- a/chrome/browser/cocoa/cookie_tree_node.h
+++ b/chrome/browser/cocoa/cookie_tree_node.h
@@ -12,6 +12,8 @@
@interface CocoaCookieTreeNode : NSObject {
scoped_nsobject<NSString> title_;
scoped_nsobject<NSMutableArray> children_;
+ // We lazily create children, so we need to know if we are a leaf.
+ BOOL isLeaf_;
// The platform-independent model node.
CookieTreeNode* treeNode_; // weak
@@ -39,7 +41,7 @@
// Getters.
- (NSString*)title;
// |-children| is mutable so that the CookiesTreeModelObserverBridge can
-// operate on the children.
+// operate on the children. Note that this lazily creates children.
- (NSMutableArray*)children;
- (TreeModelNode*)treeNode;
diff --git a/chrome/browser/cocoa/cookie_tree_node.mm b/chrome/browser/cocoa/cookie_tree_node.mm
index 00ef5bc..53b7bab 100644
--- a/chrome/browser/cocoa/cookie_tree_node.mm
+++ b/chrome/browser/cocoa/cookie_tree_node.mm
@@ -15,15 +15,7 @@
if ((self = [super init])) {
DCHECK(node);
treeNode_ = node;
-
- const int childCount = node->GetChildCount();
- children_.reset([[NSMutableArray alloc] initWithCapacity:childCount]);
- for (int i = 0; i < childCount; ++i) {
- CookieTreeNode* child = node->GetChild(i);
- scoped_nsobject<CocoaCookieTreeNode> childNode(
- [[CocoaCookieTreeNode alloc] initWithNode:child]);
- [children_ addObject:childNode.get()];
- }
+ isLeaf_ = (node->GetChildCount() == 0);
[self rebuild];
}
@@ -67,7 +59,7 @@
}
- (BOOL)isLeaf {
- return ([children_ count] == 0);
+ return isLeaf_;
}
- (NSString*)title {
@@ -75,6 +67,16 @@
}
- (NSMutableArray*)children {
+ if (!children_.get()) {
+ const int childCount = treeNode_->GetChildCount();
+ children_.reset([[NSMutableArray alloc] initWithCapacity:childCount]);
+ for (int i = 0; i < childCount; ++i) {
+ CookieTreeNode* child = treeNode_->GetChild(i);
+ scoped_nsobject<CocoaCookieTreeNode> childNode(
+ [[CocoaCookieTreeNode alloc] initWithNode:child]);
+ [children_ addObject:childNode.get()];
+ }
+ }
return children_.get();
}
diff --git a/chrome/browser/cocoa/cookies_window_controller.mm b/chrome/browser/cocoa/cookies_window_controller.mm
index c997537..9ac09b7 100644
--- a/chrome/browser/cocoa/cookies_window_controller.mm
+++ b/chrome/browser/cocoa/cookies_window_controller.mm
@@ -306,6 +306,13 @@ bool CookiesTreeModelObserverBridge::HasCocoaModel() {
children = [item childNodes];
DCHECK_EQ([children count], 1U);
[outlineView expandItem:[children lastObject]];
+ // Select the first node in that child set.
+ NSTreeNode* folderChild = [children lastObject];
+ if ([[folderChild childNodes] count] > 0) {
+ NSTreeNode* firstCookieChild =
+ [[folderChild childNodes] objectAtIndex:0];
+ [treeController_ setSelectionIndexPath:[firstCookieChild indexPath]];
+ }
}
}
}
diff --git a/chrome/browser/cocoa/cookies_window_controller_unittest.mm b/chrome/browser/cocoa/cookies_window_controller_unittest.mm
index d3a729c..f1f9e1a 100644
--- a/chrome/browser/cocoa/cookies_window_controller_unittest.mm
+++ b/chrome/browser/cocoa/cookies_window_controller_unittest.mm
@@ -54,7 +54,7 @@
@end
@implementation CocoaCookieTreeNode (UglyHacks)
- (NSMutableArray*)childs {
- return children_.get();
+ return (NSMutableArray*)[self children];
}
@end