Bug 102584 - [Bidi] Clickable area of Link with mixed direction text is incorrect
Summary: [Bidi] Clickable area of Link with mixed direction text is incorrect
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
: 118431 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-07-03 11:33 EDT by Simon Montagu CLA
Modified: 2017-07-28 09:36 EDT (History)
4 users (show)

See Also:


Attachments
The example link with LEFT_TO_RIGHT orientation (1.56 KB, image/png)
2005-07-03 11:38 EDT, Simon Montagu CLA
no flags Details
The example link with RIGHT_TO_LEFT orientation (1.48 KB, image/png)
2005-07-03 11:38 EDT, Simon Montagu CLA
no flags Details
results (39.26 KB, image/gif)
2005-07-12 14:42 EDT, Felipe Heidrich CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Montagu CLA 2005-07-03 11:33:31 EDT
The anchor inside a Link with mixed directional text can be split into two parts
by Bidi reordering. In this case the clickable area extends from the furthest
left point of the anchor to the furthest right point, including intervening text
which should not be part of the anchor.

Example:
myLink.setText("\u05d1\u05e7\u05e8 \u05d1-<A
HREF=\"www.eclipse.org\">\u05d0\u05ea\u05e8 \u05e9\u05dc Eclipse.org</A> project.");
Comment 1 Simon Montagu CLA 2005-07-03 11:38:05 EDT
Created attachment 24302 [details]
The example link with LEFT_TO_RIGHT orientation
Comment 2 Simon Montagu CLA 2005-07-03 11:38:41 EDT
Created attachment 24303 [details]
The example link with RIGHT_TO_LEFT orientation
Comment 3 Felipe Heidrich CLA 2005-07-12 14:42:29 EDT
Created attachment 24617 [details]
results

When running with the manifest the results are very different, not sure I can
fix it.
See the attachment, on top I've a fixed version of the emulated link and on the
bottom the native syslink. Are the results right ?
Comment 4 Simon Montagu CLA 2005-07-13 03:47:29 EDT
I don't understand the implications of "running with the manifest", but the top
two images in attachment 24617 [details] are what I consider to be the correct results.
Comment 5 Felipe Heidrich CLA 2005-07-13 11:07:51 EDT
Run with the manifest:
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-
home/faq.html#xpthemes
Comment 6 Billy Biggs CLA 2005-11-29 11:58:47 EST
*** Bug 118431 has been marked as a duplicate of this bug. ***
Comment 7 Felipe Heidrich CLA 2005-11-29 14:19:58 EST
Simoen, can I have the text you were using in Bug 118431 ?
Please, encoded it as java literal (see comment 1).
thanks.
Comment 8 Semion Chichelnitsky CLA 2005-11-30 05:01:44 EST
Please:
link1.setText("Visit \u05de\u05d1\u05e7\u05e8 <A HREF=\"www.eclipse.org\">123 \u05d0\u05d1\u05d2 ABC.</A> project and the <A HREF=\"www.eclipse.org\\swt\">\u05d0\u05d1\u05d1 ABC 123.</A> homepage.");
Comment 9 Semion Chichelnitsky CLA 2005-11-30 05:04:43 EST
BTW, what do you think about addidng all bidi markers as constant into SWT class?
Comment 10 Semion Chichelnitsky CLA 2005-11-30 07:20:26 EST
Code from bug 118431 is not good. Here is the better solution:
...
int parseMnemonics (char[] buffer, int start, int end, StringBuffer result) {
	int mnemonic = -1, index = start;
	boolean isMarkerUsed = OS.COMCTL32_MAJOR < 6? false : true;  //bidi
	
	while (index < end) {
		if (buffer [index] == '&') {
			if (index + 1 < end && buffer [index + 1] == '&') {
				if (!isMarkerUsed)                               //bidi
				   isMarkerUsed = checkMarker(result);           //bidi
				result.append (buffer [index]);
				index++;
			} else {
				mnemonic = result.length();
			}
		} else {
			if (!isMarkerUsed)                                   //bidi
			   isMarkerUsed = checkMarker(result);               //bidi
			result.append (buffer [index]);
		}
		index++;
	}
	return mnemonic;
}

boolean checkMarker(StringBuffer result){                       //bidi start
    if ((getStyle() & SWT.RIGHT_TO_LEFT)!= 0)
       result.append('\u200f');            //RLM
    else
       result.append('\u200e');            //LRM
	return true;
}                                                               //bidi end
...
Comment 11 Felipe Heidrich CLA 2008-05-15 15:40:23 EDT
See Bug 223336

The fix proposed in this bug, which is forcing textlayout based link to emulated bidi reordering of the native syslink, will actually introduce bug 223336 to textlayout based link.

We can fix this original problem report in this bug by fixing Link#getRectangles(). Withtout touching the bidi reordering.

Note: nowadays this problem only happens on windows 2000, low priority.
Comment 12 Felipe Heidrich CLA 2009-08-14 14:44:27 EDT
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info.
Comment 13 Eric Williams CLA 2017-07-28 09:36:43 EDT
(In reply to Felipe Heidrich from comment #11)
> Note: nowadays this problem only happens on windows 2000, low priority.

Win2000 is no longer a supported environment. If this issue occurs on a supported environment, please re-open with details to reproduce the issue.