Diff
Modified: trunk/Source/WebCore/ChangeLog (261441 => 261442)
--- trunk/Source/WebCore/ChangeLog 2020-05-09 22:40:13 UTC (rev 261441)
+++ trunk/Source/WebCore/ChangeLog 2020-05-09 23:10:41 UTC (rev 261442)
@@ -1,3 +1,47 @@
+2020-05-09 David Kilzer <[email protected]>
+
+ Adapt LocalCurrentGraphicsContext for iOS
+ <https://webkit.org/b/211660>
+
+ Reviewed by Darin Adler.
+
+ * PlatformMac.cmake:
+ * SourcesCocoa.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ - Update build files for:
+ - Rename of LocalCurrentGraphicsContext.mm to
+ LocalCurrentGraphicsContextMac.mm.
+ - Move of LocalCurrentGraphicsContext.h from platform/mac to
+ platform/cocoa.
+ - Addition of LocalCurrentGraphicsContextIOS.mm.
+
+ * platform/cocoa/LocalCurrentGraphicsContext.h: Renamed from Source/WebCore/platform/mac/LocalCurrentGraphicsContext.h.
+ - Make this work for iOS by using PLATFORM(COCOA) for the outer
+ guard and USE(APPKIT) for the Mac-specific bits.
+ - Use RetainPtr<> for NSGraphicsContext to clean up code in
+ LocalCurrentGraphicsContextMac.mm.
+ (WebCore::LocalCurrentGraphicsContext::cgContext):
+ - Inline from LocalCurrentGraphicsContextMac.mm.
+
+ * platform/ios/LocalCurrentGraphicsContextIOS.mm: Copied from Source/WebCore/platform/mac/LocalCurrentGraphicsContext.mm.
+ (WebCore::LocalCurrentGraphicsContext::LocalCurrentGraphicsContext):
+ (WebCore::LocalCurrentGraphicsContext::~LocalCurrentGraphicsContext):
+ - Implement based on LocalCurrentGraphicsContextMac.mm. Use
+ UIGraphics{GetCurrent,Pop,Push}Context() functions added to
+ UIKitSoftLink.h.
+
+ * platform/mac/LocalCurrentGraphicsContextMac.mm: Renamed from Source/WebCore/platform/mac/LocalCurrentGraphicsContext.mm.
+ (WebCore::LocalCurrentGraphicsContext::LocalCurrentGraphicsContext):
+ - Use m_savedGraphicsContext instead of graphicsContext in the
+ body of the constructor.
+ - Remove set-to-nil/retain of m_savedNSGraphicsContext since
+ that is handled by RetainPtr<> now.
+ (WebCore::LocalCurrentGraphicsContext::~LocalCurrentGraphicsContext):
+ - Remove release of m_savedNSGraphicsContext since that is
+ handled by RetainPtr<> now.
+ (WebCore::LocalCurrentGraphicsContext::cgContext): Delete.
+ - Inline into header to share implementation with iOS.
+
2020-05-09 Darin Adler <[email protected]>
Fix null-dereference in DocumentTimelinesController::updateAnimationsAndSendEvents
Modified: trunk/Source/WebCore/PAL/ChangeLog (261441 => 261442)
--- trunk/Source/WebCore/PAL/ChangeLog 2020-05-09 22:40:13 UTC (rev 261441)
+++ trunk/Source/WebCore/PAL/ChangeLog 2020-05-09 23:10:41 UTC (rev 261442)
@@ -1,3 +1,15 @@
+2020-05-09 David Kilzer <[email protected]>
+
+ Adapt LocalCurrentGraphicsContext for iOS
+ <https://webkit.org/b/211660>
+
+ Reviewed by Darin Adler.
+
+ * pal/ios/UIKitSoftLink.h:
+ * pal/ios/UIKitSoftLink.mm:
+ - Add soft linking of UIGraphics{GetCurrent,Pop,Push}Context()
+ functions.
+
2020-05-08 Per Arne Vollan <[email protected]>
[Cocoa] Close connections to Launch Services after revoking extension
Modified: trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h (261441 => 261442)
--- trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h 2020-05-09 22:40:13 UTC (rev 261441)
+++ trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h 2020-05-09 23:10:41 UTC (rev 261442)
@@ -67,5 +67,8 @@
SOFT_LINK_FUNCTION_FOR_HEADER(PAL, UIKit, UIAccessibilityIsInvertColorsEnabled, BOOL, (void), ())
SOFT_LINK_FUNCTION_FOR_HEADER(PAL, UIKit, UIAccessibilityIsReduceMotionEnabled, BOOL, (void), ())
SOFT_LINK_FUNCTION_FOR_HEADER(PAL, UIKit, UIAccessibilityPostNotification, void, (UIAccessibilityNotifications n, id argument), (n, argument))
+SOFT_LINK_FUNCTION_FOR_HEADER(PAL, UIKit, UIGraphicsGetCurrentContext, CGContextRef, (void), ())
+SOFT_LINK_FUNCTION_FOR_HEADER(PAL, UIKit, UIGraphicsPopContext, void, (void), ())
+SOFT_LINK_FUNCTION_FOR_HEADER(PAL, UIKit, UIGraphicsPushContext, void, (CGContextRef context), (context))
#endif
Modified: trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm (261441 => 261442)
--- trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm 2020-05-09 22:40:13 UTC (rev 261441)
+++ trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm 2020-05-09 23:10:41 UTC (rev 261442)
@@ -67,5 +67,8 @@
SOFT_LINK_FUNCTION_FOR_SOURCE(PAL, UIKit, UIAccessibilityIsInvertColorsEnabled, BOOL, (void), ())
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, UIKit, UIAccessibilityIsReduceMotionEnabled, BOOL, (void), (), PAL_EXPORT)
SOFT_LINK_FUNCTION_FOR_SOURCE(PAL, UIKit, UIAccessibilityPostNotification, void, (UIAccessibilityNotifications n, id argument), (n, argument))
+SOFT_LINK_FUNCTION_FOR_SOURCE(PAL, UIKit, UIGraphicsGetCurrentContext, CGContextRef, (void), ())
+SOFT_LINK_FUNCTION_FOR_SOURCE(PAL, UIKit, UIGraphicsPopContext, void, (void), ())
+SOFT_LINK_FUNCTION_FOR_SOURCE(PAL, UIKit, UIGraphicsPushContext, void, (CGContextRef context), (context))
#endif
Modified: trunk/Source/WebCore/PlatformMac.cmake (261441 => 261442)
--- trunk/Source/WebCore/PlatformMac.cmake 2020-05-09 22:40:13 UTC (rev 261441)
+++ trunk/Source/WebCore/PlatformMac.cmake 2020-05-09 23:10:41 UTC (rev 261442)
@@ -362,7 +362,7 @@
platform/mac/DragDataMac.mm
platform/mac/DragImageMac.mm
platform/mac/KeyEventMac.mm
- platform/mac/LocalCurrentGraphicsContext.mm
+ platform/mac/LocalCurrentGraphicsContextMac.mm
platform/mac/LoggingMac.mm
platform/mac/MediaRemoteSoftLink.cpp
platform/mac/NSScrollerImpDetails.mm
@@ -516,6 +516,7 @@
platform/cf/RunLoopObserver.h
+ platform/cocoa/LocalCurrentGraphicsContext.h
platform/cocoa/NetworkExtensionContentFilter.h
platform/cocoa/PlatformView.h
platform/cocoa/PlaybackSessionInterface.h
@@ -575,7 +576,6 @@
platform/mac/DynamicLinkerInterposing.h
platform/mac/LegacyNSPasteboardTypes.h
- platform/mac/LocalCurrentGraphicsContext.h
platform/mac/LocalDefaultSystemAppearance.h
platform/mac/NSScrollerImpDetails.h
platform/mac/PasteboardWriter.h
Modified: trunk/Source/WebCore/SourcesCocoa.txt (261441 => 261442)
--- trunk/Source/WebCore/SourcesCocoa.txt 2020-05-09 22:40:13 UTC (rev 261441)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2020-05-09 23:10:41 UTC (rev 261442)
@@ -404,6 +404,7 @@
platform/ios/LegacyTileGridTile.mm
platform/ios/LegacyTileLayer.mm
platform/ios/LegacyTileLayerPool.mm
+platform/ios/LocalCurrentGraphicsContextIOS.mm
platform/ios/LocalCurrentTraitCollection.mm
platform/ios/LocalizedDeviceModel.mm
platform/ios/LowPowerModeNotifierIOS.mm
@@ -449,7 +450,7 @@
platform/mac/CursorMac.mm @no-unify
platform/mac/KeyEventMac.mm @no-unify
platform/mac/PlaybackSessionInterfaceMac.mm @no-unify
-platform/mac/LocalCurrentGraphicsContext.mm
+platform/mac/LocalCurrentGraphicsContextMac.mm
platform/mac/LocalDefaultSystemAppearance.mm
platform/mac/LoggingMac.mm
platform/mac/MediaRemoteSoftLink.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (261441 => 261442)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-05-09 22:40:13 UTC (rev 261441)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-05-09 23:10:41 UTC (rev 261442)
@@ -5423,7 +5423,7 @@
066C772E0AB603FD00238CC4 /* RenderFileUploadControl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFileUploadControl.cpp; sourceTree = "<group>"; };
066C772F0AB603FD00238CC4 /* RenderFileUploadControl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderFileUploadControl.h; sourceTree = "<group>"; };
06E81ED60AB5D5E900C87837 /* LocalCurrentGraphicsContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalCurrentGraphicsContext.h; sourceTree = "<group>"; };
- 06E81EEB0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalCurrentGraphicsContext.mm; sourceTree = "<group>"; };
+ 06E81EEB0AB5DA9700C87837 /* LocalCurrentGraphicsContextMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalCurrentGraphicsContextMac.mm; sourceTree = "<group>"; };
070334D01459FFAC008D8D45 /* TrackEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TrackEvent.cpp; sourceTree = "<group>"; };
070334D11459FFAC008D8D45 /* TrackEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TrackEvent.h; sourceTree = "<group>"; };
070334D21459FFAC008D8D45 /* TrackEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TrackEvent.idl; sourceTree = "<group>"; };
@@ -7766,6 +7766,7 @@
44C991850F3D1EBE00586670 /* ScrollbarThemeIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollbarThemeIOS.h; sourceTree = "<group>"; };
44C9919D0F3D210E00586670 /* ThemeIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThemeIOS.h; sourceTree = "<group>"; };
44C9919E0F3D210E00586670 /* ThemeIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ThemeIOS.mm; sourceTree = "<group>"; };
+ 44CA2843245FCA5000C94C7F /* LocalCurrentGraphicsContextIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalCurrentGraphicsContextIOS.mm; sourceTree = "<group>"; };
44D8DA98139545BE00337B75 /* SVGMPathElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGMPathElement.idl; sourceTree = "<group>"; };
44D8DA9A139545CD00337B75 /* SVGAnimateMotionElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGAnimateMotionElement.idl; sourceTree = "<group>"; };
44DAB5AF15A623580097C1E4 /* ExtensionsGLOpenGLCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtensionsGLOpenGLCommon.cpp; sourceTree = "<group>"; };
@@ -20821,8 +20822,7 @@
E1BA66F01742BD8600C20251 /* DynamicLinkerInterposing.h */,
935C476E09AC4D7300A6AAB4 /* KeyEventMac.mm */,
F44A5F571FED3830007F5944 /* LegacyNSPasteboardTypes.h */,
- 06E81ED60AB5D5E900C87837 /* LocalCurrentGraphicsContext.h */,
- 06E81EEB0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm */,
+ 06E81EEB0AB5DA9700C87837 /* LocalCurrentGraphicsContextMac.mm */,
445775E420472F73008DCE5D /* LocalDefaultSystemAppearance.h */,
445775E92047303B008DCE5D /* LocalDefaultSystemAppearance.mm */,
1402645D0AFDC19B005919E2 /* LoggingMac.mm */,
@@ -23283,6 +23283,7 @@
E4B65A5D132FADB60070E7BE /* LegacyTileLayer.mm */,
E4E39AFA1330EFA8003AB274 /* LegacyTileLayerPool.h */,
E4E39AFC1330EFC5003AB274 /* LegacyTileLayerPool.mm */,
+ 44CA2843245FCA5000C94C7F /* LocalCurrentGraphicsContextIOS.mm */,
1C43DE6822AB4B8A001527D9 /* LocalCurrentTraitCollection.h */,
1C43DE6A22AB4B8A001527D9 /* LocalCurrentTraitCollection.mm */,
E35B907C23F60677000011FF /* LocalizedDeviceModel.h */,
@@ -23444,6 +23445,7 @@
7A09CEF01F01D1F700E93BDB /* FileMonitorCocoa.mm */,
A5C974CF11485FF10066F2AB /* KeyEventCocoa.h */,
A5C974D011485FF10066F2AB /* KeyEventCocoa.mm */,
+ 06E81ED60AB5D5E900C87837 /* LocalCurrentGraphicsContext.h */,
1A4832B21A953BA6008B4DFE /* LocalizedStringsCocoa.mm */,
C53D39331C97892D007F3AE9 /* MIMETypeRegistryCocoa.mm */,
A19D93491AA11B1E00B46C24 /* NetworkExtensionContentFilter.h */,
Copied: trunk/Source/WebCore/platform/cocoa/LocalCurrentGraphicsContext.h (from rev 261441, trunk/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.h) (0 => 261442)
--- trunk/Source/WebCore/platform/cocoa/LocalCurrentGraphicsContext.h (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/LocalCurrentGraphicsContext.h 2020-05-09 23:10:41 UTC (rev 261442)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2006-2020 Apple Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#include "GraphicsContext.h"
+#include <wtf/Noncopyable.h>
+
+#if PLATFORM(COCOA)
+
+#if USE(APPKIT)
+OBJC_CLASS NSGraphicsContext;
+#endif
+
+namespace WebCore {
+
+// This class automatically saves and restores the current NSGraphicsContext for
+// functions which call out into AppKit and rely on the currentContext being set
+class LocalCurrentGraphicsContext {
+ WTF_MAKE_NONCOPYABLE(LocalCurrentGraphicsContext);
+public:
+ WEBCORE_EXPORT LocalCurrentGraphicsContext(GraphicsContext&);
+ WEBCORE_EXPORT ~LocalCurrentGraphicsContext();
+ CGContextRef cgContext() { return m_savedGraphicsContext.platformContext(); }
+private:
+ GraphicsContext& m_savedGraphicsContext;
+#if USE(APPKIT)
+ RetainPtr<NSGraphicsContext> m_savedNSGraphicsContext;
+#endif
+ bool m_didSetGraphicsContext { false };
+};
+
+class ContextContainer {
+ WTF_MAKE_NONCOPYABLE(ContextContainer);
+public:
+ ContextContainer(GraphicsContext& graphicsContext)
+ : m_graphicsContext(graphicsContext.platformContext())
+ {
+ }
+
+ CGContextRef context() { return m_graphicsContext; }
+private:
+ CGContextRef m_graphicsContext;
+};
+
+}
+
+#endif // PLATFORM(COCOA)
Copied: trunk/Source/WebCore/platform/ios/LocalCurrentGraphicsContextIOS.mm (from rev 261441, trunk/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.mm) (0 => 261442)
--- trunk/Source/WebCore/platform/ios/LocalCurrentGraphicsContextIOS.mm (rev 0)
+++ trunk/Source/WebCore/platform/ios/LocalCurrentGraphicsContextIOS.mm 2020-05-09 23:10:41 UTC (rev 261442)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2006-2020 Apple Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#import "config.h"
+#import "LocalCurrentGraphicsContext.h"
+
+#if PLATFORM(IOS_FAMILY)
+
+#import <pal/ios/UIKitSoftLink.h>
+
+namespace WebCore {
+
+LocalCurrentGraphicsContext::LocalCurrentGraphicsContext(GraphicsContext& graphicsContext)
+ : m_savedGraphicsContext(graphicsContext)
+{
+ m_savedGraphicsContext.save();
+
+ if (!m_savedGraphicsContext.hasPlatformContext()) {
+ WTFLogAlways("LocalCurrentGraphicsContext is not setting the global context because the provided GraphicsContext does not have a platform context (likely display list recording)");
+ return;
+ }
+
+ CGContextRef cgContext = this->cgContext();
+ if (cgContext == UIGraphicsGetCurrentContext())
+ return;
+
+ UIGraphicsPushContext(cgContext);
+ m_didSetGraphicsContext = true;
+}
+
+LocalCurrentGraphicsContext::~LocalCurrentGraphicsContext()
+{
+ if (m_didSetGraphicsContext)
+ UIGraphicsPopContext();
+
+ m_savedGraphicsContext.restore();
+}
+
+}
+
+#endif // PLATFORM(IOS_FAMILY)
Deleted: trunk/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.h (261441 => 261442)
--- trunk/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.h 2020-05-09 22:40:13 UTC (rev 261441)
+++ trunk/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.h 2020-05-09 23:10:41 UTC (rev 261442)
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#pragma once
-
-#include "GraphicsContext.h"
-#include <wtf/Noncopyable.h>
-
-#if USE(APPKIT)
-
-OBJC_CLASS NSGraphicsContext;
-
-namespace WebCore {
-
-// This class automatically saves and restores the current NSGraphicsContext for
-// functions which call out into AppKit and rely on the currentContext being set
-class LocalCurrentGraphicsContext {
- WTF_MAKE_NONCOPYABLE(LocalCurrentGraphicsContext);
-public:
- WEBCORE_EXPORT LocalCurrentGraphicsContext(GraphicsContext&);
- WEBCORE_EXPORT ~LocalCurrentGraphicsContext();
- CGContextRef cgContext();
-private:
- GraphicsContext& m_savedGraphicsContext;
- NSGraphicsContext* m_savedNSGraphicsContext;
- bool m_didSetGraphicsContext;
-};
-
-class ContextContainer {
- WTF_MAKE_NONCOPYABLE(ContextContainer);
-public:
- ContextContainer(GraphicsContext& graphicsContext)
- : m_graphicsContext(graphicsContext.platformContext())
- {
- }
-
- CGContextRef context() { return m_graphicsContext; }
-private:
- PlatformGraphicsContext* m_graphicsContext;
-};
-
-}
-
-#endif // USE(APPKIT)
Deleted: trunk/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.mm (261441 => 261442)
--- trunk/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.mm 2020-05-09 22:40:13 UTC (rev 261441)
+++ trunk/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.mm 2020-05-09 23:10:41 UTC (rev 261442)
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#import "config.h"
-#import "LocalCurrentGraphicsContext.h"
-
-#if USE(APPKIT)
-
-#import <AppKit/NSGraphicsContext.h>
-
-namespace WebCore {
-
-LocalCurrentGraphicsContext::LocalCurrentGraphicsContext(GraphicsContext& graphicsContext)
- : m_savedGraphicsContext(graphicsContext)
- , m_didSetGraphicsContext(false)
-{
- graphicsContext.save();
-
- if (!graphicsContext.hasPlatformContext()) {
- WTFLogAlways("LocalCurrentGraphicsContext is not setting the global context because the provided GraphicsContext does not have a platform context (likely display list recording)");
- m_savedNSGraphicsContext = nil;
- return;
- }
-
- CGContextRef cgContext = this->cgContext();
- if (cgContext == [[NSGraphicsContext currentContext] CGContext]) {
- m_savedNSGraphicsContext = nil;
- return;
- }
-
- m_savedNSGraphicsContext = [[NSGraphicsContext currentContext] retain];
- NSGraphicsContext* newContext = [NSGraphicsContext graphicsContextWithCGContext:cgContext flipped:YES];
- [NSGraphicsContext setCurrentContext:newContext];
- m_didSetGraphicsContext = true;
-}
-
-LocalCurrentGraphicsContext::~LocalCurrentGraphicsContext()
-{
- if (m_didSetGraphicsContext) {
- [NSGraphicsContext setCurrentContext:m_savedNSGraphicsContext];
- [m_savedNSGraphicsContext release];
- }
-
- m_savedGraphicsContext.restore();
-}
-
-CGContextRef LocalCurrentGraphicsContext::cgContext()
-{
- CGContextRef cgContext = m_savedGraphicsContext.platformContext();
- return cgContext;
-}
-
-}
-
-#endif // USE(APPKIT)
Copied: trunk/Source/WebCore/platform/mac/LocalCurrentGraphicsContextMac.mm (from rev 261441, trunk/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.mm) (0 => 261442)
--- trunk/Source/WebCore/platform/mac/LocalCurrentGraphicsContextMac.mm (rev 0)
+++ trunk/Source/WebCore/platform/mac/LocalCurrentGraphicsContextMac.mm 2020-05-09 23:10:41 UTC (rev 261442)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2006-2020 Apple Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#import "config.h"
+#import "LocalCurrentGraphicsContext.h"
+
+#if USE(APPKIT)
+
+#import <AppKit/NSGraphicsContext.h>
+
+namespace WebCore {
+
+LocalCurrentGraphicsContext::LocalCurrentGraphicsContext(GraphicsContext& graphicsContext)
+ : m_savedGraphicsContext(graphicsContext)
+{
+ m_savedGraphicsContext.save();
+
+ if (!m_savedGraphicsContext.hasPlatformContext()) {
+ WTFLogAlways("LocalCurrentGraphicsContext is not setting the global context because the provided GraphicsContext does not have a platform context (likely display list recording)");
+ return;
+ }
+
+ CGContextRef cgContext = this->cgContext();
+ if (cgContext == [[NSGraphicsContext currentContext] CGContext])
+ return;
+
+ m_savedNSGraphicsContext = [NSGraphicsContext currentContext];
+ NSGraphicsContext* newContext = [NSGraphicsContext graphicsContextWithCGContext:cgContext flipped:YES];
+ [NSGraphicsContext setCurrentContext:newContext];
+ m_didSetGraphicsContext = true;
+}
+
+LocalCurrentGraphicsContext::~LocalCurrentGraphicsContext()
+{
+ if (m_didSetGraphicsContext)
+ [NSGraphicsContext setCurrentContext:m_savedNSGraphicsContext.get()];
+
+ m_savedGraphicsContext.restore();
+}
+
+}
+
+#endif // USE(APPKIT)
Modified: trunk/Source/WebKit/ChangeLog (261441 => 261442)
--- trunk/Source/WebKit/ChangeLog 2020-05-09 22:40:13 UTC (rev 261441)
+++ trunk/Source/WebKit/ChangeLog 2020-05-09 23:10:41 UTC (rev 261442)
@@ -1,3 +1,28 @@
+2020-05-09 David Kilzer <[email protected]>
+
+ Adapt LocalCurrentGraphicsContext for iOS
+ <https://webkit.org/b/211660>
+
+ Reviewed by Darin Adler.
+
+ * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+ (WebKit::convertPlatformImageToBitmap):
+ - Use LocalCurrentGraphicsContext for both iOS and Mac code
+ paths.
+
+ * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
+ - Switch from PLATFORM(MAC) and PLATFORM(IOS_FAMIY) to
+ USE(APPKIT) to separate platform code.
+ (WebKit::convertDragImageToBitmap):
+ (WebKit::convertImageToBitmap): Delete.
+ (WebKit::convertCGImageToBitmap): Delete.
+ - Combine Mac-specific convertImageToBitmap() and iOS-specific
+ convertCGImageToBitmap() into a single method using DragImage
+ type and special-casing one line of code.
+ (WebKit::WebDragClient::startDrag):
+ (WebKit::WebDragClient::didConcludeEditDrag):
+ - Combine iOS and Mac methods into a singe method.
+
2020-05-09 David Quesada <[email protected]>
Remove HAVE_UI_SCROLL_VIEW_INDICATOR_FLASHING_SPI
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (261441 => 261442)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2020-05-09 22:40:13 UTC (rev 261441)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2020-05-09 23:10:41 UTC (rev 261442)
@@ -385,14 +385,13 @@
if (!graphicsContext)
return nullptr;
+ LocalCurrentGraphicsContext savedContext(*graphicsContext);
#if PLATFORM(IOS_FAMILY)
- UIGraphicsPushContext(graphicsContext->platformContext());
[image drawInRect:CGRectMake(0, 0, bitmap->size().width(), bitmap->size().height())];
- UIGraphicsPopContext();
#elif USE(APPKIT)
- LocalCurrentGraphicsContext savedContext(*graphicsContext);
[image drawInRect:NSMakeRect(0, 0, bitmap->size().width(), bitmap->size().height()) fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1 respectFlipped:YES hints:nil];
#endif
+
return bitmap;
}
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm (261441 => 261442)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm 2020-05-09 22:40:13 UTC (rev 261441)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm 2020-05-09 23:10:41 UTC (rev 261442)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2020 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,6 +43,7 @@
#import <WebCore/FrameView.h>
#import <WebCore/GraphicsContextCG.h>
#import <WebCore/LegacyWebArchive.h>
+#import <WebCore/LocalCurrentGraphicsContext.h>
#import <WebCore/NotImplemented.h>
#import <WebCore/Page.h>
#import <WebCore/Pasteboard.h>
@@ -58,9 +59,13 @@
namespace WebKit {
using namespace WebCore;
-#if PLATFORM(MAC)
+#if USE(APPKIT)
+using DragImage = NSImage *;
+#else
+using DragImage = CGImageRef;
+#endif
-static RefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image, const IntSize& size, Frame& frame)
+static RefPtr<ShareableBitmap> convertDragImageToBitmap(DragImage image, const IntSize& size, Frame& frame)
{
ShareableBitmap::Configuration bitmapConfiguration;
bitmapConfiguration.colorSpace.cgColorSpace = screenColorSpace(frame.mainFrame().view());
@@ -72,27 +77,26 @@
if (!graphicsContext)
return nullptr;
- RetainPtr<NSGraphicsContext> savedContext = [NSGraphicsContext currentContext];
-
- ALLOW_DEPRECATED_DECLARATIONS_BEGIN
- [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:graphicsContext->platformContext() flipped:YES]];
- ALLOW_DEPRECATED_DECLARATIONS_END
+ LocalCurrentGraphicsContext savedContext(*graphicsContext);
+#if USE(APPKIT)
[image drawInRect:NSMakeRect(0, 0, bitmap->size().width(), bitmap->size().height()) fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1 respectFlipped:YES hints:nil];
+#else
+ CGContextDrawImage(graphicsContext->platformContext(), CGRectMake(0, 0, size.width(), size.height()), image);
+#endif
- [NSGraphicsContext setCurrentContext:savedContext.get()];
-
return bitmap;
}
-void WebDragClient::didConcludeEditDrag()
-{
-}
-
void WebDragClient::startDrag(DragItem dragItem, DataTransfer&, Frame& frame)
{
auto& image = dragItem.image;
+
+#if USE(APPKIT)
IntSize bitmapSize([image.get() size]);
- RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get().get(), bitmapSize, frame);
+#else
+ IntSize bitmapSize(CGImageGetWidth(image.get().get()), CGImageGetHeight(image.get().get()));
+#endif
+ auto bitmap = convertDragImageToBitmap(image.get().get(), bitmapSize, frame);
ShareableBitmap::Handle handle;
if (!bitmap || !bitmap->createHandle(handle))
return;
@@ -101,6 +105,15 @@
m_page->send(Messages::WebPageProxy::StartDrag(dragItem, handle));
}
+void WebDragClient::didConcludeEditDrag()
+{
+#if PLATFORM(IOS_FAMILY)
+ m_page->didConcludeEditDrag();
+#endif
+}
+
+#if USE(APPKIT)
+
static WebCore::CachedImage* cachedImage(Element& element)
{
auto* renderer = element.renderer();
@@ -171,42 +184,8 @@
m_page->send(Messages::WebPageProxy::SetPromisedDataForImage(pasteboardName, imageHandle, imageSize, filename, extension, title, String([[response URL] absoluteString]), WTF::userVisibleString(url), archiveHandle, archiveSize));
}
-#endif // PLATFORM(MAC)
+#else
-#if PLATFORM(IOS_FAMILY)
-
-static RefPtr<ShareableBitmap> convertCGImageToBitmap(CGImageRef image, const IntSize& size, Frame& frame)
-{
- ShareableBitmap::Configuration bitmapConfiguration;
- bitmapConfiguration.colorSpace.cgColorSpace = screenColorSpace(frame.mainFrame().view());
- auto bitmap = ShareableBitmap::createShareable(size, bitmapConfiguration);
- if (!bitmap)
- return nullptr;
-
- auto graphicsContext = bitmap->createGraphicsContext();
- if (!graphicsContext)
- return nullptr;
-
- UIGraphicsPushContext(graphicsContext->platformContext());
- CGContextDrawImage(graphicsContext->platformContext(), CGRectMake(0, 0, size.width(), size.height()), image);
- UIGraphicsPopContext();
- return bitmap;
-}
-
-void WebDragClient::startDrag(DragItem dragItem, DataTransfer& dataTransfer, Frame& frame)
-{
- auto& image = dragItem.image;
-
- IntSize bitmapSize(CGImageGetWidth(image.get().get()), CGImageGetHeight(image.get().get()));
- auto bitmap = convertCGImageToBitmap(image.get().get(), bitmapSize, frame);
- ShareableBitmap::Handle handle;
- if (!bitmap || !bitmap->createHandle(handle))
- return;
-
- m_page->willStartDrag();
- m_page->send(Messages::WebPageProxy::StartDrag(dragItem, handle));
-}
-
void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, Element& element, const URL& url, const String& label, Frame*)
{
if (auto frame = element.document().frame())
@@ -213,13 +192,8 @@
frame->editor().writeImageToPasteboard(*Pasteboard::createForDragAndDrop(), element, url, label);
}
-void WebDragClient::didConcludeEditDrag()
-{
- m_page->didConcludeEditDrag();
-}
+#endif // USE(APPKIT)
-#endif // PLATFORM(IOS_FAMILY)
-
} // namespace WebKit
#endif // ENABLE(DRAG_SUPPORT)