Title: [261210] trunk/Source
Revision
261210
Author
[email protected]
Date
2020-05-05 20:45:38 -0700 (Tue, 05 May 2020)

Log Message

Fix deprecated NSGraphicsContext methods using 'graphicsPort'
<https://webkit.org/b/211481>

Reviewed by Darin Adler.

- Replace uses of -graphicsPort with -CGContext.
- Replace uses of -graphicsContextWithGraphicsPort:flipped: with
  -graphicsContextWithCGContext:flipped:.
- Remove ALLOW_DEPRECATED_DECLARATIONS_{BEGIN,END} if possible.

Source/WebCore:

* platform/cocoa/DragImageCocoa.mm:
(WebCore::createDragImageForLink):
* platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
(WebCore::PlatformCALayer::drawLayerContents):
* platform/mac/ThemeMac.mm:
(WebCore::drawCellFocusRingWithFrameAtTime):
* platform/mac/WidgetMac.mm:
(WebCore::Widget::paint):

Source/WebKit:

* UIProcess/mac/WKPrintingView.mm:
(-[WKPrintingView _drawPDFDocument:page:atPoint:]):
(-[WKPrintingView _drawPreview:]):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::drawPDFPage):

Source/WebKitLegacy/mac:

* Misc/WebKitNSStringExtras.mm:
(-[NSString _web_drawAtPoint:font:textColor:]):
* Plugins/Hosted/WebHostedNetscapePluginView.mm:
(-[WebHostedNetscapePluginView drawRect:]):
* Plugins/WebNetscapePluginView.mm:
(-[WebNetscapePluginView saveAndSetNewPortStateForUpdate:]):
(-[WebNetscapePluginView sendDrawRectEvent:]):
* WebInspector/WebNodeHighlightView.mm:
(-[WebNodeHighlightView drawRect:]):
* WebView/WebFrame.mm:
(-[WebFrame _drawRect:contentsOnly:]):
* WebView/WebPDFView.mm:
(-[WebPDFView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]):
(-[WebPDFView _recursiveDisplayAllDirtyWithLockFocus:visRect:]):
(-[WebPDFView _recursive:displayRectIgnoringOpacity:inContext:topView:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (261209 => 261210)


--- trunk/Source/WebCore/ChangeLog	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebCore/ChangeLog	2020-05-06 03:45:38 UTC (rev 261210)
@@ -1,3 +1,24 @@
+2020-05-05  David Kilzer  <[email protected]>
+
+        Fix deprecated NSGraphicsContext methods using 'graphicsPort'
+        <https://webkit.org/b/211481>
+
+        Reviewed by Darin Adler.
+
+        - Replace uses of -graphicsPort with -CGContext.
+        - Replace uses of -graphicsContextWithGraphicsPort:flipped: with
+          -graphicsContextWithCGContext:flipped:.
+        - Remove ALLOW_DEPRECATED_DECLARATIONS_{BEGIN,END} if possible.
+
+        * platform/cocoa/DragImageCocoa.mm:
+        (WebCore::createDragImageForLink):
+        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
+        (WebCore::PlatformCALayer::drawLayerContents):
+        * platform/mac/ThemeMac.mm:
+        (WebCore::drawCellFocusRingWithFrameAtTime):
+        * platform/mac/WidgetMac.mm:
+        (WebCore::Widget::paint):
+
 2020-05-05  Pinki Gyanchandani  <[email protected]>
 
         Crash in match_constness<WebCore::CSSValue, WebCore::CSSPrimitiveValue>::type& WTF::downcast<WebCore::CSSPrimitiveValue, WebCore::CSSValue> -- ASAN

Modified: trunk/Source/WebCore/platform/cocoa/DragImageCocoa.mm (261209 => 261210)


--- trunk/Source/WebCore/platform/cocoa/DragImageCocoa.mm	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebCore/platform/cocoa/DragImageCocoa.mm	2020-05-06 03:45:38 UTC (rev 261210)
@@ -298,9 +298,7 @@
     RetainPtr<NSImage> dragImage = adoptNS([[NSImage alloc] initWithSize:imageSize]);
     [dragImage _web_lockFocusWithDeviceScaleFactor:deviceScaleFactor];
 
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    GraphicsContext context((CGContextRef)[NSGraphicsContext currentContext].graphicsPort);
-    ALLOW_DEPRECATED_DECLARATIONS_END
+    GraphicsContext context([NSGraphicsContext currentContext].CGContext);
 
     context.fillRoundedRect(FloatRoundedRect(layout.boundingRect, FloatRoundedRect::Radii(linkImageCornerRadius)), colorFromNSColor([NSColor controlBackgroundColor]));
 

Modified: trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm (261209 => 261210)


--- trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm	2020-05-06 03:45:38 UTC (rev 261210)
@@ -1186,9 +1186,7 @@
 
         // Set up an NSGraphicsContext for the context, so that parts of AppKit that rely on
         // the current NSGraphicsContext (e.g. NSCell drawing) get the right one.
-        ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-        NSGraphicsContext* layerContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:YES];
-        ALLOW_DEPRECATED_DECLARATIONS_END
+        NSGraphicsContext* layerContext = [NSGraphicsContext graphicsContextWithCGContext:context flipped:YES];
         [NSGraphicsContext setCurrentContext:layerContext];
 #endif
     }

Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (261209 => 261210)


