[CG] Upstream CoreGraphics-related WebKitSystemInterface functions
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Sep 2017 18:37:28 +0000 (18:37 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Sep 2017 18:37:28 +0000 (18:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=176200

Reviewed by Tim Horton.

Source/WebCore:

* platform/graphics/GraphicsContext.h:
* platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::subsamplingLevelForScaleFactor):
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::clipOut):
(WebCore::applyShadowOffsetWorkaroundIfNeeded):
* platform/graphics/cg/PatternCG.cpp:
(WebCore::Pattern::createPlatformPattern const):
* platform/graphics/cocoa/GraphicsContextCocoa.mm:
(WebCore::GraphicsContext::focusRingColor):
(WebCore::drawFocusRingAtTime):
(WebCore::drawFocusRing):
(WebCore::drawFocusRingToContext):
(WebCore::drawFocusRingToContextAtTime):
* platform/ios/WebCoreSystemInterfaceIOS.mm:
* platform/mac/PasteboardMac.mm:
(WebCore::flipImageSpec):
(WebCore::setDragImageImpl):
(WebCore::Pasteboard::setDragImage):
* platform/mac/PlatformEventFactoryMac.mm:
* platform/mac/ScrollbarThemeMac.mm:
(WebCore::linenBackgroundColor):
* platform/mac/ThemeMac.mm:
(WebCore::drawCellFocusRingWithFrameAtTime):
(WebCore::drawCellFocusRing):
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:
* platform/mac/WebWindowAnimation.mm:
(flipRect):
(mainWindowServerConnectionID):
(setScaledFrameForWindow):
(-[WebWindowScaleAnimation setCurrentProgress:]):
(-[WebWindowFadeAnimation setCurrentProgress:]):

Source/WebCore/PAL:

* PAL.xcodeproj/project.pbxproj:
* pal/spi/cg/CoreGraphicsSPI.h:
* pal/spi/mac/HIServicesSPI.h:
* pal/spi/mac/NSGraphicsSPI.h: Copied from Source/WebCore/PAL/pal/spi/mac/HIServicesSPI.h.

Source/WebKit:

* PluginProcess/mac/PluginProcessMac.mm:
(WebKit::PluginProcess::platformInitializeProcess):
* UIProcess/mac/WindowServerConnection.h:
* UIProcess/mac/WindowServerConnection.mm:
(WebKit::registerOcclusionNotificationHandler):
(WebKit::WindowServerConnection::WindowServerConnection):
(WebKit::WindowServerConnection::applicationWindowModificationsStarted): Deleted.
* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

Source/WebKitLegacy/mac:

* Carbon/HIWebView.mm:
(-[NSWindowGraphicsContext _web_setGraphicsPort:]):
(overrideCGContext):
(restoreCGContext):
(Draw):
* Plugins/Hosted/WebHostedNetscapePluginView.mm:
(+[WebHostedNetscapePluginView initialize]):
* Plugins/WebBaseNetscapePluginView.h:
* Plugins/WebBaseNetscapePluginView.mm:
(WebKit::sendUserChangeNotifications):
* Plugins/WebNetscapePluginView.mm:
(+[WebNetscapePluginView initialize]):
(-[WebNetscapePluginView saveAndSetNewPortStateForUpdate:]):
* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):
* WebView/WebFrame.mm:
(-[WebFrame _paintBehaviorForDestinationContext:]):
* WebView/WebFullScreenController.mm:
(setClipRectForWindow):
(-[WebFullScreenController finishedEnterFullScreenAnimation:]):
(-[WebFullScreenController finishedExitFullScreenAnimation:]):
(-[WebFullScreenController _startEnterFullScreenAnimationWithDuration:]):
(-[WebFullScreenController _startExitFullScreenAnimationWithDuration:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221485 268f45cc-cd09-0410-ab3c-d52691b4dbfc

33 files changed:
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj
Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h
Source/WebCore/PAL/pal/spi/mac/HIServicesSPI.h
Source/WebCore/PAL/pal/spi/mac/NSGraphicsSPI.h [new file with mode: 0644]
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/ImageSource.cpp
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
Source/WebCore/platform/graphics/cg/PatternCG.cpp
Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm
Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm
Source/WebCore/platform/mac/PasteboardMac.mm
Source/WebCore/platform/mac/PlatformEventFactoryMac.mm
Source/WebCore/platform/mac/ScrollbarThemeMac.mm
Source/WebCore/platform/mac/ThemeMac.mm
Source/WebCore/platform/mac/WebCoreSystemInterface.h
Source/WebCore/platform/mac/WebCoreSystemInterface.mm
Source/WebCore/platform/mac/WebWindowAnimation.mm
Source/WebKit/ChangeLog
Source/WebKit/PluginProcess/mac/PluginProcessMac.mm
Source/WebKit/UIProcess/mac/WindowServerConnection.h
Source/WebKit/UIProcess/mac/WindowServerConnection.mm
Source/WebKit/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
Source/WebKitLegacy/mac/Carbon/HIWebView.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm
Source/WebKitLegacy/mac/Plugins/WebBaseNetscapePluginView.h
Source/WebKitLegacy/mac/Plugins/WebBaseNetscapePluginView.mm
Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm
Source/WebKitLegacy/mac/WebCoreSupport/WebSystemInterface.mm
Source/WebKitLegacy/mac/WebView/WebFrame.mm
Source/WebKitLegacy/mac/WebView/WebFullScreenController.mm

index f304a9d..80ea9ec 100644 (file)
@@ -1,3 +1,44 @@
+2017-09-01  Andy Estes  <aestes@apple.com>
+
+        [CG] Upstream CoreGraphics-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176200
+
+        Reviewed by Tim Horton.
+
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/ImageSource.cpp:
+        (WebCore::ImageSource::subsamplingLevelForScaleFactor):
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::clipOut):
+        (WebCore::applyShadowOffsetWorkaroundIfNeeded):
+        * platform/graphics/cg/PatternCG.cpp:
+        (WebCore::Pattern::createPlatformPattern const):
+        * platform/graphics/cocoa/GraphicsContextCocoa.mm:
+        (WebCore::GraphicsContext::focusRingColor):
+        (WebCore::drawFocusRingAtTime):
+        (WebCore::drawFocusRing):
+        (WebCore::drawFocusRingToContext):
+        (WebCore::drawFocusRingToContextAtTime):
+        * platform/ios/WebCoreSystemInterfaceIOS.mm:
+        * platform/mac/PasteboardMac.mm:
+        (WebCore::flipImageSpec):
+        (WebCore::setDragImageImpl):
+        (WebCore::Pasteboard::setDragImage):
+        * platform/mac/PlatformEventFactoryMac.mm:
+        * platform/mac/ScrollbarThemeMac.mm:
+        (WebCore::linenBackgroundColor):
+        * platform/mac/ThemeMac.mm:
+        (WebCore::drawCellFocusRingWithFrameAtTime):
+        (WebCore::drawCellFocusRing):
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+        * platform/mac/WebWindowAnimation.mm:
+        (flipRect):
+        (mainWindowServerConnectionID):
+        (setScaledFrameForWindow):
+        (-[WebWindowScaleAnimation setCurrentProgress:]):
+        (-[WebWindowFadeAnimation setCurrentProgress:]):
+
 2017-09-01  Youenn Fablet  <youenn@apple.com>
 
         Reject promises in case of internal CacheStorage engine errors.
index eeee84d..37f1462 100644 (file)
@@ -1,3 +1,15 @@
+2017-09-01  Andy Estes  <aestes@apple.com>
+
+        [CG] Upstream CoreGraphics-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176200
+
+        Reviewed by Tim Horton.
+
+        * PAL.xcodeproj/project.pbxproj:
+        * pal/spi/cg/CoreGraphicsSPI.h:
+        * pal/spi/mac/HIServicesSPI.h:
+        * pal/spi/mac/NSGraphicsSPI.h: Copied from Source/WebCore/PAL/pal/spi/mac/HIServicesSPI.h.
+
 2017-08-31  Andy Estes  <aestes@apple.com>
 
         [Mac] Upstream AppKit-related WebKitSystemInterface functions
index 13ceccc..3a040aa 100644 (file)
                A10826F11F573BCA004772AC /* NSResponderSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A10826F01F573BCA004772AC /* NSResponderSPI.h */; };
                A10826F91F576292004772AC /* WebPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = A10826F71F576292004772AC /* WebPanel.h */; };
                A10826FA1F576292004772AC /* WebPanel.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10826F81F576292004772AC /* WebPanel.mm */; };
