| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/ui/history/tab_history_popup_controller.h" | 5 #import "ios/chrome/browser/ui/history/tab_history_popup_controller.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/bundle_locations.h" | 10 #include "base/mac/bundle_locations.h" |
| 11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 12 #import "ios/chrome/browser/ui/history/tab_history_view_controller.h" | 12 #import "ios/chrome/browser/ui/history/tab_history_view_controller.h" |
| 13 #import "ios/chrome/browser/ui/popup_menu/popup_menu_view.h" | 13 #import "ios/chrome/browser/ui/popup_menu/popup_menu_view.h" |
| 14 #include "ios/chrome/browser/ui/rtl_geometry.h" | 14 #include "ios/chrome/browser/ui/rtl_geometry.h" |
| 15 #include "ios/chrome/browser/ui/ui_util.h" | 15 #include "ios/chrome/browser/ui/ui_util.h" |
| 16 #import "ios/chrome/common/material_timing.h" | 16 #import "ios/chrome/common/material_timing.h" |
| 17 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 17 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 18 #include "ios/web/public/navigation_item.h" | 18 #include "ios/web/public/navigation_item.h" |
| 19 #import "ui/gfx/ios/NSString+CrStringDrawing.h" | 19 #import "ui/gfx/ios/NSString+CrStringDrawing.h" |
| 20 #include "ui/gfx/ios/uikit_util.h" | 20 #include "ui/gfx/ios/uikit_util.h" |
| 21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 22 | 22 |
| 23 #if !defined(__has_feature) || !__has_feature(objc_arc) | 23 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 24 #error "This file requires ARC support." | 24 #error "This file requires ARC support." |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 if (UIInterfaceOrientationIsPortrait(orientation)) | 138 if (UIInterfaceOrientationIsPortrait(orientation)) |
| 139 return kTabHistoryMinWidth; | 139 return kTabHistoryMinWidth; |
| 140 maxWidth = kTabHistoryMaxWidthLandscapePhone; | 140 maxWidth = kTabHistoryMaxWidthLandscapePhone; |
| 141 } else { | 141 } else { |
| 142 // On iPad use 85% of the available width. | 142 // On iPad use 85% of the available width. |
| 143 maxWidth = ui::AlignValueToUpperPixel( | 143 maxWidth = ui::AlignValueToUpperPixel( |
| 144 [UIApplication sharedApplication].keyWindow.frame.size.width * .85); | 144 [UIApplication sharedApplication].keyWindow.frame.size.width * .85); |
| 145 } | 145 } |
| 146 // Increase the width to fit the text to display but don't exceed maxWidth. | 146 // Increase the width to fit the text to display but don't exceed maxWidth. |
| 147 CGFloat cellWidth = kTabHistoryMinWidth; | 147 CGFloat cellWidth = kTabHistoryMinWidth; |
| 148 UIFont* font = [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:16]; | 148 UIFont* font = [[MDCTypography fontLoader] regularFontOfSize:16]; |
| 149 for (web::NavigationItem* item : items) { | 149 for (web::NavigationItem* item : items) { |
| 150 // TODO(rohitrao): Can this be replaced with GetTitleForDisplay()? | 150 // TODO(rohitrao): Can this be replaced with GetTitleForDisplay()? |
| 151 NSString* cellText = item->GetTitle().empty() | 151 NSString* cellText = item->GetTitle().empty() |
| 152 ? base::SysUTF8ToNSString(item->GetURL().spec()) | 152 ? base::SysUTF8ToNSString(item->GetURL().spec()) |
| 153 : base::SysUTF16ToNSString(item->GetTitle()); | 153 : base::SysUTF16ToNSString(item->GetTitle()); |
| 154 CGFloat contentWidth = [cellText cr_pixelAlignedSizeWithFont:font].width + | 154 CGFloat contentWidth = [cellText cr_pixelAlignedSizeWithFont:font].width + |
| 155 kCellTextXCoordinate; | 155 kCellTextXCoordinate; |
| 156 | 156 |
| 157 // If contentWidth is larger than maxWidth, return maxWidth instead of | 157 // If contentWidth is larger than maxWidth, return maxWidth instead of |
| 158 // checking the rest of the items. | 158 // checking the rest of the items. |
| 159 if (contentWidth > maxWidth) | 159 if (contentWidth > maxWidth) |
| 160 return maxWidth; | 160 return maxWidth; |
| 161 if (contentWidth > cellWidth) | 161 if (contentWidth > cellWidth) |
| 162 cellWidth = contentWidth; | 162 cellWidth = contentWidth; |
| 163 } | 163 } |
| 164 return cellWidth; | 164 return cellWidth; |
| 165 } | 165 } |
| 166 | 166 |
| 167 @end | 167 @end |
| OLD | NEW |