Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2017-11-14 13:24:53 +0000
committerLakshmi Shanmugam2017-11-14 20:44:08 +0000
commit9efbe4a8235bbb98fd1e36720eea53d0f012e240 (patch)
tree27be09718cec4dccd2f7fdf84a3c182aab3dbccd
parent4dee7f187eee7c8e55df2ad89a3d32263613e17c (diff)
downloadeclipse.platform.swt-9efbe4a8235bbb98fd1e36720eea53d0f012e240.tar.gz
eclipse.platform.swt-9efbe4a8235bbb98fd1e36720eea53d0f012e240.tar.xz
eclipse.platform.swt-9efbe4a8235bbb98fd1e36720eea53d0f012e240.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.11 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.java6
6 files changed, 45 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 317dbc57ad..58e3a92bae 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 93dc1a79a1..05d934f65f 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 41d6914200..6d43bdd89c 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 2b26cf05c2..41934477dc 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
@@ -5475,6 +5475,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 59a5bf3c93..3f9d42de39 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
@@ -153,7 +153,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*/
@@ -934,6 +935,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");
@@ -1048,6 +1050,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 ef7d7975bb..ceecaa97da 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,10 @@ 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, "@:");
+ if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 11, 0)) {
+ long /*int*/ attachmentProc = OS.CALLBACK_NSTextAttachmentCell_attachment(proc2);
+ OS.class_addMethod(cls, OS.sel_attachment, attachmentProc, "@:");
+ }
OS.objc_registerClassPair(cls);
}
@@ -2226,6 +2230,8 @@ static long /*int*/ textLayoutProc(long /*int*/ id, long /*int*/ sel) {
long /*int*/ result = C.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