--- trunk/Source/WebCore/platform/mac/ThemeMac.mm	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm	2020-05-06 03:45:38 UTC (rev 261210)
@@ -387,9 +387,7 @@
 
 static bool drawCellFocusRingWithFrameAtTime(NSCell *cell, NSRect cellFrame, NSView *controlView, NSTimeInterval timeOffset)
 {
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
-    ALLOW_DEPRECATED_DECLARATIONS_END
+    CGContextRef cgContext = [[NSGraphicsContext currentContext] CGContext];
 
     CGContextStateSaver stateSaver(cgContext);
 

Modified: trunk/Source/WebCore/platform/mac/WidgetMac.mm (261209 => 261210)


--- trunk/Source/WebCore/platform/mac/WidgetMac.mm	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebCore/platform/mac/WidgetMac.mm	2020-05-06 03:45:38 UTC (rev 261210)
@@ -239,9 +239,7 @@
     }
 
     CGContextRef cgContext = p.platformContext();
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    ASSERT(cgContext == [currentContext graphicsPort]);
-    ALLOW_DEPRECATED_DECLARATIONS_END
+    ASSERT(cgContext == [currentContext CGContext]);
     CGContextSaveGState(cgContext);
 
     NSRect viewFrame = [view frame];
@@ -255,9 +253,7 @@
 
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     {
-        ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-        NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:cgContext flipped:NO];
-        ALLOW_DEPRECATED_DECLARATIONS_END
+        NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithCGContext:cgContext flipped:NO];
         [view displayRectIgnoringOpacity:[view convertRect:r fromView:[view superview]] inContext:nsContext];
     }
     END_BLOCK_OBJC_EXCEPTIONS;

Modified: trunk/Source/WebKit/ChangeLog (261209 => 261210)


--- trunk/Source/WebKit/ChangeLog	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebKit/ChangeLog	2020-05-06 03:45:38 UTC (rev 261210)
@@ -1,3 +1,21 @@
+2020-05-05  David Kilzer  <[email protected]>
+
+        Fix deprecated NSGraphicsContext methods using 'graphicsPort'
+        <https://webkit.org/b/211481>
+
+        Reviewed by Darin Adler.
+
+        - Replace uses of -graphicsPort with -CGContext.
+        - Replace uses of -graphicsContextWithGraphicsPort:flipped: with
+          -graphicsContextWithCGContext:flipped:.
+        - Remove ALLOW_DEPRECATED_DECLARATIONS_{BEGIN,END} if possible.
+
+        * UIProcess/mac/WKPrintingView.mm:
+        (-[WKPrintingView _drawPDFDocument:page:atPoint:]):
+        (-[WKPrintingView _drawPreview:]):
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::drawPDFPage):
+
 2020-05-05  Zalan Bujtas  <[email protected]>
 
         [Quirk] Job listing page goes blank when scrolling on stackoverflow.com

Modified: trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm (261209 => 261210)


--- trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm	2020-05-06 03:45:38 UTC (rev 261210)
@@ -457,10 +457,7 @@
         return;
     }
 
-    NSGraphicsContext *nsGraphicsContext = [NSGraphicsContext currentContext];
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    CGContextRef context = static_cast<CGContextRef>([nsGraphicsContext graphicsPort]);
-    ALLOW_DEPRECATED_DECLARATIONS_END
+    CGContextRef context = [[NSGraphicsContext currentContext] CGContext];
 
     CGContextSaveGState(context);
     CGContextTranslateCTM(context, point.x, point.y);
@@ -546,11 +543,8 @@
     }
 
     RefPtr<WebKit::ShareableBitmap> bitmap = pagePreviewIterator->value;
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    CGContextRef cgContext = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
-    ALLOW_DEPRECATED_DECLARATIONS_END
 
