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

Unified Diff: chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.mm

Issue 2772383002: [Mac] Fix keyword hint spacing in RTL (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.mm b/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.mm
index 4bfbe28d068caf4c62fda62df4534b42277d0af1..affe1e33fc7e03b82e5af876de3f618c7620b15c 100644
--- a/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.mm
@@ -31,6 +31,9 @@ const CGFloat kHintImagePadding = 1.0;
// Should leave enough so that the user has space to edit things.
const CGFloat kHintAvailableRatio = 2.0 / 3.0;
+// Extra padding at the right of the decoration.
+const CGFloat kHintTrailingPadding = 5.0;
+
// Helper to convert |s| to an |NSString|, trimming whitespace at
// ends.
NSString* TrimAndConvert(const base::string16& s) {
@@ -103,7 +106,8 @@ CGFloat KeywordHintDecoration::GetWidthForSpace(CGFloat width) {
CGFloat full_width =
std::floor(GetLabelSize(hint_prefix_, attributes_).width + 0.5) +
kHintImagePadding + image_width + kHintImagePadding +
- std::floor(GetLabelSize(hint_suffix_, attributes_).width + 0.5);
+ std::floor(GetLabelSize(hint_suffix_, attributes_).width + 0.5) +
+ kHintTrailingPadding;
if (full_width <= width * kHintAvailableRatio)
return full_width;
@@ -119,6 +123,10 @@ void KeywordHintDecoration::DrawInFrame(NSRect frame, NSView* control_view) {
BOOL is_rtl = cocoa_l10n_util::ShouldDoExperimentalRTLLayout();
NSString* left_string = is_rtl ? hint_suffix_ : hint_prefix_;
NSString* right_string = is_rtl ? hint_prefix_ : hint_suffix_;
+ if (is_rtl) {
+ frame.origin.x += kHintTrailingPadding;
+ frame.size.width -= kHintTrailingPadding;
+ }
if (draw_full) {
NSRect left_rect = frame;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698