+               A10826FE1F58A433004772AC /* NSGraphicsSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A10826FD1F58A433004772AC /* NSGraphicsSPI.h */; };
                A1F55DCF1F5528EC00EDB75F /* MetadataSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F55DCE1F5528EC00EDB75F /* MetadataSPI.h */; };
                A30D41211F0DD0EA00B71954 /* KillRing.h in Headers */ = {isa = PBXBuildFile; fileRef = A30D411E1F0DD0EA00B71954 /* KillRing.h */; };
                A30D41221F0DD0EA00B71954 /* KillRing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A30D411F1F0DD0EA00B71954 /* KillRing.cpp */; };
                A10826F01F573BCA004772AC /* NSResponderSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSResponderSPI.h; sourceTree = "<group>"; };
                A10826F71F576292004772AC /* WebPanel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebPanel.h; sourceTree = "<group>"; };
                A10826F81F576292004772AC /* WebPanel.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPanel.mm; sourceTree = "<group>"; };
+               A10826FD1F58A433004772AC /* NSGraphicsSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSGraphicsSPI.h; sourceTree = "<group>"; };
                A1F55DCE1F5528EC00EDB75F /* MetadataSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MetadataSPI.h; sourceTree = "<group>"; };
                A30D411E1F0DD0EA00B71954 /* KillRing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KillRing.h; sourceTree = "<group>"; };
                A30D411F1F0DD0EA00B71954 /* KillRing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KillRing.cpp; sourceTree = "<group>"; };
                                0C7785751F45130F00F4EBB6 /* NSApplicationSPI.h */,
                                0C7785761F45130F00F4EBB6 /* NSEventSPI.h */,
                                0C7785771F45130F00F4EBB6 /* NSFontSPI.h */,
+                               A10826FD1F58A433004772AC /* NSGraphicsSPI.h */,
                                0C7785781F45130F00F4EBB6 /* NSImmediateActionGestureRecognizerSPI.h */,
                                0C7785791F45130F00F4EBB6 /* NSMenuSPI.h */,
                                0C77857A1F45130F00F4EBB6 /* NSPasteboardSPI.h */,
                                0C2DA14E1F3BEB4900DBC317 /* NSExtensionSPI.h in Headers */,
                                0C2DA14F1F3BEB4900DBC317 /* NSFileManagerSPI.h in Headers */,
                                0C7785901F45130F00F4EBB6 /* NSFontSPI.h in Headers */,
+                               A10826FE1F58A433004772AC /* NSGraphicsSPI.h in Headers */,
                                0C7785911F45130F00F4EBB6 /* NSImmediateActionGestureRecognizerSPI.h in Headers */,
                                0C7785921F45130F00F4EBB6 /* NSMenuSPI.h in Headers */,
                                0C7785931F45130F00F4EBB6 /* NSPasteboardSPI.h in Headers */,
