| OLD | NEW | 
|    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  | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   51 const CGFloat kWindowGradientHeight = 24.0; |   51 const CGFloat kWindowGradientHeight = 24.0; | 
|   52  |   52  | 
|   53 } |   53 } | 
|   54  |   54  | 
|   55 @interface FramedBrowserWindow (Private) |   55 @interface FramedBrowserWindow (Private) | 
|   56  |   56  | 
|   57 // Updates the title bar's frame so it moves the windows buttons to correct |   57 // Updates the title bar's frame so it moves the windows buttons to correct | 
|   58 // location (frame bottom is moved down so the buttons are moved down as well). |   58 // location (frame bottom is moved down so the buttons are moved down as well). | 
|   59 - (void)adjustTitlebarContainer:(NSView*)titlebarContainer; |   59 - (void)adjustTitlebarContainer:(NSView*)titlebarContainer; | 
|   60 // Adds layout constraints to window buttons, respecting flag returned by |   60 // Adds layout constraints to window buttons, respecting flag returned by | 
|   61 // |ShouldDoExperimentalRTLLayout| method. |   61 // |ShouldFlipWindowControlsInRTL| method. | 
|   62 - (void)setWindowButtonsConstraints; |   62 - (void)setWindowButtonsConstraints; | 
|   63 // Replaces -[NSThemeFrame addTrackingArea:] with implementation that ignores |   63 // Replaces -[NSThemeFrame addTrackingArea:] with implementation that ignores | 
|   64 // tracking rect if its size is the same as the size of window buttons rect |   64 // tracking rect if its size is the same as the size of window buttons rect | 
|   65 // (rect where close, miniaturize and zoom buttons are located). This is |   65 // (rect where close, miniaturize and zoom buttons are located). This is | 
|   66 // needed to workaround macOS bug (rdar://28535344) which unnecessarily adds |   66 // needed to workaround macOS bug (rdar://28535344) which unnecessarily adds | 
|   67 // window buttons tracking rect even if those buttons were moved. |   67 // window buttons tracking rect even if those buttons were moved. | 
|   68 // TODO(crbug.com/651287): Remove this workaround once macOS bug is fixed. |   68 // TODO(crbug.com/651287): Remove this workaround once macOS bug is fixed. | 
|   69 - (void)forbidAddingWindowButtonsTrackingArea; |   69 - (void)forbidAddingWindowButtonsTrackingArea; | 
|   70 // Called when titlebar container changes its frame. This method adjusts |   70 // Called when titlebar container changes its frame. This method adjusts | 
|   71 // titlebar container with correct frame. |   71 // titlebar container with correct frame. | 
|   72 - (void)titlebarDidChangeFrameNotification:(NSNotification*)notification; |   72 - (void)titlebarDidChangeFrameNotification:(NSNotification*)notification; | 
|   73 // Adds layout constraints to the given window button so it displayed at correct |   73 // Adds layout constraints to the given window button so it displayed at correct | 
|   74 // location. This respects flag returned by |ShouldDoExperimentalRTLLayout| |   74 // location. This respects flag returned by |ShouldFlipWindowControlsInRTL| | 
|   75 // method. |   75 // method. | 
|   76 - (void)setLeadingOffset:(CGFloat)leadingOffset |   76 - (void)setLeadingOffset:(CGFloat)leadingOffset | 
|   77                 toButton:(NSWindowButton)buttonType; |   77                 toButton:(NSWindowButton)buttonType; | 
|   78  |   78  | 
|   79 - (void)adjustCloseButton:(NSNotification*)notification; |   79 - (void)adjustCloseButton:(NSNotification*)notification; | 
|   80 - (void)adjustMiniaturizeButton:(NSNotification*)notification; |   80 - (void)adjustMiniaturizeButton:(NSNotification*)notification; | 
|   81 - (void)adjustZoomButton:(NSNotification*)notification; |   81 - (void)adjustZoomButton:(NSNotification*)notification; | 
|   82 - (void)adjustButton:(NSButton*)button |   82 - (void)adjustButton:(NSButton*)button | 
|   83               ofKind:(NSWindowButton)kind; |   83               ofKind:(NSWindowButton)kind; | 
|   84 - (void)childWindowsDidChange; |   84 - (void)childWindowsDidChange; | 
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  264   [self adjustTitlebarContainer:[notification object]]; |  264   [self adjustTitlebarContainer:[notification object]]; | 
|  265 } |  265 } | 
|  266  |  266  | 
|  267 - (void)setLeadingOffset:(CGFloat)leadingOffset |  267 - (void)setLeadingOffset:(CGFloat)leadingOffset | 
|  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 |ShouldDoExperimentalRTLLayout| |  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::ShouldDoExperimentalRTLLayout()) { |  278   if (cocoa_l10n_util::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  Loading... | 
|  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::ShouldDoExperimentalRTLLayout()) { |  341   if (cocoa_l10n_util::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  Loading... | 
|  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 | 
| OLD | NEW |