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

Unified Diff: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm

Issue 157403004: [mac] Implement dragging of multiple tabs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes for rsesek. Created 6 years, 10 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/tabs/tab_strip_controller.mm
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
index b84dc3a62295f2a9b906cb3c503fe0de4c3787a6..b1d0c836cb354592fe96ce800a0b386d10fbbf31 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
@@ -788,6 +788,14 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay, CGFloat alpha) {
return -1;
}
+- (NSArray*)selectedViews {
+ NSMutableArray* views = [NSMutableArray arrayWithCapacity:[tabArray_ count]];
+ for (TabController* tab in tabArray_.get()) {
+ if ([tab selected])
+ [views addObject:[tab tabView]];
+ }
+ return views;
+}
// Returns the view at the given index, using the array of TabControllers to
// get the associated view. Returns nil if out of range.
@@ -1715,8 +1723,7 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay, CGFloat alpha) {
[self layoutTabs];
}
-- (void)setFrameOfActiveTab:(NSRect)frame {
- NSView* view = [self activeTabView];
+- (void)setFrame:(NSRect)frame ofTabView:(NSView*)view {
NSValue* identifier = [NSValue valueWithPointer:view];
[targetFrames_ setObject:[NSValue valueWithRect:frame]
forKey:identifier];
@@ -1727,6 +1734,14 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay, CGFloat alpha) {
return tabStripModel_;
}
+- (NSArray*)tabViews {
+ NSMutableArray* views = [NSMutableArray arrayWithCapacity:[tabArray_ count]];
+ for (TabController* tab in tabArray_.get()) {
+ [views addObject:[tab tabView]];
+ }
+ return views;
+}
+
- (NSView*)activeTabView {
int activeIndex = tabStripModel_->active_index();
// Take closing tabs into account. They can't ever be selected.
@@ -1734,16 +1749,18 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay, CGFloat alpha) {
return [self viewAtIndex:activeIndex];
}
-// Find the model index based on the x coordinate of the placeholder. If there
-// is no placeholder, this returns the end of the tab strip. Closing tabs are
-// not considered in computing the index.
- (int)indexOfPlaceholder {
- double placeholderX = placeholderFrame_.origin.x;
- int index = 0;
- int location = 0;
// Use |tabArray_| here instead of the tab strip count in order to get the
// correct index when there are closing tabs to the left of the placeholder.
const int count = [tabArray_ count];
+
+ // No placeholder, return the end of the strip.
+ if (placeholderTab_ == nil)
+ return count;
+
+ double placeholderX = placeholderFrame_.origin.x;
+ int index = 0;
+ int location = 0;
while (index < count) {
// Ignore closing tabs for simplicity. The only drawback of this is that
// if the placeholder is placed right before one or several contiguous
@@ -1789,10 +1806,10 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay, CGFloat alpha) {
// new window. Mini-tabs are either app or pinned tabs; the app state is stored
// by the |contents|, but the |pinned| state is the caller's responsibility.
- (void)dropWebContents:(WebContents*)contents
+ atIndex:(int)modelIndex
withFrame:(NSRect)frame
- asPinnedTab:(BOOL)pinned {
- int modelIndex = [self indexOfPlaceholder];
-
+ asPinnedTab:(BOOL)pinned
+ activate:(BOOL)activate {
// Mark that the new tab being created should start at |frame|. It will be
// reset as soon as the tab has been positioned.
droppedTabFrame_ = frame;
@@ -1800,8 +1817,10 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay, CGFloat alpha) {
// Insert it into this tab strip. We want it in the foreground and to not
// inherit the current tab's group.
tabStripModel_->InsertWebContentsAt(
- modelIndex, contents,
- TabStripModel::ADD_ACTIVE | (pinned ? TabStripModel::ADD_PINNED : 0));
+ modelIndex,
+ contents,
+ (activate ? TabStripModel::ADD_ACTIVE : TabStripModel::ADD_NONE) |
+ (pinned ? TabStripModel::ADD_PINNED : TabStripModel::ADD_NONE));
}
// Called when the tab strip view changes size. As we only registered for
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_controller.h ('k') | chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698