index 7c291c9..88735d6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc.  All rights reserved.
+ * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -137,21 +137,74 @@ static inline CGFloat CGFloatMin(CGFloat a, CGFloat b) { return isnan(a) ? b : (
 
 typedef struct CGFontCache CGFontCache;
 
-#if PLATFORM(MAC)
-typedef uint32_t CGSConnectionID;
-typedef uint32_t CGSWindowID;
-typedef uint32_t CGSWindowCount;
-typedef CGSWindowID *CGSWindowIDList;
+#if PLATFORM(COCOA)
 
 enum {
     kCGSWindowCaptureNominalResolution = 0x0200,
     kCGSCaptureIgnoreGlobalClipShape = 0x0800,
 };
 typedef uint32_t CGSWindowCaptureOptions;
-#endif
+
+typedef CF_ENUM (int32_t, CGStyleDrawOrdering) {
+    kCGStyleDrawOrderingStyleOnly = 0,
+    kCGStyleDrawOrderingBelow = 1,
+    kCGStyleDrawOrderingAbove = 2,
+};
+
+typedef CF_ENUM (int32_t, CGFocusRingOrdering) {
+    kCGFocusRingOrderingNone = kCGStyleDrawOrderingStyleOnly,
+    kCGFocusRingOrderingBelow = kCGStyleDrawOrderingBelow,
+    kCGFocusRingOrderingAbove = kCGStyleDrawOrderingAbove,
+};
+
+typedef CF_ENUM (int32_t, CGFocusRingTint) {
+    kCGFocusRingTintBlue = 0,
+    kCGFocusRingTintGraphite = 1,
+};
+
+struct CGFocusRingStyle {
+    unsigned int version;
+    CGFocusRingTint tint;
+    CGFocusRingOrdering ordering;
+    CGFloat alpha;
+    CGFloat radius;
+    CGFloat threshold;
+    CGRect bounds;
+    int accumulate;
+};
+typedef struct CGFocusRingStyle CGFocusRingStyle;
+
+typedef CF_ENUM(uint32_t, CGSNotificationType) {
+    kCGSFirstConnectionNotification = 900,
+    kCGSFirstSessionNotification = 1500,
+};
+
+static const CGSNotificationType kCGSConnectionWindowModificationsStarted = (CGSNotificationType)(kCGSFirstConnectionNotification + 6);
+static const CGSNotificationType kCGSConnectionWindowModificationsStopped = (CGSNotificationType)(kCGSFirstConnectionNotification + 7);
+static const CGSNotificationType kCGSessionConsoleConnect = kCGSFirstSessionNotification;
+static const CGSNotificationType kCGSessionConsoleDisconnect = (CGSNotificationType)(kCGSessionConsoleConnect + 1);
+
+#endif // PLATFORM(COCOA)
 
 #endif // USE(APPLE_INTERNAL_SDK)
 
+#if PLATFORM(COCOA)
+typedef uint32_t CGSByteCount;
+typedef uint32_t CGSConnectionID;
+typedef uint32_t CGSWindowCount;
+typedef uint32_t CGSWindowID;
+
+typedef CGSWindowID* CGSWindowIDList;
+typedef struct CF_BRIDGED_TYPE(id) CGSRegionObject* CGSRegionObj;
+typedef struct CF_BRIDGED_TYPE(id) CGStyle* CGStyleRef;
+
+typedef void* CGSNotificationArg;
+typedef void* CGSNotificationData;
+
+typedef void (*CGSNotifyConnectionProcPtr)(CGSNotificationType, void* data, uint32_t data_length, void* arg, CGSConnectionID);
+typedef void (*CGSNotifyProcPtr)(CGSNotificationType, void* data, uint32_t data_length, void* arg);
+#endif
+
 WTF_EXTERN_C_BEGIN
 
 CGColorRef CGColorTransformConvertColor(CGColorTransformRef, CGColorRef, CGColorRenderingIntent);
@@ -186,6 +239,8 @@ CGDataProviderRef CGPDFDocumentGetDataProvider(CGPDFDocumentRef);
 
 CGFontAntialiasingStyle CGContextGetFontAntialiasingStyle(CGContextRef);
 void CGContextSetFontAntialiasingStyle(CGContextRef, CGFontAntialiasingStyle);
+bool CGContextDrawsWithCorrectShadowOffsets(CGContextRef);
+CGPatternRef CGPatternCreateWithImage2(CGImageRef, CGAffineTransform, CGPatternTiling);
 
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || PLATFORM(IOS)
 bool CGColorSpaceUsesExtendedRange(CGColorSpaceRef);
@@ -203,10 +258,21 @@ CGColorSpaceRef CGIOSurfaceContextGetColorSpace(CGContextRef);
 #endif
 
 #if PLATFORM(COCOA)
-CGSRegionEnumeratorObj CGSRegionEnumerator(CGRegionRef);
-CGRect* CGSNextRect(const CGSRegionEnumeratorObj);
-CGError CGSReleaseRegionEnumerator(const CGSRegionEnumeratorObj);
 CGColorSpaceRef CGContextCopyDeviceColorSpace(CGContextRef);
+CGError CGSNewRegionWithRect(const CGRect*, CGRegionRef*);
+CGError CGSPackagesEnableConnectionOcclusionNotifications(CGSConnectionID, bool flag, bool* outCurrentVisibilityState);
+CGError CGSPackagesEnableConnectionWindowModificationNotifications(CGSConnectionID, bool flag, bool* outConnectionIsCurrentlyIdle);
+CGError CGSRegisterConnectionNotifyProc(CGSConnectionID, CGSNotifyConnectionProcPtr, CGSNotificationType, void* arg);
+CGError CGSRegisterNotifyProc(CGSNotifyProcPtr, CGSNotificationType, void* arg);
+CGError CGSReleaseRegion(const CGRegionRef CF_RELEASES_ARGUMENT);
+CGError CGSReleaseRegionEnumerator(const CGSRegionEnumeratorObj);
+CGError CGSSetWindowAlpha(CGSConnectionID, CGSWindowID, float alpha);
+CGError CGSSetWindowClipShape(CGSConnectionID, CGSWindowID, CGRegionRef shape);
+CGError CGSSetWindowWarp(CGSConnectionID, CGSWindowID, int w, int h, const float* mesh);
+CGRect* CGSNextRect(const CGSRegionEnumeratorObj);
+CGSRegionEnumeratorObj CGSRegionEnumerator(CGRegionRef);
+CGStyleRef CGStyleCreateFocusRingWithColor(const CGFocusRingStyle*, CGColorRef);
+void CGContextSetStyle(CGContextRef, CGStyleRef);
 #endif
 
 #if PLATFORM(WIN)
index 9f35dcd..a355b94 100644 (file)
 #if USE(APPLE_INTERNAL_SDK)
 
 #include <HIServices/AXTextMarker.h>
+#include <HIServices/CoreDrag.h>
+
+#else
+
+enum {
+    kCoreDragImageSpecVersionOne = 1,
+};
+
+struct CoreDragImageSpec {
+    UInt32 version;
+    SInt32 pixelsWide;
+    SInt32 pixelsHigh;
+    SInt32 bitsPerSample;
+    SInt32 samplesPerPixel;
+    SInt32 bitsPerPixel;
+    SInt32 bytesPerRow;
+    Boolean isPlanar;
+    Boolean hasAlpha;
+    const UInt8* data[5];
+};
 
 #endif
 
-typedef const struct __AXTextMarker *AXTextMarkerRef;
-typedef const struct __AXTextMarkerRange *AXTextMarkerRangeRef;
+typedef const struct __AXTextMarker* AXTextMarkerRef;
+typedef const struct __AXTextMarkerRange* AXTextMarkerRangeRef;
+typedef struct CoreDragImageSpec CoreDragImageSpec;
+typedef struct OpaqueCoreDrag* CoreDragRef;
 
 WTF_EXTERN_C_BEGIN
 
-CFTypeID AXTextMarkerGetTypeID();
-CFTypeID AXTextMarkerRangeGetTypeID();
-AXTextMarkerRef AXTextMarkerCreate(CFAllocatorRef, const UInt8* bytes, CFIndex length);
-CFIndex AXTextMarkerGetLength(AXTextMarkerRef);
-const UInt8* AXTextMarkerGetBytePtr(AXTextMarkerRef);
 AXTextMarkerRangeRef AXTextMarkerRangeCreate(CFAllocatorRef, AXTextMarkerRef startMarker, AXTextMarkerRef endMarker);
+AXTextMarkerRef AXTextMarkerCreate(CFAllocatorRef, const UInt8* bytes, CFIndex length);
 AXTextMarkerRef AXTextMarkerRangeCopyStartMarker(AXTextMarkerRangeRef);
 AXTextMarkerRef AXTextMarkerRangeCopyEndMarker(AXTextMarkerRangeRef);
+CFIndex AXTextMarkerGetLength(AXTextMarkerRef);
+CFTypeID AXTextMarkerGetTypeID();
+CFTypeID AXTextMarkerRangeGetTypeID();
+CoreDragRef CoreDragGetCurrentDrag();
+OSStatus CoreDragSetImage(CoreDragRef, CGPoint imageOffset, CoreDragImageSpec*, CGSRegionObj imageShape, float overallAlpha);
+const UInt8* AXTextMarkerGetBytePtr(AXTextMarkerRef);
 
 WTF_EXTERN_C_END
diff --git a/Source/WebCore/PAL/pal/spi/mac/NSGraphicsSPI.h b/Source/WebCore/PAL/pal/spi/mac/NSGraphicsSPI.h
new file mode 100644 (file)
index 0000000..371046f
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if PLATFORM(MAC)
+
+#import <AppKit/AppKit.h>
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <AppKit/NSGraphicsContextPrivate.h>
+#import <AppKit/NSGraphics_Private.h>
+
+#else
+
+#import <pal/spi/cg/CoreGraphicsSPI.h>
+
+@interface NSCGSContext : NSGraphicsContext {
+    CGContextRef _cgsContext;
+}
+@end
+
+@interface NSWindowGraphicsContext : NSCGSContext {
+    CGSWindowID _cgsWindowID;
+}
+@end
+
+#endif
+
+WTF_EXTERN_C_BEGIN
+
+BOOL NSInitializeCGFocusRingStyleForTime(NSFocusRingPlacement, CGFocusRingStyle*, NSTimeInterval);
+
+WTF_EXTERN_C_END
+
+#endif // PLATFORM(MAC)
index 18acddb..b8244a9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2008-2009 Torch Mobile, Inc.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -445,6 +445,7 @@ public:
 #if PLATFORM(MAC)
     void drawFocusRing(const Path&, double timeOffset, bool& needsRedraw);
     void drawFocusRing(const Vector<FloatRect>&, double timeOffset, bool& needsRedraw);
+    static CGColorRef focusRingColor();
 #endif
 
     void setLineCap(LineCap);
index 6696c96..7b34938 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2010, 2011, 2012, 2014, 2016 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk>
  * Copyright (C) 2008, Google Inc. All rights reserved.
  * Copyright (C) 2007-2009 Torch Mobile, Inc
@@ -184,7 +184,7 @@ SubsamplingLevel ImageSource::subsamplingLevelForScaleFactor(GraphicsContext& co
 {
 #if USE(CG)
     // Never use subsampled images for drawing into PDF contexts.
-    if (wkCGContextIsPDFContext(context.platformContext()))
+    if (CGContextGetType(context.platformContext()) == kCGContextTypePDF)
         return SubsamplingLevel::Default;
 
     float scale = std::min(float(1), std::max(scaleFactor.width(), scaleFactor.height()));
index d58839a..78df2b3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -987,7 +987,7 @@ void GraphicsContext::clipOut(const FloatRect& rect)
     // has certain transforms that aren't just a translation or a scale. And due to <rdar://problem/14634453>
     // we cannot use it in for a printing context either.
     const AffineTransform& ctm = getCTM();
-    bool canUseCGRectInfinite = !wkCGContextIsPDFContext(platformContext()) && (!isAcceleratedContext() || (!ctm.b() && !ctm.c()));
+    bool canUseCGRectInfinite = CGContextGetType(platformContext()) != kCGContextTypePDF && (!isAcceleratedContext() || (!ctm.b() && !ctm.c()));
     CGRect rects[2] = { canUseCGRectInfinite ? CGRectInfinite : CGContextGetClipBoundingBox(platformContext()), rect };
     CGContextBeginPath(platformContext());
     CGContextAddRects(platformContext(), rects, 2);
@@ -1085,7 +1085,7 @@ bool GraphicsContext::supportsTransparencyLayers()
 
 static void applyShadowOffsetWorkaroundIfNeeded(const GraphicsContext& context, CGFloat& xOffset, CGFloat& yOffset)
 {
-#if PLATFORM(IOS)
+#if PLATFORM(IOS) || PLATFORM(WIN)
     UNUSED_PARAM(context);
     UNUSED_PARAM(xOffset);
     UNUSED_PARAM(yOffset);
@@ -1093,7 +1093,7 @@ static void applyShadowOffsetWorkaroundIfNeeded(const GraphicsContext& context,
     if (context.isAcceleratedContext())
         return;
 
-    if (wkCGContextDrawsWithCorrectShadowOffsets(context.platformContext()))
+    if (CGContextDrawsWithCorrectShadowOffsets(context.platformContext()))
         return;
 
     // Work around <rdar://problem/5539388> by ensuring that the offsets will get truncated
index 98e69de..8e79db0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
 
 #include "AffineTransform.h"
 #include "GraphicsContext.h"
-
 #include <CoreGraphics/CoreGraphics.h>
+#include <pal/spi/cg/CoreGraphicsSPI.h>
 #include <wtf/MainThread.h>
 
 #if PLATFORM(COCOA)
@@ -74,7 +74,7 @@ CGPatternRef Pattern::createPlatformPattern(const AffineTransform& userSpaceTran
     // If we're repeating in both directions, we can use image-backed patterns
     // instead of custom patterns, and avoid tiling-edge pixel cracks.
     if (m_repeatX && m_repeatY)
-        return wkCGPatternCreateWithImageAndTransform(tileImage().nativeImage().get(), patternTransform, wkPatternTilingConstantSpacing);
+        return CGPatternCreateWithImage2(tileImage().nativeImage().get(), patternTransform, kCGPatternTilingConstantSpacing);
 
     // If FLT_MAX should also be used for xStep or yStep, nothing is rendered. Using fractions of FLT_MAX also
     // result in nothing being rendered.
index 67f4deb..ea41026 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #import "GraphicsContextCG.h"
 #import "GraphicsContextPlatformPrivateCG.h"
 #import "IntRect.h"
+#import <pal/spi/cg/CoreGraphicsSPI.h>
+#import <pal/spi/mac/NSGraphicsSPI.h>
+#import <wtf/StdLibExtras.h>
+
 #if USE(APPKIT)
 #import <AppKit/AppKit.h>
 #endif
-#import <wtf/StdLibExtras.h>
 
 #if PLATFORM(IOS)
 #import "Color.h"
@@ -43,7 +46,6 @@
 #if !PLATFORM(IOS)
 #import "LocalCurrentGraphicsContext.h"
 #endif
-#import "WebCoreSystemInterface.h"
 
 @class NSColor;
 
@@ -57,11 +59,48 @@ namespace WebCore {
 // exceptions for those.
 
 #if !PLATFORM(IOS)
+CGColorRef GraphicsContext::focusRingColor()
+{
+    static CGColorRef color;
+    if (!color) {
+        CGFloat colorComponents[] = { 0.5, 0.75, 1.0, 1.0 };
+        auto colorSpace = adoptCF(CGColorSpaceCreateWithName(kCGColorSpaceSRGB));
+        color = CGColorCreate(colorSpace.get(), colorComponents);
+    }
+
+    return color;
+}
+
+static bool drawFocusRingAtTime(CGContextRef context, NSTimeInterval timeOffset)
+{
+    CGFocusRingStyle focusRingStyle;
+    BOOL needsRepaint = NSInitializeCGFocusRingStyleForTime(NSFocusRingOnly, &focusRingStyle, timeOffset);
+
+    // We want to respect the CGContext clipping and also not overpaint any
+    // existing focus ring. The way to do this is set accumulate to
+    // -1. According to CoreGraphics, the reasoning for this behavior has been
+    // lost in time.
+    focusRingStyle.accumulate = -1;
+    auto style = adoptCF(CGStyleCreateFocusRingWithColor(&focusRingStyle, GraphicsContext::focusRingColor()));
+
+    CGContextSaveGState(context);
+    CGContextSetStyle(context, style.get());
+    CGContextFillPath(context);
+    CGContextRestoreGState(context);
+
+    return needsRepaint;
+}
+
+static void drawFocusRing(CGContextRef context)
+{
+    drawFocusRingAtTime(context, std::numeric_limits<double>::max());
+}
+
 static void drawFocusRingToContext(CGContextRef context, CGPathRef focusRingPath)
 {
     CGContextBeginPath(context);
     CGContextAddPath(context, focusRingPath);
-    wkDrawFocusRing(context, nullptr, 0);
+    drawFocusRing(context);
 }
 
 static bool drawFocusRingToContextAtTime(CGContextRef context, CGPathRef focusRingPath, double timeOffset)
@@ -69,7 +108,7 @@ static bool drawFocusRingToContextAtTime(CGContextRef context, CGPathRef focusRi
     UNUSED_PARAM(timeOffset);
     CGContextBeginPath(context);
     CGContextAddPath(context, focusRingPath);
-    return wkDrawFocusRingAtTime(context, std::numeric_limits<double>::max());
+    return drawFocusRingAtTime(context, std::numeric_limits<double>::max());
 }
 #endif // !PLATFORM(IOS)
 
index 09a1828..d698601 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright 2006-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #import "WebCoreSystemInterface.h"
 
 WEBCORE_EXPORT void (*wkCALayerEnumerateRectsBeingDrawnWithBlock)(CALayer *, CGContextRef context, void (^block)(CGRect rect));
-WEBCORE_EXPORT CGPatternRef (*wkCGPatternCreateWithImageAndTransform)(CGImageRef, CGAffineTransform, int);
 WEBCORE_EXPORT void (*wkClearGlyphVector)(void* glyphs);
 WEBCORE_EXPORT OSStatus (*wkConvertCharToGlyphs)(void* styleGroup, const UniChar*, unsigned numCharacters, void* glyphs);
-WEBCORE_EXPORT bool (*wkCGContextIsPDFContext)(CGContextRef);
 WEBCORE_EXPORT id (*wkCreateNSURLConnectionDelegateProxy)(void);
 WEBCORE_EXPORT void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
 WEBCORE_EXPORT void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString);
index 20e635c..cd62a2d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -52,6 +52,8 @@
 #import "WebCoreSystemInterface.h"
 #import "WebNSAttributedStringExtras.h"
 #import "markup.h"
+#import <pal/spi/cg/CoreGraphicsSPI.h>
+#import <pal/spi/mac/HIServicesSPI.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/StdLibExtras.h>
 #import <wtf/text/StringBuilder.h>
@@ -669,6 +671,80 @@ Vector<String> Pasteboard::readFilenames()
 }
 
 #if ENABLE(DRAG_SUPPORT)
+static void flipImageSpec(CoreDragImageSpec* imageSpec)
+{
+    unsigned char* tempRow = (unsigned char*)fastMalloc(imageSpec->bytesPerRow);
+    int planes = imageSpec->isPlanar ? imageSpec->samplesPerPixel : 1;
+
+    for (int p = 0; p < planes; ++p) {
+        unsigned char* topRow = (unsigned char*)imageSpec->data[p];
+        unsigned char* botRow = topRow + (imageSpec->pixelsHigh - 1) * imageSpec->bytesPerRow;
+        for (int i = 0; i < imageSpec->pixelsHigh / 2; ++i, topRow += imageSpec->bytesPerRow, botRow -= imageSpec->bytesPerRow) {
+            bcopy(topRow, tempRow, imageSpec->bytesPerRow);
+            bcopy(botRow, topRow, imageSpec->bytesPerRow);
+            bcopy(tempRow, botRow, imageSpec->bytesPerRow);
+        }
+    }
+
+    fastFree(tempRow);
+}
+
+static void setDragImageImpl(NSImage *image, NSPoint offset)
+{
+    bool flipImage;
+    NSSize imageSize = image.size;
+    CGRect imageRect = CGRectMake(0, 0, imageSize.width, imageSize.height);
+    NSImageRep *imageRep = [image bestRepresentationForRect:NSRectFromCGRect(imageRect) context:nil hints:nil];
+    RetainPtr<NSBitmapImageRep> bitmapImage;
+    if (!imageRep || ![imageRep isKindOfClass:[NSBitmapImageRep class]] || !NSEqualSizes(imageRep.size, imageSize)) {
+        [image lockFocus];
+        bitmapImage = adoptNS([[NSBitmapImageRep alloc] initWithFocusedViewRect:*(NSRect*)&imageRect]);
+        [image unlockFocus];
+        
+        // we may have to flip the bits we just read if the image was flipped since it means the cache was also
+        // and CoreDragSetImage can't take a transform for rendering.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+        flipImage = image.isFlipped;
+#pragma clang diagnostic pop
+    } else {
+        flipImage = false;
+        bitmapImage = (NSBitmapImageRep *)imageRep;
+    }
+    ASSERT(bitmapImage);
+
+    CoreDragImageSpec imageSpec;
+    imageSpec.version = kCoreDragImageSpecVersionOne;
+    imageSpec.pixelsWide = [bitmapImage pixelsWide];
+    imageSpec.pixelsHigh = [bitmapImage pixelsHigh];
+    imageSpec.bitsPerSample = [bitmapImage bitsPerSample];
+    imageSpec.samplesPerPixel = [bitmapImage samplesPerPixel];
+    imageSpec.bitsPerPixel = [bitmapImage bitsPerPixel];
+    imageSpec.bytesPerRow = [bitmapImage bytesPerRow];
+    imageSpec.isPlanar = [bitmapImage isPlanar];
+    imageSpec.hasAlpha = [bitmapImage hasAlpha];
+    [bitmapImage getBitmapDataPlanes:(unsigned char**)imageSpec.data];
+
+    // if image was flipped, we have an upside down bitmap since the cache is rendered flipped
+    if (flipImage)
+        flipImageSpec(&imageSpec);
+
+    CGSRegionObj imageShape;
+    OSStatus error = CGSNewRegionWithRect(&imageRect, &imageShape);
+    ASSERT(error == kCGErrorSuccess);
+    if (error != kCGErrorSuccess)
+        return;
+
+    // make sure image has integer offset
+    CGPoint imageOffset = { -offset.x, -(imageSize.height - offset.y) };
+    imageOffset.x = floor(imageOffset.x + 0.5);
+    imageOffset.y = floor(imageOffset.y + 0.5);
+
+    error = CoreDragSetImage(CoreDragGetCurrentDrag(), imageOffset, &imageSpec, imageShape, 1.0);
+    CGSReleaseRegion(imageShape);
+    ASSERT(error == kCGErrorSuccess);
+}
+
 void Pasteboard::setDragImage(DragImage image, const IntPoint& location)
 {
     // Don't allow setting the drag image if someone kept a pasteboard and is trying to set the image too late.
@@ -677,7 +753,7 @@ void Pasteboard::setDragImage(DragImage image, const IntPoint& location)
 
     // Dashboard wants to be able to set the drag image during dragging, but Cocoa does not allow this.
     // Instead we must drop down to the CoreGraphics API.
-    wkSetDragImage(image.get().get(), location);
+    setDragImageImpl(image.get().get(), location);
 
     // Hack: We must post an event to wake up the NSDragManager, which is sitting in a nextEvent call
     // up the stack from us because the CoreFoundation drag manager does not use the run loop by itself.
index 77b9cb9..2b18224 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -676,7 +676,7 @@ static int typeForEvent(NSEvent *event)
 {
     return static_cast<int>([NSMenu menuTypeForEvent:event]);
 }
-    
+
 void getWheelEventDeltas(NSEvent *event, float& deltaX, float& deltaY, BOOL& continuous)
 {
     ASSERT(event);
index c4c2877..072e2b4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008-2017 Apple Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,6 +36,7 @@
 #include "ScrollView.h"
 #include "WebCoreSystemInterface.h"
 #include <Carbon/Carbon.h>
+#include <pal/spi/cg/CoreGraphicsSPI.h>
 #include <pal/spi/mac/NSScrollerImpSPI.h>
 #include <wtf/BlockObjCExceptions.h>
 #include <wtf/HashMap.h>
@@ -573,7 +574,7 @@ static RetainPtr<CGColorRef> linenBackgroundColor()
     if (!cgImage)
         return nullptr;
 
-    RetainPtr<CGPatternRef> pattern = adoptCF(wkCGPatternCreateWithImageAndTransform(cgImage, CGAffineTransformIdentity, wkPatternTilingNoDistortion));
+    RetainPtr<CGPatternRef> pattern = adoptCF(CGPatternCreateWithImage2(cgImage, CGAffineTransformIdentity, kCGPatternTilingNoDistortion));
     RetainPtr<CGColorSpaceRef> colorSpace = adoptCF(CGColorSpaceCreatePattern(0));
 
     const CGFloat alpha = 1.0;
index 90f1041..5cde548 100644 (file)
@@ -36,6 +36,7 @@
 #import "WebCoreSystemInterface.h"
 #import <Carbon/Carbon.h>
 #import <pal/spi/cocoa/NSButtonCellSPI.h>
+#import <pal/spi/mac/NSGraphicsSPI.h>
 #import <wtf/BlockObjCExceptions.h>
 #import <wtf/NeverDestroyed.h>
 #import <wtf/StdLibExtras.h>
@@ -349,9 +350,32 @@ static NSButtonCell *sharedCheckboxCell(const ControlStates& states, const IntSi
     return checkboxCell;
 }
 
+static bool drawCellFocusRingWithFrameAtTime(NSCell *cell, NSRect cellFrame, NSView *controlView, NSTimeInterval timeOffset)
+{
+    CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
+    CGContextSaveGState(cgContext);
+
+    CGFocusRingStyle focusRingStyle;
+    bool needsRepaint = NSInitializeCGFocusRingStyleForTime(NSFocusRingOnly, &focusRingStyle, timeOffset);
+    // We want to respect the CGContext clipping and also not overpaint any
+    // existing focus ring. The way to do this is set accumulate to
+    // -1. According to CoreGraphics, the reasoning for this behavior has been
+    // lost in time.
+    focusRingStyle.accumulate = -1;
+    auto style = adoptCF(CGStyleCreateFocusRingWithColor(&focusRingStyle, GraphicsContext::focusRingColor()));
+    CGContextSetStyle(cgContext, style.get());
+
+    CGContextBeginTransparencyLayerWithRect(cgContext, NSRectToCGRect(cellFrame), nullptr);
+    [cell drawFocusRingMaskWithFrame:cellFrame inView:controlView];
+    CGContextEndTransparencyLayer(cgContext);
+    CGContextRestoreGState(cgContext);
+
+    return needsRepaint;
+}
+
 static bool drawCellFocusRing(NSCell *cell, NSRect cellFrame, NSView *controlView)
 {
-    wkDrawCellFocusRingWithFrameAtTime(cell, cellFrame, controlView, std::numeric_limits<double>::max());
+    drawCellFocusRingWithFrameAtTime(cell, cellFrame, controlView, std::numeric_limits<double>::max());
     return false;
 }
 
index 8a12482..47c783e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright 2006-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef WebCoreSystemInterface_h
-#define WebCoreSystemInterface_h
+#pragma once
 
 #include <objc/objc.h>
 
@@ -126,14 +125,7 @@ typedef enum {
     wkPatternTilingConstantSpacing
 } wkPatternTiling;
 #if !PLATFORM(IOS)
-extern bool (*wkCGContextDrawsWithCorrectShadowOffsets)(CGContextRef);
-#endif
-extern CGPatternRef (*wkCGPatternCreateWithImageAndTransform)(CGImageRef, CGAffineTransform, int);
-#if !PLATFORM(IOS)
 extern void (*wkDrawBezeledTextArea)(NSRect, BOOL enabled);
-extern void (*wkDrawFocusRing)(CGContextRef, CGColorRef, int);
-extern bool (*wkDrawFocusRingAtTime)(CGContextRef, NSTimeInterval time);
-extern bool (*wkDrawCellFocusRingWithFrameAtTime)(NSCell *cell, NSRect cellFrame, NSView *controlView, NSTimeInterval time);
 extern void (*wkDrawMediaSliderTrack)(CGContextRef context, CGRect rect, float timeLoaded, float currentTime,
     float duration, unsigned state);
 extern void (*wkDrawMediaUIPart)(int part, CGContextRef context, CGRect rect, unsigned state);
@@ -156,9 +148,6 @@ typedef enum {
 } wkMediaUIControlType;
 extern NSControl *(*wkCreateMediaUIControl)(int);
 
-extern void (*wkWindowSetAlpha)(NSWindow *, float);
-extern void (*wkWindowSetScaledFrame)(NSWindow *, NSRect, NSRect);
-
 extern unsigned (*wkQTIncludeOnlyModernMediaFileTypes)(void);
 extern void (*wkQTMovieDisableComponent)(uint32_t[5]);
 extern float (*wkQTMovieMaxTimeLoaded)(QTMovie*);
@@ -172,9 +161,7 @@ extern NSArray *(*wkQTGetSitesInMediaDownloadCache)();
 extern void (*wkQTClearMediaDownloadCacheForSite)(NSString *site);
 extern void (*wkQTClearMediaDownloadCache)();
 extern void (*wkSetCookieStoragePrivateBrowsingEnabled)(BOOL);
-extern void (*wkSetDragImage)(NSImage*, NSPoint offset);
 #endif
-extern bool (*wkCGContextIsPDFContext)(CGContextRef);
 extern void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
 extern void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString);
 extern CFHTTPMessageRef (*wkCopyCONNECTProxyResponse)(CFReadStreamRef, CFURLRef responseURL, CFStringRef proxyHost, CFNumberRef proxyPort);
@@ -225,5 +212,3 @@ extern NSString *(*wkExernalDeviceDisplayNameForPlayer)(AVPlayer *);
 extern bool (*wkQueryDecoderAvailability)(void);
 
 }
-
-#endif
index 272b555..dd0a758 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright 2006-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #import <Foundation/Foundation.h>
 
 void (*wkCALayerEnumerateRectsBeingDrawnWithBlock)(CALayer *, CGContextRef context, void (^block)(CGRect rect));
-bool (*wkCGContextDrawsWithCorrectShadowOffsets)(CGContextRef);
-CGPatternRef (*wkCGPatternCreateWithImageAndTransform)(CGImageRef, CGAffineTransform, int);
 void (*wkDrawBezeledTextArea)(NSRect, BOOL enabled);
-void (*wkDrawFocusRing)(CGContextRef, CGColorRef, int);
-bool (*wkDrawFocusRingAtTime)(CGContextRef, NSTimeInterval);
-bool (*wkDrawCellFocusRingWithFrameAtTime)(NSCell*, NSRect, NSView*, NSTimeInterval);
 void (*wkDrawMediaSliderTrack)(CGContextRef context, CGRect rect, float timeLoaded, float currentTime,
     float duration, unsigned state);
 BOOL (*wkHitTestMediaUIPart)(int part, CGRect bounds, CGPoint point);
@@ -44,8 +39,6 @@ void (*wkDrawMediaUIPart)(int part, CGContextRef context, CGRect rect, unsigned
 void (*wkMeasureMediaUIPart)(int part, CGRect *bounds, CGSize *naturalSize);
 NSView *(*wkCreateMediaUIBackgroundView)(void);
 NSControl *(*wkCreateMediaUIControl)(int);
-void (*wkWindowSetAlpha)(NSWindow *, float);
-void (*wkWindowSetScaledFrame)(NSWindow *, NSRect, NSRect);
 NSTimeInterval (*wkGetNSURLResponseCalculatedExpiration)(NSURLResponse *response);
 BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response);
 UInt8 (*wkGetNSEventKeyChar)(NSEvent *);
@@ -63,8 +56,6 @@ NSArray *(*wkQTGetSitesInMediaDownloadCache)();
 void (*wkQTClearMediaDownloadCacheForSite)(NSString *site);
 void (*wkQTClearMediaDownloadCache)();
 
-void (*wkSetDragImage)(NSImage*, NSPoint offset);
-bool (*wkCGContextIsPDFContext)(CGContextRef);
 void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
 void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString);
 CFHTTPMessageRef (*wkCopyCONNECTProxyResponse)(CFReadStreamRef, CFURLRef responseURL, CFStringRef proxyHost, CFNumberRef proxyPort);
index 8abc840..5f566e0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,6 +29,7 @@
 
 #import "FloatConversion.h"
 #import "WebCoreSystemInterface.h"
+#import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <wtf/Assertions.h>
 #import <wtf/MathExtras.h>
 
@@ -109,6 +110,59 @@ static CGFloat squaredDistance(NSPoint point1, NSPoint point2)
     return scaledRect(_finalFrame, _initialFrame, [self currentValue]);
 }
 
+static void flipRect(NSRect* rect)
+{
+    rect->origin.y = NSMaxY([(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame]) - NSMaxY(*rect);
+}
+
+static CGSConnectionID mainWindowServerConnectionID()
+{
+    static CGSConnectionID cgsId;
+    if (!cgsId)
+        cgsId = CGSMainConnectionID();
+    return cgsId;
+}
+
+static void setScaledFrameForWindow(NSWindow *window, NSRect scaleFrame, NSRect nonScaledFrame)
+{
+    if (NSEqualRects(scaleFrame, nonScaledFrame)) {
+        CGSSetWindowWarp(mainWindowServerConnectionID(), window.windowNumber, 0, 0, nullptr);
+        return;
+    }
+    
+    float mesh[16];
+    
+    flipRect(&scaleFrame);
+    flipRect(&nonScaledFrame);
+    
+    // top-left point (to and from)
+    mesh[0] = 0;
+    mesh[1] = 0;
+    mesh[2] = NSMinX(scaleFrame);
+    mesh[3] = NSMinY(scaleFrame);
+    
+    // top-right point (to and from)
+    mesh[4] = NSWidth(nonScaledFrame);
+    mesh[5] = 0;
+    mesh[6] = NSMaxX(scaleFrame);
+    mesh[7] = NSMinY(scaleFrame);
+    
+    // bottom-left (to and from)
+    mesh[8] = 0;
+    mesh[9] = NSHeight(nonScaledFrame);
+    mesh[10] = NSMinX(scaleFrame);
+    mesh[11] = NSMaxY(scaleFrame);
+    
+    // bottom-right (to and from)
+    mesh[12] = NSWidth(nonScaledFrame);
+    mesh[13] = NSHeight(nonScaledFrame);
+    mesh[14] = NSMaxX(scaleFrame);
+    mesh[15] = NSMaxY(scaleFrame);
+    
+    // Apply the warp.
+    CGSSetWindowWarp(mainWindowServerConnectionID(), window.windowNumber, 2, 2, mesh);
+}
+
 - (void)setCurrentProgress:(NSAnimationProgress)progress
 {
     if (!_window)
@@ -117,7 +171,7 @@ static CGFloat squaredDistance(NSPoint point1, NSPoint point2)
     [super setCurrentProgress:progress];
 
     NSRect currentRect = [self currentFrame];
-    wkWindowSetScaledFrame(_window, currentRect, _realFrame);
+    setScaledFrameForWindow(_window, currentRect, _realFrame);
     [_subAnimation setCurrentProgress:progress];
 }
 
@@ -211,7 +265,7 @@ static CGFloat squaredDistance(NSPoint point1, NSPoint point2)
     ASSERT(_window);
     [super setCurrentProgress:progress];
 
-    wkWindowSetAlpha(_window, [self currentAlpha]);
+    CGSSetWindowAlpha(mainWindowServerConnectionID(), _window.windowNumber, self.currentAlpha);
 }
 
 - (void)setWindow:(NSWindow*)window
index e5c56fe..c0b07e3 100644 (file)
@@ -1,3 +1,20 @@
+2017-09-01  Andy Estes  <aestes@apple.com>
+
+        [CG] Upstream CoreGraphics-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176200
+
+        Reviewed by Tim Horton.
+
+        * PluginProcess/mac/PluginProcessMac.mm:
+        (WebKit::PluginProcess::platformInitializeProcess):
+        * UIProcess/mac/WindowServerConnection.h:
+        * UIProcess/mac/WindowServerConnection.mm:
+        (WebKit::registerOcclusionNotificationHandler):
+        (WebKit::WindowServerConnection::WindowServerConnection):
+        (WebKit::WindowServerConnection::applicationWindowModificationsStarted): Deleted.
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2017-09-01  Per Arne Vollan  <pvollan@apple.com>
 
         [Win] Compile error, 'Cache' is not declared.
index d860378..24d26ed 100644 (file)
@@ -46,6 +46,7 @@
 #import <mach/mach_vm.h>
 #import <mach/vm_statistics.h>
 #import <objc/runtime.h>
+#import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <pal/spi/mac/HIToolboxSPI.h>
 #import <pal/spi/mac/NSWindowSPI.h>
 #import <sysexits.h>
@@ -531,7 +532,10 @@ void PluginProcess::platformInitializeProcess(const ChildProcessInitializationPa
 
     // FIXME: It would be better to proxy SetCursor calls over to the UI process instead of
     // allowing plug-ins to change the mouse cursor at any time.
-    WKEnableSettingCursorWhenInBackground();
+    // FIXME: SetsCursorInBackground connection property is deprecated in favor of kCGSSetsCursorInBackgroundTagBit window tag bit.
+    // <rdar://problem/7752422> asks for an API to set cursor from background processes.
+    CGSConnectionID cid = CGSMainConnectionID();
+    CGSSetConnectionProperty(cid, cid, CFSTR("SetsCursorInBackground"), (CFTypeRef)kCFBooleanTrue);
 
     RetainPtr<CFURLRef> pluginURL = adoptCF(CFURLCreateWithFileSystemPath(0, m_pluginPath.createCFString().get(), kCFURLPOSIXPathStyle, false));
     if (!pluginURL)
index 838a34f..4920092 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WindowServerConnection_h
-#define WindowServerConnection_h
+#pragma once
 
 namespace WebKit {
 
@@ -41,14 +40,9 @@ private:
     void windowServerConnectionStateChanged();
 
     void applicationWindowModificationsStopped(bool stopped);
-
-    static void applicationWindowModificationsStarted(uint32_t, void*, uint32_t, void*, uint32_t);
-    static void applicationWindowModificationsStopped(uint32_t, void*, uint32_t, void*, uint32_t);
 #endif
 
     bool m_applicationWindowModificationsHaveStopped;
 };
 
 } // namespace WebKit
-
-#endif // WindowServerConnection_h
index 819535c..4cf2fac 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,6 +28,7 @@
 
 #import "WebKitSystemInterface.h"
 #import "WebProcessPool.h"
+#import <pal/spi/cg/CoreGraphicsSPI.h>
 
 namespace WebKit {
 
@@ -41,16 +42,6 @@ void WindowServerConnection::applicationWindowModificationsStopped(bool stopped)
     windowServerConnectionStateChanged();
 }
 
-void WindowServerConnection::applicationWindowModificationsStarted(uint32_t, void*, uint32_t, void*, uint32_t)
-{
-    WindowServerConnection::singleton().applicationWindowModificationsStopped(false);
-}
-
-void WindowServerConnection::applicationWindowModificationsStopped(uint32_t, void*, uint32_t, void*, uint32_t)
-{
-    WindowServerConnection::singleton().applicationWindowModificationsStopped(true);
-}
-
 void WindowServerConnection::windowServerConnectionStateChanged()
 {
     for (auto* processPool : WebProcessPool::allProcessPools())
@@ -65,23 +56,48 @@ WindowServerConnection& WindowServerConnection::singleton()
     return windowServerConnection;
 }
 
+#if HAVE(WINDOW_SERVER_OCCLUSION_NOTIFICATIONS)
+static bool registerOcclusionNotificationHandler(CGSNotificationType type, CGSNotifyConnectionProcPtr handler)
+{
+    CGSConnectionID mainConnection = CGSMainConnectionID();
+    static bool notificationsEnabled;
+    if (!notificationsEnabled) {
+        if (CGSPackagesEnableConnectionOcclusionNotifications(mainConnection, true, nullptr) != kCGErrorSuccess)
+            return false;
+        if (CGSPackagesEnableConnectionWindowModificationNotifications(mainConnection, true, nullptr) != kCGErrorSuccess)
+            return false;
+        notificationsEnabled = true;
+    }
+
+    return CGSRegisterConnectionNotifyProc(mainConnection, handler, type, nullptr) == kCGErrorSuccess;
+}
+#endif
+
 WindowServerConnection::WindowServerConnection()
     : m_applicationWindowModificationsHaveStopped(false)
 {
 #if HAVE(WINDOW_SERVER_OCCLUSION_NOTIFICATIONS)
     struct OcclusionNotificationHandler {
-        WKOcclusionNotificationType notificationType;
-        WKOcclusionNotificationHandler handler;
+        CGSNotificationType notificationType;
+        CGSNotifyConnectionProcPtr handler;
         const char* name;
     };
 
+    static auto windowModificationsStarted = [](CGSNotificationType, void*, uint32_t, void*, CGSConnectionID) {
+        WindowServerConnection::singleton().applicationWindowModificationsStopped(false);
+    };
+
+    static auto windowModificationsStopped = [](CGSNotificationType, void*, uint32_t, void*, CGSConnectionID) {
+        WindowServerConnection::singleton().applicationWindowModificationsStopped(true);
+    };
+
     static const OcclusionNotificationHandler occlusionNotificationHandlers[] = {
-        { WKOcclusionNotificationTypeApplicationWindowModificationsStarted, applicationWindowModificationsStarted, "Application Window Modifications Started" },
-        { WKOcclusionNotificationTypeApplicationWindowModificationsStopped, applicationWindowModificationsStopped, "Application Window Modifications Stopped" },
+        { kCGSConnectionWindowModificationsStarted, windowModificationsStarted, "Application Window Modifications Started" },
+        { kCGSConnectionWindowModificationsStopped, windowModificationsStopped, "Application Window Modifications Stopped" },
     };
 
     for (const auto& occlusionNotificationHandler : occlusionNotificationHandlers) {
-        bool result = WKRegisterOcclusionNotificationHandler(occlusionNotificationHandler.notificationType, occlusionNotificationHandler.handler);
+        bool result = registerOcclusionNotificationHandler(occlusionNotificationHandler.notificationType, occlusionNotificationHandler.handler);
         UNUSED_PARAM(result);
         ASSERT_WITH_MESSAGE(result, "Registration of \"%s\" notification handler failed.\n", occlusionNotificationHandler.name);
     }
index d18a440..84c13ca 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -37,21 +37,11 @@ void InitWebCoreSystemInterface(void)
     
     dispatch_once(&initOnce, ^{
         INIT(CALayerEnumerateRectsBeingDrawnWithBlock);
-        INIT(CGPatternCreateWithImageAndTransform);
-#if !PLATFORM(IOS)
-        INIT(CGContextDrawsWithCorrectShadowOffsets);
-#endif
         INIT(CopyCONNECTProxyResponse);
 #if !PLATFORM(IOS)
         INIT(DrawBezeledTextArea);
-        INIT(DrawFocusRing);
-        INIT(DrawFocusRingAtTime);
-        INIT(DrawCellFocusRingWithFrameAtTime);
         INIT(DrawMediaSliderTrack);
         INIT(DrawMediaUIPart);
-#endif
-        INIT(CGContextIsPDFContext);
-#if !PLATFORM(IOS)
         INIT(GetNSEventKeyChar);
         INIT(HitTestMediaUIPart);
         INIT(MeasureMediaUIPart);
@@ -70,16 +60,11 @@ void InitWebCoreSystemInterface(void)
 #endif
         INIT(SetCONNECTProxyAuthorizationForStream);
         INIT(SetCONNECTProxyForStream);
-#if !PLATFORM(IOS)
-        INIT(SetDragImage);
-#endif
 
 #if !PLATFORM(IOS)
         INIT(ExecutableWasLinkedOnOrBeforeSnowLeopard);
         INIT(CopyDefaultSearchProviderDisplayName);
         INIT(Cursor);
-        INIT(WindowSetScaledFrame);
-        INIT(WindowSetAlpha);
         INIT(SpeechSynthesisGetVoiceIdentifiers);
         INIT(SpeechSynthesisGetDefaultVoiceIdentifierForLocale);
         INIT(NSElasticDeltaForTimeDelta);
index 34585c2..db4bb64 100644 (file)
@@ -36,6 +36,7 @@
 #import "WebKit.h"
 #import <WebKitSystemInterface.h>
 #import <pal/spi/mac/NSEventSPI.h>
+#import <pal/spi/mac/NSGraphicsSPI.h>
 #import <pal/spi/mac/QuickDrawSPI.h>
 #import <wtf/ObjcRuntimeExtras.h>
 
@@ -85,6 +86,21 @@ extern "C" void HIWebViewRegisterClass();
 
 @end
 
+@interface NSWindowGraphicsContext (HIWebView)
+- (void)_web_setGraphicsPort:(CGContextRef)context;
+@end
+
+@implementation NSWindowGraphicsContext (HIWebView)
+
+- (void)_web_setGraphicsPort:(CGContextRef)context
+{
+    CGContextRetain(context);
+    CGContextRelease(_cgsContext);
+    _cgsContext = context;
+}
+
+@end
+
 struct HIWebView
 {
     HIViewRef                                                  fViewRef;
@@ -290,6 +306,22 @@ GetBehaviors()
        return kControlSupportsDataAccess | kControlSupportsGetRegion | kControlGetsFocusOnClick;
 }
 
+static CGContextRef overrideCGContext(NSWindow *window, CGContextRef context)
+{
+    NSWindowGraphicsContext *graphicsContext = (NSWindowGraphicsContext *)window.graphicsContext;
+    CGContextRef savedContext = (CGContextRef)graphicsContext.graphicsPort;
+    CGContextRetain(savedContext);
+    [graphicsContext _web_setGraphicsPort:context];
+    return savedContext;
+}
+
+static void restoreCGContext(NSWindow *window, CGContextRef savedContext)
+{
+    NSWindowGraphicsContext *graphicsContext = (NSWindowGraphicsContext *)window.graphicsContext;
+    [graphicsContext _web_setGraphicsPort:savedContext];
+    CGContextRelease(savedContext);
+}
+
 //----------------------------------------------------------------------------------
 // Draw
 //----------------------------------------------------------------------------------
@@ -321,7 +353,7 @@ Draw( HIWebView* inView, RgnHandle limitRgn, CGContextRef inContext )
 
        HIViewGetBounds( inView->fViewRef, &bounds );
 
-    CGContextRef savedContext = WKNSWindowOverrideCGContext(inView->fKitWindow, inContext);
+    CGContextRef savedContext = overrideCGContext(inView->fKitWindow, inContext);
     [NSGraphicsContext setCurrentContext:[inView->fKitWindow graphicsContext]];
 
        GetRegionBounds( limitRgn, &drawRect );
@@ -351,7 +383,7 @@ Draw( HIWebView* inView, RgnHandle limitRgn, CGContextRef inContext )
     else
         [inView->fWebView displayRect:*(NSRect*)&hiRect];
 
-    WKNSWindowRestoreCGContext(inView->fKitWindow, savedContext);
+    restoreCGContext(inView->fKitWindow, savedContext);
 
     if ( !inView->fIsComposited )
     {
index c4f9956..332d999 100644 (file)
@@ -1,3 +1,34 @@
+2017-09-01  Andy Estes  <aestes@apple.com>
+
+        [CG] Upstream CoreGraphics-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176200
+
+        Reviewed by Tim Horton.
+
+        * Carbon/HIWebView.mm:
+        (-[NSWindowGraphicsContext _web_setGraphicsPort:]):
+        (overrideCGContext):
+        (restoreCGContext):
+        (Draw):
+        * Plugins/Hosted/WebHostedNetscapePluginView.mm:
+        (+[WebHostedNetscapePluginView initialize]):
+        * Plugins/WebBaseNetscapePluginView.h:
+        * Plugins/WebBaseNetscapePluginView.mm:
+        (WebKit::sendUserChangeNotifications):
+        * Plugins/WebNetscapePluginView.mm:
+        (+[WebNetscapePluginView initialize]):
+        (-[WebNetscapePluginView saveAndSetNewPortStateForUpdate:]):
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+        * WebView/WebFrame.mm:
+        (-[WebFrame _paintBehaviorForDestinationContext:]):
+        * WebView/WebFullScreenController.mm:
+        (setClipRectForWindow):
+        (-[WebFullScreenController finishedEnterFullScreenAnimation:]):
+        (-[WebFullScreenController finishedExitFullScreenAnimation:]):
+        (-[WebFullScreenController _startEnterFullScreenAnimationWithDuration:]):
+        (-[WebFullScreenController _startExitFullScreenAnimationWithDuration:]):
+
 2017-08-31  Andy Estes  <aestes@apple.com>
 
         [Mac] Upstream AppKit-related WebKitSystemInterface functions
index 9e2044e..33a08af 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008-2017 Apple Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -76,7 +76,7 @@ extern "C" {
     WTF::initializeMainThreadToProcessMainThread();
     RunLoop::initializeMainRunLoop();
 #endif
-    WKSendUserChangeNotifications();
+    sendUserChangeNotifications();
 }
 
 - (id)initWithFrame:(NSRect)frame
index c2223ab..c237ccf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -134,6 +134,7 @@ namespace WebCore {
 namespace WebKit {
 bool getAuthenticationInfo(const char* protocolStr, const char* hostStr, int32_t port, const char* schemeStr, const char* realmStr,
                            WTF::CString& username, WTF::CString& password);
+void sendUserChangeNotifications();
 } 
 
 #endif
index 64de901..4a760cf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -55,6 +55,7 @@
 #import <WebCore/SecurityOrigin.h>
 #import <WebCore/WebCoreObjCExtras.h>
 #import <WebKitLegacy/DOMPrivate.h>
+#import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <runtime/InitializeThreading.h>
 #import <wtf/Assertions.h>
 #import <wtf/MainThread.h>
@@ -73,7 +74,7 @@ using namespace WebCore;
     JSC::initializeThreading();
     WTF::initializeMainThreadToProcessMainThread();
     RunLoop::initializeMainRunLoop();
-    WKSendUserChangeNotifications();
+    WebKit::sendUserChangeNotifications();
 }
 
 - (id)initWithFrame:(NSRect)frame
@@ -900,6 +901,23 @@ bool getAuthenticationInfo(const char* protocolStr, const char* hostStr, int32_t
     return true;
 }
 
+void sendUserChangeNotifications()
+{
+    auto consoleConnectionChangeNotifyProc = [](CGSNotificationType type, CGSNotificationData, CGSByteCount, CGSNotificationArg) {
+        NSString *notificationName = nil;
+        if (type == kCGSessionConsoleConnect)
+            notificationName = LoginWindowDidSwitchToUserNotification;
+        else if (type == kCGSessionConsoleDisconnect)
+            notificationName = LoginWindowDidSwitchFromUserNotification;
+        else
+            ASSERT_NOT_REACHED();
+        [[NSNotificationCenter defaultCenter] postNotificationName:notificationName object:nil];
+    };
+
+    CGSRegisterNotifyProc(consoleConnectionChangeNotifyProc, kCGSessionConsoleConnect, nullptr);
+    CGSRegisterNotifyProc(consoleConnectionChangeNotifyProc, kCGSessionConsoleDisconnect, nullptr);
+}
+
 } // namespace WebKit
 
 #endif //  ENABLE(NETSCAPE_PLUGIN_API)
index c680ff7..0c4a2f4 100644 (file)
@@ -74,6 +74,7 @@
 #import <WebKitLegacy/DOMPrivate.h>
 #import <WebKitLegacy/WebUIDelegate.h>
 #import <objc/runtime.h>
+#import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <pal/spi/mac/QuickDrawSPI.h>
 #import <runtime/InitializeThreading.h>
 #import <runtime/JSLock.h>
@@ -193,7 +194,7 @@ typedef struct {
     JSC::initializeThreading();
     WTF::initializeMainThreadToProcessMainThread();
     RunLoop::initializeMainRunLoop();
-    WKSendUserChangeNotifications();
+    sendUserChangeNotifications();
 }
 
 // MARK: EVENTS
@@ -379,10 +380,10 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
             qdPortState->clipRegion = clipRegion;
 
             CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
-            if (currentContext && WKCGContextIsBitmapContext(currentContext)) {
-                // We use WKCGContextIsBitmapContext here, because if we just called CGBitmapContextGetData
-                // on any context, we'd log to the console every time. But even if WKCGContextIsBitmapContext
-                // returns true, it still might not be a context we need to create a GWorld for; for example
+            if (currentContext && CGContextGetType(currentContext) == kCGContextTypeBitmap) {
+                // We check for kCGContextTypeBitmap here, because if we just called CGBitmapContextGetData
+                // on any context, we'd log to the console every time. But even if currentContext is a
+                // kCGContextTypeBitmap, it still might not be a context we need to create a GWorld for; for example
                 // transparency layers will return true, but return 0 for CGBitmapContextGetData.
                 void* offscreenData = CGBitmapContextGetData(currentContext);
                 if (offscreenData) {
index 6dd0b57..fad110d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright 2006-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -43,16 +43,9 @@ void InitWebCoreSystemInterface(void)
         return;
 
     INIT(CALayerEnumerateRectsBeingDrawnWithBlock);
-    INIT(CGPatternCreateWithImageAndTransform);
-#if !PLATFORM(IOS)
-    INIT(CGContextDrawsWithCorrectShadowOffsets);
-#endif
     INIT(CopyCONNECTProxyResponse);
 #if !PLATFORM(IOS)
     INIT(DrawBezeledTextArea);
-    INIT(DrawFocusRing);
-    INIT(DrawFocusRingAtTime);
-    INIT(DrawCellFocusRingWithFrameAtTime);
     INIT(DrawMediaUIPart);
     INIT(DrawMediaSliderTrack);
     INIT(GetNSEventKeyChar);
@@ -60,15 +53,9 @@ void InitWebCoreSystemInterface(void)
     INIT(MeasureMediaUIPart);
     INIT(CreateMediaUIBackgroundView);
     INIT(CreateMediaUIControl);
-    INIT(WindowSetAlpha);
-    INIT(WindowSetScaledFrame);
 #endif
     INIT(SetCONNECTProxyAuthorizationForStream);
     INIT(SetCONNECTProxyForStream);
-#if !PLATFORM(IOS)
-    INIT(SetDragImage);
-#endif
-    INIT(CGContextIsPDFContext);
 #if ENABLE(VIDEO) && !PLATFORM(IOS)
     INIT(QTIncludeOnlyModernMediaFileTypes);
     INIT(QTMovieDisableComponent);
index f0f8e62..e7ff4d0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2006, 2007, 2008, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -598,7 +598,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
         return PaintBehaviorFlattenCompositingLayers | PaintBehaviorSnapshotting;
 #endif
 
-    if (!WKCGContextIsBitmapContext(context))
+    if (CGContextGetType(context) != kCGContextTypeBitmap)
         return PaintBehaviorNormal;
 
     // If we're drawing into a bitmap, we might be snapshotting, or drawing into a layer-backed view.
index fd8fc56..3f10996 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -249,6 +249,16 @@ static NSRect convertRectToScreen(NSWindow *window, NSRect rect)
     _isEnteringFullScreen = true;
 }
 
+static void setClipRectForWindow(NSWindow *window, NSRect clipRect)
+{
+    CGSWindowID windowNumber = (CGSWindowID)window.windowNumber;
+    CGSRegionObj shape;
+    CGRect cgClipRect = NSRectToCGRect(clipRect);
+    CGSNewRegionWithRect(&cgClipRect, &shape);
+    CGSSetWindowClipShape(CGSMainConnectionID(), windowNumber, shape);
+    CGSReleaseRegion(shape);
+}
+
 - (void)finishedEnterFullScreenAnimation:(bool)completed
 {
     if (!_isEnteringFullScreen)
@@ -263,7 +273,7 @@ static NSRect convertRectToScreen(NSWindow *window, NSRect rect)
         
         NSRect windowBounds = [[self window] frame];
         windowBounds.origin = NSZeroPoint;
-        WKWindowSetClipRect([self window], windowBounds);
+        setClipRectForWindow(self.window, windowBounds);
         
         NSWindow *webWindow = [_webViewPlaceholder.get() window];
         // In Lion, NSWindow will animate into and out of orderOut operations. Suppress that
@@ -353,7 +363,7 @@ static NSRect convertRectToScreen(NSWindow *window, NSRect rect)
     
     NSRect windowBounds = [[self window] frame];
     windowBounds.origin = NSZeroPoint;
-    WKWindowSetClipRect([self window], windowBounds);
+    setClipRectForWindow(self.window, windowBounds);
     
     [[self window] orderOut:self];
     [[self window] setFrame:NSZeroRect display:YES];
@@ -484,13 +494,13 @@ static NSRect windowFrameFromApparentFrames(NSRect screenFrame, NSRect initialFr
     [_scaleAnimation.get() setCurrentProgress:0];
     [_scaleAnimation.get() startAnimation];
     
-    // WKWindowSetClipRect takes window coordinates, so convert from screen coordinates here:
+    // setClipRectForWindow takes window coordinates, so convert from screen coordinates here:
     NSRect finalBounds = _finalFrame;
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
     finalBounds.origin = [[self window] convertScreenToBase:finalBounds.origin];
 #pragma clang diagnostic pop
-    WKWindowSetClipRect([self window], finalBounds);
+    setClipRectForWindow(self.window, finalBounds);
     
     [[self window] makeKeyAndOrderFront:self];
     
@@ -556,13 +566,13 @@ static NSRect windowFrameFromApparentFrames(NSRect screenFrame, NSRect initialFr
     
     [_backgroundWindow.get() orderWindow:NSWindowBelow relativeTo:[[self window] windowNumber]];
     
-    // WKWindowSetClipRect takes window coordinates, so convert from screen coordinates here:
+    // setClipRectForWindow takes window coordinates, so convert from screen coordinates here:
     NSRect finalBounds = _finalFrame;
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
     finalBounds.origin = [[self window] convertScreenToBase:finalBounds.origin];
 #pragma clang diagnostic pop
-    WKWindowSetClipRect([self window], finalBounds);
+    setClipRectForWindow(self.window, finalBounds);
     
     [[self window] setAutodisplay:YES];
     [[self window] displayIfNeeded];