summaryrefslogtreecommitdiff
path: root/chromium/ui/message_center
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-03-08 10:20:46 +0100
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-03-08 09:30:54 +0000
commitd26d06ed332166d6f61a5c06ab85aee5d987b2b6 (patch)
tree101729a45ae70b06e2586f5c66730f9e2524f3b5 /chromium/ui/message_center
parent47c928e8a4986fa683c5763762fa0069c9b3debe (diff)
downloadqtwebengine-chromium-d26d06ed332166d6f61a5c06ab85aee5d987b2b6.tar.gz
BASELINE: Update Chromium to 49.0.2623.91
And adds sources hunspell dictionary convertion tool. Change-Id: Ifb016b018e7b7cc5a2c56d8e4c1b1b563bd5eaed Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'chromium/ui/message_center')
-rw-r--r--chromium/ui/message_center/cocoa/notification_controller.h18
-rw-r--r--chromium/ui/message_center/cocoa/notification_controller.mm161
2 files changed, 108 insertions, 71 deletions
diff --git a/chromium/ui/message_center/cocoa/notification_controller.h b/chromium/ui/message_center/cocoa/notification_controller.h
index a76c4451211..ef214f1fbcf 100644
--- a/chromium/ui/message_center/cocoa/notification_controller.h
+++ b/chromium/ui/message_center/cocoa/notification_controller.h
@@ -19,6 +19,20 @@ class Notification;
@class HoverImageButton;
+namespace message_center {
+// A struct that can hold all the temporary frames
+// created when adjusting a view
+struct NotificationLayoutParams {
+ NSRect rootFrame;
+ NSRect titleFrame;
+ NSRect messageFrame;
+ NSRect contextMessageFrame;
+ NSRect settingsButtonFrame;
+ NSRect listFrame;
+ NSRect progressBarFrame;
+};
+}
+
// The base view controller class for notifications. A notification at minimum
// has an image, title, body, and close button. This controller can be used as
// the content for both a popup bubble and a view in the notification tray.
@@ -91,6 +105,10 @@ MESSAGE_CENTER_EXPORT
// Called when the user clicks within the notification view.
- (void)notificationClicked;
+// Adjust the position and height of all the internal frames by |delta|.
+- (void)adjustFrameHeight:(message_center::NotificationLayoutParams*)frames
+ delta:(CGFloat)delta;
+
@end
@interface MCNotificationController (TestingInterface)
diff --git a/chromium/ui/message_center/cocoa/notification_controller.mm b/chromium/ui/message_center/cocoa/notification_controller.mm
index 47893a50590..ae4b8fc490c 100644
--- a/chromium/ui/message_center/cocoa/notification_controller.mm
+++ b/chromium/ui/message_center/cocoa/notification_controller.mm
@@ -364,9 +364,10 @@
DCHECK_EQ(notification->id(), notificationID_);
notification_ = notification;
- NSRect rootFrame = NSMakeRect(0, 0,
- message_center::kNotificationPreferredImageWidth,
- message_center::kNotificationIconSize);
+ message_center::NotificationLayoutParams layoutParams;
+ layoutParams.rootFrame =
+ NSMakeRect(0, 0, message_center::kNotificationPreferredImageWidth,
+ message_center::kNotificationIconSize);
[smallImage_ setImage:notification_->small_image().AsNSImage()];
@@ -400,8 +401,10 @@
maxNumberOfLines:message_center::kMaxTitleLines
actualLines:&actualTitleLines])];
[title_ sizeToFit];
- NSRect titleFrame = [title_ frame];
- titleFrame.origin.y = NSMaxY(rootFrame) - titlePadding - NSHeight(titleFrame);
+ layoutParams.titleFrame = [title_ frame];
+ layoutParams.titleFrame.origin.y = NSMaxY(layoutParams.rootFrame) -
+ titlePadding -
+ NSHeight(layoutParams.titleFrame);
// The number of message lines depends on the number of context message lines
// and the lines within the title, and whether an image exists.
@@ -424,7 +427,7 @@
forFont:[message_ font]
maxNumberOfLines:messageLineLimit])];
[message_ sizeToFit];
- NSRect messageFrame = [message_ frame];
+ layoutParams.messageFrame = [message_ frame];
// If there are list items, then the message_ view should not be displayed.
const std::vector<message_center::NotificationItem>& items =
@@ -434,13 +437,14 @@
// space (size to fit leaves it 15 px tall.
if (items.size() > 0 || notification_->message().empty()) {
[message_ setHidden:YES];
- messageFrame.origin.y = titleFrame.origin.y;
- messageFrame.size.height = 0;
+ layoutParams.messageFrame.origin.y = layoutParams.titleFrame.origin.y;
+ layoutParams.messageFrame.size.height = 0;
} else {
[message_ setHidden:NO];
- messageFrame.origin.y =
- NSMinY(titleFrame) - messagePadding - NSHeight(messageFrame);
- messageFrame.size.height = NSHeight([message_ frame]);
+ layoutParams.messageFrame.origin.y = NSMinY(layoutParams.titleFrame) -
+ messagePadding -
+ NSHeight(layoutParams.messageFrame);
+ layoutParams.messageFrame.size.height = NSHeight([message_ frame]);
}
// Set the context message and recalculate the frame.
@@ -461,31 +465,46 @@
[contextMessage_ setString:base::SysUTF16ToNSString(elided)];
[contextMessage_ sizeToFit];
- NSRect contextMessageFrame = [contextMessage_ frame];
+ layoutParams.contextMessageFrame = [contextMessage_ frame];
if (notification->context_message().empty() &&
!notification->UseOriginAsContextMessage()) {
[contextMessage_ setHidden:YES];
- contextMessageFrame.origin.y = messageFrame.origin.y;
- contextMessageFrame.size.height = 0;
+ layoutParams.contextMessageFrame.origin.y =
+ layoutParams.messageFrame.origin.y;
+ layoutParams.contextMessageFrame.size.height = 0;
} else {
[contextMessage_ setHidden:NO];
- contextMessageFrame.origin.y =
- NSMinY(messageFrame) -
- contextMessagePadding -
- NSHeight(contextMessageFrame);
- contextMessageFrame.size.height = NSHeight([contextMessage_ frame]);
+
+ // If the context message is used as a domain make sure it's placed at the
+ // bottom of the top section.
+ CGFloat contextMessageY = NSMinY(layoutParams.messageFrame) -
+ contextMessagePadding -
+ NSHeight(layoutParams.contextMessageFrame);
+ layoutParams.contextMessageFrame.origin.y =
+ notification->UseOriginAsContextMessage()
+ ? std::min(NSMinY([icon_ frame]) + contextMessagePadding,
+ contextMessageY)
+ : contextMessageY;
+ layoutParams.contextMessageFrame.size.height =
+ NSHeight([contextMessage_ frame]);
}
- NSRect settingsButtonFrame = [settingsButton_ frame];
+
+ // Calculate the settings button position. It is dependent on whether the
+ // context message aligns or not with the icon.
+ layoutParams.settingsButtonFrame = [settingsButton_ frame];
+ layoutParams.settingsButtonFrame.origin.y =
+ MIN(NSMinY([icon_ frame]) + message_center::kSmallImagePadding,
+ NSMinY(layoutParams.contextMessageFrame));
// Create the list item views (up to a maximum).
[listView_ removeFromSuperview];
- NSRect listFrame = NSZeroRect;
+ layoutParams.listFrame = NSZeroRect;
if (items.size() > 0) {
- listFrame = [self currentContentRect];
- listFrame.origin.y = 0;
- listFrame.size.height = 0;
- listView_.reset([[NSView alloc] initWithFrame:listFrame]);
+ layoutParams.listFrame = [self currentContentRect];
+ layoutParams.listFrame.origin.y = 0;
+ layoutParams.listFrame.size.height = 0;
+ listView_.reset([[NSView alloc] initWithFrame:layoutParams.listFrame]);
[listView_ accessibilitySetOverrideValue:NSAccessibilityListRole
forAttribute:NSAccessibilityRoleAttribute];
[listView_
@@ -499,8 +518,9 @@
const int kNumNotifications =
std::min(items.size(), message_center::kNotificationMaximumItems);
for (int i = kNumNotifications - 1; i >= 0; --i) {
- NSTextView* itemView = [self newLabelWithFrame:
- NSMakeRect(0, y, NSWidth(listFrame), lineHeight)];
+ NSTextView* itemView = [self
+ newLabelWithFrame:NSMakeRect(0, y, NSWidth(layoutParams.listFrame),
+ lineHeight)];
[itemView setFont:font];
// Disable the word-wrap in order to show the text in single line.
@@ -538,24 +558,27 @@
// TODO(thakis): The spacing is not completely right.
CGFloat listTopPadding =
message_center::kTextTopPadding - contextMessageTopGap;
- listFrame.size.height = y;
- listFrame.origin.y =
- NSMinY(contextMessageFrame) - listTopPadding - NSHeight(listFrame);
- [listView_ setFrame:listFrame];
+ layoutParams.listFrame.size.height = y;
+ layoutParams.listFrame.origin.y = NSMinY(layoutParams.contextMessageFrame) -
+ listTopPadding -
+ NSHeight(layoutParams.listFrame);
+ [listView_ setFrame:layoutParams.listFrame];
[[self view] addSubview:listView_];
}
// Create the progress bar view if needed.
[progressBarView_ removeFromSuperview];
- NSRect progressBarFrame = NSZeroRect;
+ layoutParams.progressBarFrame = NSZeroRect;
if (notification->type() == message_center::NOTIFICATION_TYPE_PROGRESS) {
- progressBarFrame = [self currentContentRect];
- progressBarFrame.origin.y = NSMinY(contextMessageFrame) -
+ layoutParams.progressBarFrame = [self currentContentRect];
+ layoutParams.progressBarFrame.origin.y =
+ NSMinY(layoutParams.contextMessageFrame) -
message_center::kProgressBarTopPadding -
message_center::kProgressBarThickness;
- progressBarFrame.size.height = message_center::kProgressBarThickness;
- progressBarView_.reset(
- [[MCNotificationProgressBar alloc] initWithFrame:progressBarFrame]);
+ layoutParams.progressBarFrame.size.height =
+ message_center::kProgressBarThickness;
+ progressBarView_.reset([[MCNotificationProgressBar alloc]
+ initWithFrame:layoutParams.progressBarFrame]);
// Setting indeterminate to NO does not work with custom drawRect.
[progressBarView_ setIndeterminate:YES];
[progressBarView_ setStyle:NSProgressIndicatorBarStyle];
@@ -565,23 +588,18 @@
// If the bottom-most element so far is out of the rootView's bounds, resize
// the view.
- CGFloat minY = NSMinY(contextMessageFrame);
- if (listView_ && NSMinY(listFrame) < minY)
- minY = NSMinY(listFrame);
- if (progressBarView_ && NSMinY(progressBarFrame) < minY)
- minY = NSMinY(progressBarFrame);
+ CGFloat minY = NSMinY(layoutParams.contextMessageFrame);
+ if (listView_ && NSMinY(layoutParams.listFrame) < minY)
+ minY = NSMinY(layoutParams.listFrame);
+ if (progressBarView_ && NSMinY(layoutParams.progressBarFrame) < minY)
+ minY = NSMinY(layoutParams.progressBarFrame);
if (minY < messagePadding) {
CGFloat delta = messagePadding - minY;
- rootFrame.size.height += delta;
- titleFrame.origin.y += delta;
- messageFrame.origin.y += delta;
- contextMessageFrame.origin.y += delta;
- listFrame.origin.y += delta;
- progressBarFrame.origin.y += delta;
+ [self adjustFrameHeight:&layoutParams delta:delta];
}
// Add the bottom container view.
- NSRect frame = rootFrame;
+ NSRect frame = layoutParams.rootFrame;
frame.size.height = 0;
[bottomView_ removeFromSuperview];
bottomView_.reset([[NSView alloc] initWithFrame:frame]);
@@ -641,36 +659,26 @@
[bottomView_ setFrame:frame];
[[self view] addSubview:bottomView_];
-
- rootFrame.size.height += NSHeight(frame);
- titleFrame.origin.y += NSHeight(frame);
- messageFrame.origin.y += NSHeight(frame);
- contextMessageFrame.origin.y += NSHeight(frame);
- listFrame.origin.y += NSHeight(frame);
- progressBarFrame.origin.y += NSHeight(frame);
+ [self adjustFrameHeight:&layoutParams delta:NSHeight(frame)];
// Make sure that there is a minimum amount of spacing below the icon and
// the edge of the frame.
- CGFloat bottomDelta = NSHeight(rootFrame) - NSHeight([icon_ frame]);
+ CGFloat bottomDelta =
+ NSHeight(layoutParams.rootFrame) - NSHeight([icon_ frame]);
if (bottomDelta > 0 && bottomDelta < message_center::kIconBottomPadding) {
CGFloat bottomAdjust = message_center::kIconBottomPadding - bottomDelta;
- rootFrame.size.height += bottomAdjust;
- titleFrame.origin.y += bottomAdjust;
- messageFrame.origin.y += bottomAdjust;
- contextMessageFrame.origin.y += bottomAdjust;
- listFrame.origin.y += bottomAdjust;
- progressBarFrame.origin.y += bottomAdjust;
+ [self adjustFrameHeight:&layoutParams delta:bottomAdjust];
}
- [[self view] setFrame:rootFrame];
- [title_ setFrame:titleFrame];
- [message_ setFrame:messageFrame];
- [contextMessage_ setFrame:contextMessageFrame];
- [settingsButton_ setFrame:settingsButtonFrame];
- [listView_ setFrame:listFrame];
- [progressBarView_ setFrame:progressBarFrame];
+ [[self view] setFrame:layoutParams.rootFrame];
+ [title_ setFrame:layoutParams.titleFrame];
+ [message_ setFrame:layoutParams.messageFrame];
+ [contextMessage_ setFrame:layoutParams.contextMessageFrame];
+ [settingsButton_ setFrame:layoutParams.settingsButtonFrame];
+ [listView_ setFrame:layoutParams.listFrame];
+ [progressBarView_ setFrame:layoutParams.progressBarFrame];
- return rootFrame;
+ return layoutParams.rootFrame;
}
- (void)close:(id)sender {
@@ -699,6 +707,17 @@
messageCenter_->ClickOnNotification([self notificationID]);
}
+- (void)adjustFrameHeight:(message_center::NotificationLayoutParams*)frames
+ delta:(CGFloat)delta {
+ frames->rootFrame.size.height += delta;
+ frames->titleFrame.origin.y += delta;
+ frames->messageFrame.origin.y += delta;
+ frames->contextMessageFrame.origin.y += delta;
+ frames->settingsButtonFrame.origin.y += delta;
+ frames->listFrame.origin.y += delta;
+ frames->progressBarFrame.origin.y += delta;
+}
+
// Private /////////////////////////////////////////////////////////////////////
- (void)configureCustomBox:(NSBox*)box {