mas_disable_custom_window_frame.patch 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Cheng Zhao <[email protected]>
  3. Date: Thu, 20 Sep 2018 17:48:49 -0700
  4. Subject: mas_disable_custom_window_frame.patch
  5. Disable private window frame APIs (NSNextStepFrame and NSThemeFrame) for MAS
  6. build.
  7. diff --git a/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm b/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
  8. index 2cd283de6677f0c256940ab475eb6c58d8040f54..ad7f1f0c05b491977ccd5650c94248e876ad2b0e 100644
  9. --- a/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
  10. +++ b/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
  11. @@ -9,6 +9,7 @@
  12. #include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
  13. #include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
  14. +#ifndef MAS_BUILD
  15. @interface NSWindow (PrivateBrowserNativeWidgetAPI)
  16. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
  17. @end
  18. @@ -63,6 +64,8 @@
  19. @end
  20. +#endif // MAS_BUILD
  21. +
  22. @implementation BrowserNativeWidgetWindow
  23. // Prevent detached tabs from glitching when the window is partially offscreen.
  24. @@ -88,6 +91,7 @@
  25. // NSWindow (PrivateAPI) overrides.
  26. +#ifndef MAS_BUILD
  27. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
  28. // - NSThemeFrame and its subclasses will be nil if it's missing at runtime.
  29. if ([BrowserWindowFrame class])
  30. @@ -102,6 +106,8 @@
  31. return NO;
  32. }
  33. +#endif // MAS_BUILD
  34. +
  35. // Handle "Move focus to the window toolbar" configured in System Preferences ->
  36. // Keyboard -> Shortcuts -> Keyboard. Usually Ctrl+F5. The argument (|unknown|)
  37. // tends to just be nil.
  38. diff --git a/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
  39. index 8416c7c6e052dafb2aad61c0bd3224c36e945d23..cd356beda023ab2409b16d58ca38c70ba3674913 100644
  40. --- a/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
  41. +++ b/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
  42. @@ -4,6 +4,8 @@
  43. #import "components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.h"
  44. +#ifndef MAS_BUILD
  45. +
  46. @interface NSWindow (PrivateAPI)
  47. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
  48. @end
  49. @@ -18,8 +20,12 @@
  50. }
  51. @end
  52. +#endif // MAS_BUILD
  53. +
  54. @implementation NativeWidgetMacFramelessNSWindow
  55. +#ifndef MAS_BUILD
  56. +
  57. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
  58. if ([NativeWidgetMacFramelessNSWindowFrame class]) {
  59. return [NativeWidgetMacFramelessNSWindowFrame class];
  60. @@ -27,4 +33,6 @@
  61. return [super frameViewClassForStyleMask:windowStyle];
  62. }
  63. +#endif // MAS_BUILD
  64. +
  65. @end
  66. diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
  67. index e03bbc724cfd01967e71998394361556df1c4915..783745b11365c04c1e1052197d20d494bc901d45 100644
  68. --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
  69. +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
  70. @@ -17,6 +17,7 @@ class NativeWidgetNSWindowBridge;
  71. @protocol WindowTouchBarDelegate;
  72. +#ifndef MAS_BUILD
  73. // Weak lets Chrome launch even if a future macOS doesn't have the below classes
  74. WEAK_IMPORT_ATTRIBUTE
  75. @interface NSNextStepFrame : NSView
  76. @@ -33,6 +34,7 @@ REMOTE_COCOA_APP_SHIM_EXPORT
  77. REMOTE_COCOA_APP_SHIM_EXPORT
  78. @interface NativeWidgetMacNSWindowTitledFrame : NSThemeFrame
  79. @end
  80. +#endif
  81. // The NSWindow used by BridgedNativeWidget. Provides hooks into AppKit that
  82. // can only be accomplished by overriding methods.
  83. diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
  84. index 757c72d98de11f611309f4f5af8d0d9aab639181..a6319a0760308df6bac6b39ad3500ad77c1b6525 100644
  85. --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
  86. +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
  87. @@ -16,7 +16,9 @@
  88. #import "ui/base/cocoa/window_size_constants.h"
  89. @interface NSWindow (Private)
  90. +#ifndef MAS_BUILD
  91. + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle;
  92. +#endif
  93. - (BOOL)hasKeyAppearance;
  94. - (long long)_resizeDirectionForMouseLocation:(CGPoint)location;
  95. - (BOOL)_isConsideredOpenForPersistentState;
  96. @@ -58,6 +60,8 @@
  97. }
  98. @end
  99. +#ifndef MAS_BUILD
  100. +
  101. @implementation NativeWidgetMacNSWindowTitledFrame
  102. - (void)mouseDown:(NSEvent*)event {
  103. if (base::mac::IsAtMostOS10_11() && self.window.isMovable)
  104. @@ -84,6 +88,8 @@
  105. }
  106. @end
  107. +#endif // MAS_BUILD
  108. +
  109. @implementation NativeWidgetMacNSWindow {
  110. @private
  111. base::scoped_nsobject<CommandDispatcher> _commandDispatcher;
  112. @@ -165,6 +171,8 @@
  113. // NSWindow overrides.
  114. +#ifndef MAS_BUILD
  115. +
  116. + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
  117. if (windowStyle & NSWindowStyleMaskTitled) {
  118. if (Class customFrame = [NativeWidgetMacNSWindowTitledFrame class])
  119. @@ -176,6 +184,8 @@
  120. return [super frameViewClassForStyleMask:windowStyle];
  121. }
  122. +#endif
  123. +
  124. - (BOOL)_isTitleHidden {
  125. bool shouldShowWindowTitle = YES;
  126. if (_bridge)