Title: [271694] trunk
Revision
271694
Author
commit-qu...@webkit.org
Date
2021-01-21 09:17:40 -0800 (Thu, 21 Jan 2021)

Log Message

Null check in WebTextIndicatorView::initWithFrame
https://bugs.webkit.org/show_bug.cgi?id=220491

Patch by Rob Buis <rb...@igalia.com> on 2021-01-21
Reviewed by Youenn Fablet.

Source/WebCore:

Null check contentImage/contentImageScaleFactor in initWithFrame
since these are not guaranteed to be non-null.

Test: ipc/set-text-indicator.html

* page/mac/TextIndicatorWindow.mm:
(-[WebTextIndicatorView initWithFrame:textIndicator:margin:offset:]):

LayoutTests:

Add test for this.

* ipc/set-text-indicator-expected.txt: Added.
* ipc/set-text-indicator.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (271693 => 271694)


--- trunk/LayoutTests/ChangeLog	2021-01-21 17:12:19 UTC (rev 271693)
+++ trunk/LayoutTests/ChangeLog	2021-01-21 17:17:40 UTC (rev 271694)
@@ -1,5 +1,17 @@
 2021-01-21  Rob Buis  <rb...@igalia.com>
 
+        Null check in WebTextIndicatorView::initWithFrame
+        https://bugs.webkit.org/show_bug.cgi?id=220491
+
+        Reviewed by Youenn Fablet.
+
+        Add test for this.
+
+        * ipc/set-text-indicator-expected.txt: Added.
+        * ipc/set-text-indicator.html: Added.
+
+2021-01-21  Rob Buis  <rb...@igalia.com>
+
         Null check in RTCRtpSFrameTransform::createStreams
         https://bugs.webkit.org/show_bug.cgi?id=220396
 

Added: trunk/LayoutTests/ipc/set-text-indicator-expected.txt (0 => 271694)


--- trunk/LayoutTests/ipc/set-text-indicator-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/ipc/set-text-indicator-expected.txt	2021-01-21 17:17:40 UTC (rev 271694)
@@ -0,0 +1 @@
+Test passes if it does not crash.

Added: trunk/LayoutTests/ipc/set-text-indicator.html (0 => 271694)


--- trunk/LayoutTests/ipc/set-text-indicator.html	                        (rev 0)
+++ trunk/LayoutTests/ipc/set-text-indicator.html	2021-01-21 17:17:40 UTC (rev 271694)
@@ -0,0 +1,10 @@
+<!DOCTYPE html><!-- webkit-test-runner [ IPCTestingAPIEnabled=true ] -->
+<html>
+Test passes if it does not crash.
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+if (window.IPC)
+    IPC.sendMessage('UI', IPC.webPageProxyID, IPC.messages.WebPageProxy_SetTextIndicator.name, [{type: 'float', value: 598}, {type: 'float', value: 352}, {type: 'float', value: 597}, {type: 'float', value: 948}, {type: 'float', value: 0}, {type: 'float', value: 942}, {type: 'float', value: 233}, {type: 'float', value: 310}, {type: 'Vector', value: [[{type: 'float', value: 0}, {type: 'float', value: 0}, {type: 'float', value: 0}, {type: 'float', value: 0}]]}, {type: 'float', value: 927}, {type: 'float', value: 705}, {type: 'float', value: 498}, {type: 'float', value: 830}, {type: 'float', value: 58}, {type: 'bool', value: 1}, {type: 'float', value: 341}, {type: 'float', value: 1204}, {type: 'float', value: 1292}, {type: 'float', value: 1074}, {type: 'uint8_t', value: 2}, {type: 'uint8_t', value: 2}, {type: 'uint16_t', value: 1}, {type: 'bool', value: 0}, {type: 'bool', value: 0}, {type: 'bool', value: 0}, {type: 'uint64_t', value: 1}]);
+</script>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (271693 => 271694)


--- trunk/Source/WebCore/ChangeLog	2021-01-21 17:12:19 UTC (rev 271693)
+++ trunk/Source/WebCore/ChangeLog	2021-01-21 17:17:40 UTC (rev 271694)
@@ -1,5 +1,20 @@
 2021-01-21  Rob Buis  <rb...@igalia.com>
 
+        Null check in WebTextIndicatorView::initWithFrame
+        https://bugs.webkit.org/show_bug.cgi?id=220491
+
+        Reviewed by Youenn Fablet.
+
+        Null check contentImage/contentImageScaleFactor in initWithFrame
+        since these are not guaranteed to be non-null.
+
+        Test: ipc/set-text-indicator.html
+
+        * page/mac/TextIndicatorWindow.mm:
+        (-[WebTextIndicatorView initWithFrame:textIndicator:margin:offset:]):
+
+2021-01-21  Rob Buis  <rb...@igalia.com>
+
         Ensure createStreams gets valid JSGlobalObject
         https://bugs.webkit.org/show_bug.cgi?id=220396
 

Modified: trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm (271693 => 271694)


--- trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm	2021-01-21 17:12:19 UTC (rev 271693)
+++ trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm	2021-01-21 17:17:40 UTC (rev 271694)
@@ -159,13 +159,16 @@
     self.wantsLayer = YES;
     self.layer.anchorPoint = CGPointZero;
 
-    FloatSize contentsImageLogicalSize = _textIndicator->contentImage()->size();
-    contentsImageLogicalSize.scale(1 / _textIndicator->contentImageScaleFactor());
     RefPtr<NativeImage> contentsImage;
-    if (indicatorWantsContentCrossfade(*_textIndicator))
-        contentsImage = _textIndicator->contentImageWithHighlight()->nativeImage();
-    else
-        contentsImage = _textIndicator->contentImage()->nativeImage();
+    FloatSize contentsImageLogicalSize { 1, 1 };
+    if (auto* contentImage = _textIndicator->contentImage()) {
+        contentsImageLogicalSize = contentImage->size();
+        contentsImageLogicalSize.scale(1 / _textIndicator->contentImageScaleFactor());
+        if (indicatorWantsContentCrossfade(*_textIndicator) && _textIndicator->contentImageWithHighlight())
+            contentsImage = _textIndicator->contentImageWithHighlight()->nativeImage();
+        else
+            contentsImage = contentImage->nativeImage();
+    }
 
     RetainPtr<NSMutableArray> bounceLayers = adoptNS([[NSMutableArray alloc] init]);
 
@@ -229,7 +232,8 @@
         [textLayer setBorderColor:borderColor.get()];
         [textLayer setBorderWidth:borderWidth];
         [textLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
-        [textLayer setContents:(__bridge id)contentsImage->platformImage().get()];
+        if (contentsImage)
+            [textLayer setContents:(__bridge id)contentsImage->platformImage().get()];
 
         RetainPtr<CAShapeLayer> maskLayer = adoptNS([[CAShapeLayer alloc] init]);
         [maskLayer setPath:translatedPath.platformPath()];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to