Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2017-11-14 13:24:53 +0000
committerLakshmi Shanmugam2017-11-15 17:23:32 +0000
commitc3e3b10064d80fba27e34154f06a6ca0e75e381a (patch)
treeb2b46c0fdaa67acbbe79b94b255572e01736cb02
parent3158cee8fcdcf63868233c52d34e491637e77634 (diff)
downloadeclipse.platform.swt-c3e3b10064d80fba27e34154f06a6ca0e75e381a.tar.gz
eclipse.platform.swt-c3e3b10064d80fba27e34154f06a6ca0e75e381a.tar.xz
eclipse.platform.swt-c3e3b10064d80fba27e34154f06a6ca0e75e381a.zip
[Bug 525465] TextLayout with embedded images is missing text on macOS
High Sierra NSTextAttachmentCellProtocol has a new and required property "attachment" since 10.11. Added attachment method to SWTTextAttachmentCell for macOS version >= 10.13 Change-Id: I9b0686db3c90e6b7b8d5fd4db0a0c2b1c27d19ac
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java12
6 files changed, 51 insertions, 1 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
index b62f41243f..e51c88f093 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
@@ -67,6 +67,34 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(AcquireRootMenu)
}
#endif
+#ifndef NO_CALLBACK_1NSTextAttachmentCell_1attachment
+static jintLong CALLBACK_1NSTextAttachmentCell_1attachment;
+static id proc_CALLBACK_1NSTextAttachmentCell_1attachment(id arg0, SEL arg1) {
+ id* lprc = ((id* (*)(id, SEL))CALLBACK_1NSTextAttachmentCell_1attachment)(arg0, arg1);
+ id rc;
+ if (lprc) {
+ rc = *lprc;
+ free(lprc);
+ } else {
+ memset(&rc, 0, sizeof(id));
+ }
+ return rc;
+}
+static jintLong CALLBACK_NSTextAttachmentCell_attachment(jintLong func) {
+ CALLBACK_1NSTextAttachmentCell_1attachment = func;
+ return (jintLong)proc_CALLBACK_1NSTextAttachmentCell_1attachment;
+}
+JNIEXPORT jintLong JNICALL OS_NATIVE(CALLBACK_1NSTextAttachmentCell_1attachment)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, CALLBACK_1NSTextAttachmentCell_1attachment_FUNC);
+ rc = (jintLong)CALLBACK_NSTextAttachmentCell_attachment(arg0);
+ OS_NATIVE_EXIT(env, that, CALLBACK_1NSTextAttachmentCell_1attachment_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_CALLBACK_1NSTextAttachmentCell_1cellSize
static jintLong CALLBACK_1NSTextAttachmentCell_1cellSize;
static NSSize proc_CALLBACK_1NSTextAttachmentCell_1cellSize(id arg0, SEL arg1) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
index bac2ebb6a5..a06a43555f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
@@ -20,6 +20,7 @@
char * OS_nativeFunctionNames[] = {
"ATSFontActivateFromFileReference",
"AcquireRootMenu",
+ "CALLBACK_1NSTextAttachmentCell_1attachment",
"CALLBACK_1NSTextAttachmentCell_1cellSize",
"CALLBACK_1accessibilityHitTest_1",
"CALLBACK_1attributedSubstringFromRange_1",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
index 3fcc56dfe6..48abe67c8e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
@@ -30,6 +30,7 @@ extern char* OS_nativeFunctionNames[];
typedef enum {
ATSFontActivateFromFileReference_FUNC,
AcquireRootMenu_FUNC,
+ CALLBACK_1NSTextAttachmentCell_1attachment_FUNC,
CALLBACK_1NSTextAttachmentCell_1cellSize_FUNC,
CALLBACK_1accessibilityHitTest_1_FUNC,
CALLBACK_1attributedSubstringFromRange_1_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
index db372d3163..6c40792616 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
@@ -5446,6 +5446,11 @@
<arg swt_gen="true"></arg>
</method>
</informal_protocol>
+ <informal_protocol name="NSTextAttachmentCell" swt_gen="mixed">
+ <method selector="attachment" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
+ </informal_protocol>
<informal_protocol name="NSTextDelegate" swt_gen="mixed">
<method selector="textDidChange:" swt_gen="true">
<arg swt_gen="true"></arg>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
index fcd14ea7c8..32546f2a7f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
@@ -146,7 +146,8 @@ public class OS extends C {
public static final native long /*int*/ CALLBACK_cellBaselineOffset(long /*int*/ func);
/** @method callback_types=NSSize;id;SEL;,callback_flags=struct;none;none; */
public static final native long /*int*/ CALLBACK_NSTextAttachmentCell_cellSize(long /*int*/ func);
- public static final long /*int*/ protocol_NSTextAttachmentCell = objc_getProtocol("NSTextAttachmentCell");
+ /** @method callback_types=id;id;SEL;,callback_flags=struct;none;none; */
+ public static final native long /*int*/ CALLBACK_NSTextAttachmentCell_attachment(long /*int*/ func);
public static final long /*int*/ sel_cellBaselineOffset = sel_registerName("cellBaselineOffset");
/*10.6 Accessibility Strings*/
@@ -932,6 +933,7 @@ public static final long /*int*/ protocol_NSTabViewDelegate = objc_getProtocol("
public static final long /*int*/ protocol_NSTableDataSource = objc_getProtocol("NSTableDataSource");
public static final long /*int*/ protocol_NSTableViewDelegate = objc_getProtocol("NSTableViewDelegate");
public static final long /*int*/ protocol_NSTableViewNotifications = objc_getProtocol("NSTableViewNotifications");
+public static final long /*int*/ protocol_NSTextAttachmentCell = objc_getProtocol("NSTextAttachmentCell");
public static final long /*int*/ protocol_NSTextDelegate = objc_getProtocol("NSTextDelegate");
public static final long /*int*/ protocol_NSTextInput = objc_getProtocol("NSTextInput");
public static final long /*int*/ protocol_NSTextViewDelegate = objc_getProtocol("NSTextViewDelegate");
@@ -1046,6 +1048,7 @@ public static final long /*int*/ sel_arrayWithObject_ = sel_registerName("arrayW
public static final long /*int*/ sel_arrowCursor = sel_registerName("arrowCursor");
public static final long /*int*/ sel_ascender = sel_registerName("ascender");
public static final long /*int*/ sel_attachColorList_ = sel_registerName("attachColorList:");
+public static final long /*int*/ sel_attachment = sel_registerName("attachment");
public static final long /*int*/ sel_attribute_atIndex_effectiveRange_ = sel_registerName("attribute:atIndex:effectiveRange:");
public static final long /*int*/ sel_attributedStringValue = sel_registerName("attributedStringValue");
public static final long /*int*/ sel_attributedStringWithAttachment_ = sel_registerName("attributedStringWithAttachment:");
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java
index 715eef6130..0a6ef50216 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java
@@ -1588,6 +1588,16 @@ void initClasses () {
OS.class_addProtocol(cls, OS.protocol_NSTextAttachmentCell);
OS.class_addMethod(cls, OS.sel_cellSize, cellSizeProc, "@:");
OS.class_addMethod(cls, OS.sel_cellBaselineOffset, cellBaselineOffsetProc, "@:");
+ /*
+ * On macOS 10.13, entire text after an attachment goes missing.
+ * NSTextAttachmentCellProtocol has a new and required property 'attachment'
+ * since 10.11 and attachment method has to be added to SWTTextAttachmentCell.
+ * Adding it for versions >= 10.13, as this is broken from 10.13 only.
+ */
+ if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 13, 0)) {
+ long /*int*/ attachmentProc = OS.CALLBACK_NSTextAttachmentCell_attachment(proc2);
+ OS.class_addMethod(cls, OS.sel_attachment, attachmentProc, "@:");
+ }
OS.objc_registerClassPair(cls);
}
@@ -2226,6 +2236,8 @@ static long /*int*/ textLayoutProc(long /*int*/ id, long /*int*/ sel) {
long /*int*/ result = OS.malloc(NSPoint.sizeof);
OS.memmove(result, point, NSPoint.sizeof);
return result;
+ } else if (sel == OS.sel_attachment) {
+ return 0;
}
return 0;
}

Back to the top