mas_blink_no_private_api.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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_blink_no_private_api.patch
  5. Guard usages in chromium code of private Mac APIs by MAS_BUILD, so they can
  6. be excluded for people who want to submit their apps to the Mac App store.
  7. diff --git a/third_party/blink/renderer/core/editing/kill_ring_mac.mm b/third_party/blink/renderer/core/editing/kill_ring_mac.mm
  8. index 94afefcee81b87c05bf9b1199d90d3d4b5ea84a6..2ec7f04c71824b47de1ddbf1f0e8625d33e833a8 100644
  9. --- a/third_party/blink/renderer/core/editing/kill_ring_mac.mm
  10. +++ b/third_party/blink/renderer/core/editing/kill_ring_mac.mm
  11. @@ -27,6 +27,7 @@
  12. namespace blink {
  13. +#ifndef MAS_BUILD
  14. extern "C" {
  15. // Kill ring calls. Would be better to use NSKillRing.h, but that's not
  16. @@ -39,38 +40,53 @@ NSString* _NSYankFromKillRing();
  17. void _NSNewKillRingSequence();
  18. void _NSSetKillRingToYankedState();
  19. }
  20. +#endif
  21. static void InitializeKillRingIfNeeded() {
  22. static bool initialized_kill_ring = false;
  23. if (!initialized_kill_ring) {
  24. initialized_kill_ring = true;
  25. +#ifndef MAS_BUILD
  26. _NSInitializeKillRing();
  27. +#endif
  28. }
  29. }
  30. void KillRing::Append(const String& string) {
  31. InitializeKillRingIfNeeded();
  32. +#ifndef MAS_BUILD
  33. _NSAppendToKillRing(string);
  34. +#endif
  35. }
  36. void KillRing::Prepend(const String& string) {
  37. InitializeKillRingIfNeeded();
  38. +#ifndef MAS_BUILD
  39. _NSPrependToKillRing(string);
  40. +#endif
  41. }
  42. String KillRing::Yank() {
  43. InitializeKillRingIfNeeded();
  44. +#ifndef MAS_BUILD
  45. return _NSYankFromKillRing();
  46. +#else
  47. + return "";
  48. +#endif
  49. }
  50. void KillRing::StartNewSequence() {
  51. InitializeKillRingIfNeeded();
  52. +#ifndef MAS_BUILD
  53. _NSNewKillRingSequence();
  54. +#endif
  55. }
  56. void KillRing::SetToYankedState() {
  57. InitializeKillRingIfNeeded();
  58. +#ifndef MAS_BUILD
  59. _NSSetKillRingToYankedState();
  60. +#endif
  61. }
  62. } // namespace blink
  63. diff --git a/third_party/blink/renderer/core/paint/theme_painter_mac.mm b/third_party/blink/renderer/core/paint/theme_painter_mac.mm
  64. index e965faf9fd8d5ec3572d769421f149907d66c67f..b2d0bbd80994fdf9607009d9e27bf4c3629fe402 100644
  65. --- a/third_party/blink/renderer/core/paint/theme_painter_mac.mm
  66. +++ b/third_party/blink/renderer/core/paint/theme_painter_mac.mm
  67. @@ -41,6 +41,7 @@
  68. // The methods in this file are specific to the Mac OS X platform.
  69. +#ifndef MAS_BUILD
  70. // Forward declare Mac SPIs.
  71. extern "C" {
  72. void _NSDrawCarbonThemeBezel(NSRect frame, BOOL enabled, BOOL flipped);
  73. @@ -50,6 +51,7 @@ void _NSDrawCarbonThemeListBox(NSRect frame,
  74. BOOL flipped,
  75. BOOL always_yes);
  76. }
  77. +#endif
  78. namespace blink {
  79. @@ -72,10 +74,12 @@ bool ThemePainterMac::PaintTextField(const Node* node,
  80. // behavior change while remaining a fragile solution.
  81. // https://bugs.chromium.org/p/chromium/issues/detail?id=658085#c3
  82. if (!use_ns_text_field_cell) {
  83. +#ifndef MAS_BUILD
  84. _NSDrawCarbonThemeBezel(
  85. CGRect(r),
  86. LayoutTheme::IsEnabled(node) && !LayoutTheme::IsReadOnlyControl(node),
  87. YES);
  88. +#endif
  89. return false;
  90. }
  91. @@ -161,10 +165,12 @@ bool ThemePainterMac::PaintTextArea(const Node* node,
  92. const PaintInfo& paint_info,
  93. const IntRect& r) {
  94. LocalCurrentGraphicsContext local_context(paint_info.context, r);
  95. +#ifndef MAS_BUILD
  96. _NSDrawCarbonThemeListBox(
  97. CGRect(r),
  98. LayoutTheme::IsEnabled(node) && !LayoutTheme::IsReadOnlyControl(node),
  99. YES, YES);
  100. +#endif
  101. return false;
  102. }