-    WebCore::GraphicsContext context(cgContext);
+    WebCore::GraphicsContext context([[NSGraphicsContext currentContext] CGContext]);
     WebCore::GraphicsContextStateSaver stateSaver(context);
 
     bitmap->paint(context, _webFrame->page()->deviceScaleFactor(), WebCore::IntPoint(nsRect.origin), bitmap->bounds());

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (261209 => 261210)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2020-05-06 03:45:38 UTC (rev 261210)
@@ -712,8 +712,8 @@
     }
 
     [NSGraphicsContext saveGraphicsState];
+    [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithCGContext:context flipped:NO]];
     ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO]];
     [pdfPage drawWithBox:kPDFDisplayBoxCropBox];
     ALLOW_DEPRECATED_DECLARATIONS_END
     [NSGraphicsContext restoreGraphicsState];

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (261209 => 261210)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2020-05-06 03:45:38 UTC (rev 261210)
@@ -1,3 +1,31 @@
+2020-05-05  David Kilzer  <[email protected]>
+
+        Fix deprecated NSGraphicsContext methods using 'graphicsPort'
+        <https://webkit.org/b/211481>
+
+        Reviewed by Darin Adler.
+
+        - Replace uses of -graphicsPort with -CGContext.
+        - Replace uses of -graphicsContextWithGraphicsPort:flipped: with
+          -graphicsContextWithCGContext:flipped:.
+        - Remove ALLOW_DEPRECATED_DECLARATIONS_{BEGIN,END} if possible.
+
+        * Misc/WebKitNSStringExtras.mm:
+        (-[NSString _web_drawAtPoint:font:textColor:]):
+        * Plugins/Hosted/WebHostedNetscapePluginView.mm:
+        (-[WebHostedNetscapePluginView drawRect:]):
+        * Plugins/WebNetscapePluginView.mm:
+        (-[WebNetscapePluginView saveAndSetNewPortStateForUpdate:]):
+        (-[WebNetscapePluginView sendDrawRectEvent:]):
+        * WebInspector/WebNodeHighlightView.mm:
+        (-[WebNodeHighlightView drawRect:]):
+        * WebView/WebFrame.mm:
+        (-[WebFrame _drawRect:contentsOnly:]):
+        * WebView/WebPDFView.mm:
+        (-[WebPDFView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]):
+        (-[WebPDFView _recursiveDisplayAllDirtyWithLockFocus:visRect:]):
+        (-[WebPDFView _recursive:displayRectIgnoringOpacity:inContext:topView:]):
+
 2020-05-05  Peng Liu  <[email protected]>
 
         Update WebKitTestRunner to support running multiple video fullscreen and Picture-in-Picture tests simultaneously

Modified: trunk/Source/WebKitLegacy/mac/Misc/WebKitNSStringExtras.mm (261209 => 261210)


--- trunk/Source/WebKitLegacy/mac/Misc/WebKitNSStringExtras.mm	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebKitLegacy/mac/Misc/WebKitNSStringExtras.mm	2020-05-06 03:45:38 UTC (rev 261210)
@@ -77,9 +77,7 @@
         point.y = CGCeiling(point.y);
 
         NSGraphicsContext *nsContext = [NSGraphicsContext currentContext];
-        ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-        CGContextRef cgContext = static_cast<CGContextRef>([nsContext graphicsPort]);
-        ALLOW_DEPRECATED_DECLARATIONS_END
+        CGContextRef cgContext = [nsContext CGContext];
         GraphicsContext graphicsContext { cgContext };
 
         // WebCore requires a flipped graphics context.

Modified: trunk/Source/WebKitLegacy/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm (261209 => 261210)


--- trunk/Source/WebKitLegacy/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebKitLegacy/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm	2020-05-06 03:45:38 UTC (rev 261210)
@@ -476,17 +476,15 @@
     }
 
     if (_proxy) {
-        ALLOW_DEPRECATED_DECLARATIONS_BEGIN
         if (_softwareRenderer) {
             if ([NSGraphicsContext currentContextDrawingToScreen]) {
-                _softwareRenderer->render((CGContextRef)[[NSGraphicsContext currentContext] graphicsPort], NSRectToCGRect(rect));
+                _softwareRenderer->render([[NSGraphicsContext currentContext] CGContext], NSRectToCGRect(rect));
                 _proxy->didDraw();
             } else
-                _proxy->print(reinterpret_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]), [self bounds].size.width, [self bounds].size.height);
+                _proxy->print([[NSGraphicsContext currentContext] CGContext], [self bounds].size.width, [self bounds].size.height);
         } else if (_snapshotting && [self supportsSnapshotting]) {
-            _proxy->snapshot(reinterpret_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]), [self bounds].size.width, [self bounds].size.height);
+            _proxy->snapshot([[NSGraphicsContext currentContext] CGContext], [self bounds].size.width, [self bounds].size.height);
         }
