- Revision
- 202998
- Author
- [email protected]
- Date
- 2016-07-08 11:52:26 -0700 (Fri, 08 Jul 2016)
Log Message
REGRESSION (r196321): Adobe Reader DC + Safari : Zoom level pulldown is not displayed at the correct position
https://bugs.webkit.org/show_bug.cgi?id=159531
rdar://problem/26382579
Reviewed by Tim Horton.
There's code in the Adobe Acrobat framework that checks if the main bundle identifier is "com.apple.WebKit.PluginProcess"
and assumes that it's running inside the Adobe Reader app if it's something else. Since we're now using the XPC service
for all plug-ins, the bundle identifier is "com.apple.WebKit.Plugin.64", so the Acrobat framework assumes it's running in the app
and doesn't use any special tricks to show the popup menu.
Work around this by shimming CFStringCompare, and looking for the exact conditions when this can happen and return kCFCompareEqualTo
when all conditions are true.
* PluginProcess/mac/PluginProcessMac.mm:
(WebKit::isAdobeAcrobatAddress):
(WebKit::stringCompare):
(WebKit::initializeShim):
(WebKit::PluginProcess::platformInitializeProcess):
* PluginProcess/mac/PluginProcessShim.h:
* PluginProcess/mac/PluginProcessShim.mm:
(WebKit::shimCFStringCompare):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (202997 => 202998)
--- trunk/Source/WebKit2/ChangeLog 2016-07-08 18:48:25 UTC (rev 202997)
+++ trunk/Source/WebKit2/ChangeLog 2016-07-08 18:52:26 UTC (rev 202998)
@@ -1,3 +1,28 @@
+2016-07-07 Anders Carlsson <[email protected]>
+
+ REGRESSION (r196321): Adobe Reader DC + Safari : Zoom level pulldown is not displayed at the correct position
+ https://bugs.webkit.org/show_bug.cgi?id=159531
+ rdar://problem/26382579
+
+ Reviewed by Tim Horton.
+
+ There's code in the Adobe Acrobat framework that checks if the main bundle identifier is "com.apple.WebKit.PluginProcess"
+ and assumes that it's running inside the Adobe Reader app if it's something else. Since we're now using the XPC service
+ for all plug-ins, the bundle identifier is "com.apple.WebKit.Plugin.64", so the Acrobat framework assumes it's running in the app
+ and doesn't use any special tricks to show the popup menu.
+
+ Work around this by shimming CFStringCompare, and looking for the exact conditions when this can happen and return kCFCompareEqualTo
+ when all conditions are true.
+
+ * PluginProcess/mac/PluginProcessMac.mm:
+ (WebKit::isAdobeAcrobatAddress):
+ (WebKit::stringCompare):
+ (WebKit::initializeShim):
+ (WebKit::PluginProcess::platformInitializeProcess):
+ * PluginProcess/mac/PluginProcessShim.h:
+ * PluginProcess/mac/PluginProcessShim.mm:
+ (WebKit::shimCFStringCompare):
+
2016-07-08 Brady Eidson <[email protected]>
Unreviewed: Fix case-sensitive filesystem build.
Modified: trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm (202997 => 202998)
--- trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm 2016-07-08 18:48:25 UTC (rev 202997)
+++ trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm 2016-07-08 18:52:26 UTC (rev 202998)
@@ -238,7 +238,7 @@
PluginProcess::singleton().setModalWindowIsShowing(modalWindowIsShowing);
}
-static unsigned modalCount = 0;
+static unsigned modalCount;
static void beginModal()
{
@@ -271,11 +271,70 @@
return result;
}
-#if defined(__i386__)
+static bool oldPluginProcessNameShouldEqualNewPluginProcessNameForAdobeReader;
+
+static bool isAdobeAcrobatAddress(const void* address)
+{
+ Dl_info imageInfo;
+ if (!dladdr(address, &imageInfo))
+ return false;
+
+ const char* pathSuffix = "/Contents/Frameworks/Acrobat.framework/Acrobat";
+
+ int pathSuffixLength = strlen(pathSuffix);
+ int imageFilePathLength = strlen(imageInfo.dli_fname);
+
+ if (imageFilePathLength < pathSuffixLength)
+ return false;
+
+ if (strcmp(imageInfo.dli_fname + (imageFilePathLength - pathSuffixLength), pathSuffix))
+ return false;
+
+ return true;
+}
+
+static bool stringCompare(CFStringRef a, CFStringRef b, CFStringCompareFlags options, void* returnAddress, CFComparisonResult& result)
+{
+ if (pthread_main_np() != 1)
+ return false;
+
+ if (!oldPluginProcessNameShouldEqualNewPluginProcessNameForAdobeReader)
+ return false;
+
+ if (options != kCFCompareCaseInsensitive)
+ return false;
+
+ const char* aCString = CFStringGetCStringPtr(a, kCFStringEncodingASCII);
+ if (!aCString)
+ return false;
+
+ const char* bCString = CFStringGetCStringPtr(b, kCFStringEncodingASCII);
+ if (!bCString)
+ return false;
+
+ if (strcmp(aCString, "com.apple.WebKit.PluginProcess"))
+ return false;
+
+ if (strcmp(bCString, "com.apple.WebKit.Plugin.64"))
+ return false;
+
+ // Check if the LHS string comes from the Acrobat framework.
+ if (!isAdobeAcrobatAddress(a))
+ return false;
+
+ // Check if the return adress is part of the Acrobat framework as well.
+ if (!isAdobeAcrobatAddress(returnAddress))
+ return false;
+
+ result = kCFCompareEqualTo;
+ return true;
+}
+
static void initializeShim()
{
// Initialize the shim for 32-bit only.
const PluginProcessShimCallbacks callbacks = {
+#if defined(__i386__)
shouldCallRealDebugger,
isWindowActive,
getCurrentEventButtonState,
@@ -286,12 +345,13 @@
setModal,
openCFURLRef,
shouldMapMemoryExecutable,
+#endif
+ stringCompare,
};
PluginProcessShimInitializeFunc initFunc = reinterpret_cast<PluginProcessShimInitializeFunc>(dlsym(RTLD_DEFAULT, "WebKitPluginProcessShimInitialize"));
initFunc(callbacks);
}
-#endif
static void (*NSConcreteTask_launch)(NSTask *, SEL);
@@ -447,9 +507,7 @@
void PluginProcess::platformInitializeProcess(const ChildProcessInitializationParameters& parameters)
{
-#if defined(__i386__)
initializeShim();
-#endif
initializeCocoaOverrides();
@@ -467,6 +525,9 @@
m_pluginBundleIdentifier = CFBundleGetIdentifier(pluginBundle.get());
+ if (m_pluginBundleIdentifier == "com.adobe.acrobat.pdfviewerNPAPI")
+ oldPluginProcessNameShouldEqualNewPluginProcessNameForAdobeReader = true;
+
#if defined(__i386__)
if (m_pluginBundleIdentifier == "com.microsoft.SilverlightPlugin") {
// Set this so that any calls to mach_vm_map for pages reserved by malloc will be executable.
Modified: trunk/Source/WebKit2/PluginProcess/mac/PluginProcessShim.h (202997 => 202998)
--- trunk/Source/WebKit2/PluginProcess/mac/PluginProcessShim.h 2016-07-08 18:48:25 UTC (rev 202997)
+++ trunk/Source/WebKit2/PluginProcess/mac/PluginProcessShim.h 2016-07-08 18:52:26 UTC (rev 202998)
@@ -23,8 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef PluginProcessShim_h
-#define PluginProcessShim_h
+#pragma once
@class NSWindow;
@@ -33,6 +32,7 @@
namespace WebKit {
struct PluginProcessShimCallbacks {
+#if defined(__i386__)
bool (*shouldCallRealDebugger)();
bool (*isWindowActive)(WindowRef, bool& result);
UInt32 (*getCurrentEventButtonState)();
@@ -43,10 +43,10 @@
void (*setModal)(bool);
bool (*openCFURLRef)(CFURLRef, int32_t& returnValue, CFURLRef* launchedURL);
bool (*shouldMapMemoryExecutable)(int flags);
+#endif
+ bool (*stringCompare)(CFStringRef a, CFStringRef b, CFStringCompareFlags options, void* returnAddress, CFComparisonResult& result);
};
typedef void (*PluginProcessShimInitializeFunc)(const PluginProcessShimCallbacks&);
}
-
-#endif // PluginProcessShim_h
Modified: trunk/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm (202997 => 202998)
--- trunk/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm 2016-07-08 18:48:25 UTC (rev 202997)
+++ trunk/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm 2016-07-08 18:52:26 UTC (rev 202998)
@@ -136,6 +136,7 @@
DYLD_INTERPOSE(shimHideWindow, HideWindow);
DYLD_INTERPOSE(shimLSOpenCFURLRef, LSOpenCFURLRef);
DYLD_INTERPOSE(shimMachVMMap, mach_vm_map);
+DYLD_INTERPOSE(shimCFStringCompare, CFStringCompare);
#pragma clang diagnostic pop
@@ -330,6 +331,20 @@
DYLD_INTERPOSE(shim_shmget, shmget);
DYLD_INTERPOSE(shim_shmctl, shmctl);
+static CFComparisonResult shimCFStringCompare(CFStringRef a, CFStringRef b, CFStringCompareFlags options)
+{
+ if (pluginProcessShimCallbacks.stringCompare) {
+ CFComparisonResult result;
+ if (pluginProcessShimCallbacks.stringCompare(a, b, options, __builtin_return_address(0), result))
+ return result;
+ }
+
+ return CFStringCompare(a, b, options);
+}
+
+DYLD_INTERPOSE(shimCFStringCompare, CFStringCompare);
+
+
__attribute__((visibility("default")))
void WebKitPluginProcessShimInitialize(const PluginProcessShimCallbacks& callbacks)
{