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

Side by Side Diff: chrome/browser/ui/cocoa/framed_browser_window.mm

Issue 2555033003: Add ScopedMacRTL class for Cocoa browser RTL testing (Closed)
Patch Set: Whitespace Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/ui/cocoa/framed_browser_window.h" 5 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <objc/runtime.h> 8 #include <objc/runtime.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/mac/sdk_forward_declarations.h" 12 #include "base/mac/sdk_forward_declarations.h"
13 #include "chrome/browser/global_keyboard_shortcuts_mac.h" 13 #include "chrome/browser/global_keyboard_shortcuts_mac.h"
14 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 14 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
15 #include "chrome/browser/themes/theme_properties.h" 15 #include "chrome/browser/themes/theme_properties.h"
16 #include "chrome/browser/themes/theme_service.h" 16 #include "chrome/browser/themes/theme_service.h"
17 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 17 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
18 #import "chrome/browser/ui/cocoa/browser_window_layout.h" 18 #import "chrome/browser/ui/cocoa/browser_window_layout.h"
19 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 19 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
20 #include "chrome/browser/ui/cocoa/l10n_util.h"
21 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 20 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
22 #import "chrome/browser/ui/cocoa/themed_window.h" 21 #import "chrome/browser/ui/cocoa/themed_window.h"
23 #include "chrome/grit/theme_resources.h" 22 #include "chrome/grit/theme_resources.h"
24 #include "ui/base/cocoa/cocoa_base_utils.h" 23 #include "ui/base/cocoa/cocoa_base_utils.h"
25 #include "ui/base/cocoa/nsgraphics_context_additions.h" 24 #include "ui/base/cocoa/nsgraphics_context_additions.h"
26 #import "ui/base/cocoa/nsview_additions.h" 25 #import "ui/base/cocoa/nsview_additions.h"
26 #import "ui/base/cocoa/rtl_feature.h"
27 #include "ui/base/material_design/material_design_controller.h" 27 #include "ui/base/material_design/material_design_controller.h"
28 28
29 // Implementer's note: Moving the window controls is tricky. When altering the 29 // Implementer's note: Moving the window controls is tricky. When altering the
30 // code, ensure that: 30 // code, ensure that:
31 // - accessibility hit testing works 31 // - accessibility hit testing works
32 // - the accessibility hierarchy is correct 32 // - the accessibility hierarchy is correct
33 // - close/min in the background don't bring the window forward 33 // - close/min in the background don't bring the window forward
34 // - rollover effects work correctly 34 // - rollover effects work correctly
35 35
36 // The NSLayoutConstraint class hierarchy only exists in the 10.11 SDK. When 36 // The NSLayoutConstraint class hierarchy only exists in the 10.11 SDK. When
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 toButton:(NSWindowButton)buttonType { 268 toButton:(NSWindowButton)buttonType {
269 DCHECK(chrome::ShouldUseFullSizeContentView()); 269 DCHECK(chrome::ShouldUseFullSizeContentView());
270 270
271 NSButton* button = [self standardWindowButton:buttonType]; 271 NSButton* button = [self standardWindowButton:buttonType];
272 [button setTranslatesAutoresizingMaskIntoConstraints:NO]; 272 [button setTranslatesAutoresizingMaskIntoConstraints:NO];
273 273
274 // Do not use leadingAnchor because |ShouldFlipWindowControlsInRTL| 274 // Do not use leadingAnchor because |ShouldFlipWindowControlsInRTL|
275 // should determine if current locale is RTL. 275 // should determine if current locale is RTL.
276 NSLayoutXAxisAnchor* leadingSourceAnchor = [button leftAnchor]; 276 NSLayoutXAxisAnchor* leadingSourceAnchor = [button leftAnchor];
277 NSLayoutXAxisAnchor* leadingTargetAnchor = [[button superview] leftAnchor]; 277 NSLayoutXAxisAnchor* leadingTargetAnchor = [[button superview] leftAnchor];
278 if (cocoa_l10n_util::ShouldFlipWindowControlsInRTL()) { 278 if (ui::ShouldFlipWindowControlsInRTL()) {
279 leadingSourceAnchor = [button rightAnchor]; 279 leadingSourceAnchor = [button rightAnchor];
280 leadingTargetAnchor = [[button superview] rightAnchor]; 280 leadingTargetAnchor = [[button superview] rightAnchor];
281 leadingOffset = -leadingOffset; 281 leadingOffset = -leadingOffset;
282 } 282 }
283 283
284 #if !defined(MAC_OS_X_VERSION_10_11) || \ 284 #if !defined(MAC_OS_X_VERSION_10_11) || \
285 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 285 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11
286 id leadingSourceAnchorDuck = leadingSourceAnchor; 286 id leadingSourceAnchorDuck = leadingSourceAnchor;
287 #else 287 #else
288 NSLayoutXAxisAnchor* leadingSourceAnchorDuck = leadingSourceAnchor; 288 NSLayoutXAxisAnchor* leadingSourceAnchorDuck = leadingSourceAnchor;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 buttonFrame.origin.x += windowButtonsInterButtonSpacing_; 331 buttonFrame.origin.x += windowButtonsInterButtonSpacing_;
332 // fallthrough 332 // fallthrough
333 case NSWindowMiniaturizeButton: 333 case NSWindowMiniaturizeButton:
334 buttonFrame.origin.x += NSWidth([closeButton_ frame]); 334 buttonFrame.origin.x += NSWidth([closeButton_ frame]);
335 buttonFrame.origin.x += windowButtonsInterButtonSpacing_; 335 buttonFrame.origin.x += windowButtonsInterButtonSpacing_;
336 // fallthrough 336 // fallthrough
337 default: 337 default:
338 break; 338 break;
339 } 339 }
340 340
341 if (cocoa_l10n_util::ShouldFlipWindowControlsInRTL()) { 341 if (ui::ShouldFlipWindowControlsInRTL()) {
342 buttonFrame.origin.x = 342 buttonFrame.origin.x =
343 NSWidth([self frame]) - buttonFrame.origin.x - NSWidth([button frame]); 343 NSWidth([self frame]) - buttonFrame.origin.x - NSWidth([button frame]);
344 } 344 }
345 345
346 BOOL didPost = [button postsBoundsChangedNotifications]; 346 BOOL didPost = [button postsBoundsChangedNotifications];
347 [button setPostsFrameChangedNotifications:NO]; 347 [button setPostsFrameChangedNotifications:NO];
348 [button setFrame:buttonFrame]; 348 [button setFrame:buttonFrame];
349 [button setPostsFrameChangedNotifications:didPost]; 349 [button setPostsFrameChangedNotifications:didPost];
350 } 350 }
351 351
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 [self childWindowsDidChange]; 525 [self childWindowsDidChange];
526 } 526 }
527 527
528 - (void)childWindowsDidChange { 528 - (void)childWindowsDidChange {
529 id delegate = [self delegate]; 529 id delegate = [self delegate];
530 if ([delegate respondsToSelector:@selector(childWindowsDidChange)]) 530 if ([delegate respondsToSelector:@selector(childWindowsDidChange)])
531 [delegate childWindowsDidChange]; 531 [delegate childWindowsDidChange];
532 } 532 }
533 533
534 @end 534 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698