electron/patches/chromium/mas_blink_no_private_api.patch
2020-04-08 08:59:14 -07:00

120 lines
3.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Thu, 20 Sep 2018 17:48:49 -0700
Subject: mas_blink_no_private_api.patch
Guard usages in chromium code of private Mac APIs by MAS_BUILD, so they can
be excluded for people who want to submit their apps to the Mac App store.
diff --git a/third_party/blink/renderer/core/editing/kill_ring_mac.mm b/third_party/blink/renderer/core/editing/kill_ring_mac.mm
index 94afefcee81b87c05bf9b1199d90d3d4b5ea84a6..2ec7f04c71824b47de1ddbf1f0e8625d33e833a8 100644
--- a/third_party/blink/renderer/core/editing/kill_ring_mac.mm
+++ b/third_party/blink/renderer/core/editing/kill_ring_mac.mm
@@ -27,6 +27,7 @@
namespace blink {
+#ifndef MAS_BUILD
extern "C" {
// Kill ring calls. Would be better to use NSKillRing.h, but that's not
@@ -39,38 +40,53 @@ NSString* _NSYankFromKillRing();
void _NSNewKillRingSequence();
void _NSSetKillRingToYankedState();
}
+#endif
static void InitializeKillRingIfNeeded() {
static bool initialized_kill_ring = false;
if (!initialized_kill_ring) {
initialized_kill_ring = true;
+#ifndef MAS_BUILD
_NSInitializeKillRing();
+#endif
}
}
void KillRing::Append(const String& string) {
InitializeKillRingIfNeeded();
+#ifndef MAS_BUILD
_NSAppendToKillRing(string);
+#endif
}
void KillRing::Prepend(const String& string) {
InitializeKillRingIfNeeded();
+#ifndef MAS_BUILD
_NSPrependToKillRing(string);
+#endif
}
String KillRing::Yank() {
InitializeKillRingIfNeeded();
+#ifndef MAS_BUILD
return _NSYankFromKillRing();
+#else
+ return "";
+#endif
}
void KillRing::StartNewSequence() {
InitializeKillRingIfNeeded();
+#ifndef MAS_BUILD
_NSNewKillRingSequence();
+#endif
}
void KillRing::SetToYankedState() {
InitializeKillRingIfNeeded();
+#ifndef MAS_BUILD
_NSSetKillRingToYankedState();
+#endif
}
} // namespace blink
diff --git a/third_party/blink/renderer/core/paint/theme_painter_mac.mm b/third_party/blink/renderer/core/paint/theme_painter_mac.mm
index 8f4ae94bc1d8188d041654c50511f3346eee79de..fa06f47abbff3dcda937bf0b794f616e4818cd30 100644
--- a/third_party/blink/renderer/core/paint/theme_painter_mac.mm
+++ b/third_party/blink/renderer/core/paint/theme_painter_mac.mm
@@ -41,6 +41,7 @@
// The methods in this file are specific to the Mac OS X platform.
+#ifndef MAS_BUILD
// Forward declare Mac SPIs.
extern "C" {
void _NSDrawCarbonThemeBezel(NSRect frame, BOOL enabled, BOOL flipped);
@@ -50,6 +51,7 @@ void _NSDrawCarbonThemeListBox(NSRect frame,
BOOL flipped,
BOOL always_yes);
}
+#endif
namespace blink {
@@ -95,10 +97,12 @@ bool ThemePainterMac::PaintTextField(const Node* node,
// behavior change while remaining a fragile solution.
// https://bugs.chromium.org/p/chromium/issues/detail?id=658085#c3
if (!use_ns_text_field_cell) {
+#ifndef MAS_BUILD
_NSDrawCarbonThemeBezel(
CGRect(r),
LayoutTheme::IsEnabled(node) && !LayoutTheme::IsReadOnlyControl(node),
YES);
+#endif
return false;
}
@@ -186,10 +190,12 @@ bool ThemePainterMac::PaintTextArea(const Node* node,
const IntRect& r) {
ScopedColorSchemeAppearance appearance(style.UsedColorScheme());
LocalCurrentGraphicsContext local_context(paint_info.context, r);
+#ifndef MAS_BUILD
_NSDrawCarbonThemeListBox(
CGRect(r),
LayoutTheme::IsEnabled(node) && !LayoutTheme::IsReadOnlyControl(node),
YES, YES);
+#endif
return false;
}