| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" |
| 11 #include "chrome/browser/global_keyboard_shortcuts_mac.h" | 11 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
| 12 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 12 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 13 #include "chrome/browser/themes/theme_properties.h" | 13 #include "chrome/browser/themes/theme_properties.h" |
| 14 #include "chrome/browser/themes/theme_service.h" | 14 #include "chrome/browser/themes/theme_service.h" |
| 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 16 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | 16 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
| 17 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 17 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 18 #import "chrome/browser/ui/cocoa/themed_window.h" | 18 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 19 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
| 20 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 20 #include "ui/base/cocoa/nsgraphics_context_additions.h" | 21 #include "ui/base/cocoa/nsgraphics_context_additions.h" |
| 21 #import "ui/base/cocoa/nsview_additions.h" | 22 #import "ui/base/cocoa/nsview_additions.h" |
| 22 #include "ui/base/material_design/material_design_controller.h" | 23 #include "ui/base/material_design/material_design_controller.h" |
| 23 | 24 |
| 24 // Implementer's note: Moving the window controls is tricky. When altering the | 25 // Implementer's note: Moving the window controls is tricky. When altering the |
| 25 // code, ensure that: | 26 // code, ensure that: |
| 26 // - accessibility hit testing works | 27 // - accessibility hit testing works |
| 27 // - the accessibility hierarchy is correct | 28 // - the accessibility hierarchy is correct |
| 28 // - close/min in the background don't bring the window forward | 29 // - close/min in the background don't bring the window forward |
| 29 // - rollover effects work correctly | 30 // - rollover effects work correctly |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 161 |
| 161 BOOL didPost = [button postsBoundsChangedNotifications]; | 162 BOOL didPost = [button postsBoundsChangedNotifications]; |
| 162 [button setPostsFrameChangedNotifications:NO]; | 163 [button setPostsFrameChangedNotifications:NO]; |
| 163 [button setFrame:buttonFrame]; | 164 [button setFrame:buttonFrame]; |
| 164 [button setPostsFrameChangedNotifications:didPost]; | 165 [button setPostsFrameChangedNotifications:didPost]; |
| 165 } | 166 } |
| 166 | 167 |
| 167 // The tab strip view covers our window buttons. So we add hit testing here | 168 // The tab strip view covers our window buttons. So we add hit testing here |
| 168 // to find them properly and return them to the accessibility system. | 169 // to find them properly and return them to the accessibility system. |
| 169 - (id)accessibilityHitTest:(NSPoint)point { | 170 - (id)accessibilityHitTest:(NSPoint)point { |
| 170 NSPoint windowPoint = [self convertScreenToBase:point]; | 171 NSPoint windowPoint = ui::ConvertPointFromScreenToWindow(self, point); |
| 171 NSControl* controls[] = { closeButton_, zoomButton_, miniaturizeButton_ }; | 172 NSControl* controls[] = { closeButton_, zoomButton_, miniaturizeButton_ }; |
| 172 id value = nil; | 173 id value = nil; |
| 173 for (size_t i = 0; i < sizeof(controls) / sizeof(controls[0]); ++i) { | 174 for (size_t i = 0; i < sizeof(controls) / sizeof(controls[0]); ++i) { |
| 174 if (NSPointInRect(windowPoint, [controls[i] frame])) { | 175 if (NSPointInRect(windowPoint, [controls[i] frame])) { |
| 175 value = [controls[i] accessibilityHitTest:point]; | 176 value = [controls[i] accessibilityHitTest:point]; |
| 176 break; | 177 break; |
| 177 } | 178 } |
| 178 } | 179 } |
| 179 if (!value) { | 180 if (!value) { |
| 180 value = [super accessibilityHitTest:point]; | 181 value = [super accessibilityHitTest:point]; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 ThemedWindowStyle windowStyle = [self themedWindowStyle]; | 353 ThemedWindowStyle windowStyle = [self themedWindowStyle]; |
| 353 BOOL incognito = windowStyle & THEMED_INCOGNITO; | 354 BOOL incognito = windowStyle & THEMED_INCOGNITO; |
| 354 | 355 |
| 355 if (incognito) | 356 if (incognito) |
| 356 return [NSColor whiteColor]; | 357 return [NSColor whiteColor]; |
| 357 else | 358 else |
| 358 return [NSColor windowFrameTextColor]; | 359 return [NSColor windowFrameTextColor]; |
| 359 } | 360 } |
| 360 | 361 |
| 361 @end | 362 @end |
| OLD | NEW |