-        ALLOW_DEPRECATED_DECLARATIONS_END
 
         return;
     }

Modified: trunk/Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm (261209 => 261210)


--- trunk/Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm	2020-05-06 03:45:38 UTC (rev 261210)
@@ -243,9 +243,7 @@
             
             ASSERT([NSView focusView] == self);
 
-            ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-            CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
-            ALLOW_DEPRECATED_DECLARATIONS_END
+            CGContextRef context = [[NSGraphicsContext currentContext] CGContext];
 
             PortState_CG *cgPortState = (PortState_CG *)malloc(sizeof(PortState_CG));
             portState = (PortState)cgPortState;
@@ -387,9 +385,7 @@
 {
     ASSERT(_eventHandler);
     
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
-    ALLOW_DEPRECATED_DECLARATIONS_END
+    CGContextRef context = [[NSGraphicsContext currentContext] CGContext];
     _eventHandler->drawRect(context, rect);
 }
 

Modified: trunk/Source/WebKitLegacy/mac/WebInspector/WebNodeHighlightView.mm (261209 => 261210)


--- trunk/Source/WebKitLegacy/mac/WebInspector/WebNodeHighlightView.mm	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebKitLegacy/mac/WebInspector/WebNodeHighlightView.mm	2020-05-06 03:45:38 UTC (rev 261210)
@@ -98,9 +98,7 @@
 
         ASSERT([[NSGraphicsContext currentContext] isFlipped]);
 
-        ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-        GraphicsContext context((PlatformGraphicsContext*)[[NSGraphicsContext currentContext] graphicsPort]);
-        ALLOW_DEPRECATED_DECLARATIONS_END
+        GraphicsContext context([[NSGraphicsContext currentContext] CGContext]);
         [_webNodeHighlight inspectorController]->drawHighlight(context);
         [NSGraphicsContext restoreGraphicsState];
     }

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm (261209 => 261210)


--- trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm	2020-05-06 03:45:38 UTC (rev 261210)
@@ -615,9 +615,7 @@
 #if !PLATFORM(IOS_FAMILY)
     ASSERT([[NSGraphicsContext currentContext] isFlipped]);
 
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    CGContextRef ctx = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
-    ALLOW_DEPRECATED_DECLARATIONS_END
+    CGContextRef ctx = [[NSGraphicsContext currentContext] CGContext];
 #else
     CGContextRef ctx = WKGetCurrentGraphicsContext();
 #endif

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPDFView.mm (261209 => 261210)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPDFView.mm	2020-05-06 03:08:43 UTC (rev 261209)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPDFView.mm	2020-05-06 03:45:38 UTC (rev 261210)
@@ -326,9 +326,7 @@
 
 - (void)_recursiveDisplayRectIfNeededIgnoringOpacity:(NSRect)rect isVisibleRect:(BOOL)isVisibleRect rectIsVisibleRectForView:(NSView *)visibleView topView:(BOOL)topView
 {
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
-    ALLOW_DEPRECATED_DECLARATIONS_END
+    CGContextRef context = [[NSGraphicsContext currentContext] CGContext];
     
     bool allowsSmoothing = CGContextGetAllowsFontSmoothing(context);
     bool allowsSubpixelQuantization = CGContextGetAllowsFontSubpixelQuantization(context);
@@ -341,9 +339,7 @@
 
 - (void)_recursiveDisplayAllDirtyWithLockFocus:(BOOL)needsLockFocus visRect:(NSRect)visRect
 {
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
-    ALLOW_DEPRECATED_DECLARATIONS_END
+    CGContextRef context = [[NSGraphicsContext currentContext] CGContext];
     
     bool allowsSmoothing = CGContextGetAllowsFontSmoothing(context);
     bool allowsSubpixelQuantization = CGContextGetAllowsFontSubpixelQuantization(context);
@@ -356,9 +352,7 @@
 
 - (void)_recursive:(BOOL)recurse displayRectIgnoringOpacity:(NSRect)displayRect inContext:(NSGraphicsContext *)graphicsContext topView:(BOOL)topView
 {
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    CGContextRef context = (CGContextRef)[graphicsContext graphicsPort];
-    ALLOW_DEPRECATED_DECLARATIONS_END
+    CGContextRef context = [graphicsContext CGContext];
     
     bool allowsSmoothing = CGContextGetAllowsFontSmoothing(context);
     bool allowsSubpixelQuantization = CGContextGetAllowsFontSubpixelQuantization(context);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to