Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342973 - [editor][chrome]Mouse and cursor don't line up
Summary: [editor][chrome]Mouse and cursor don't line up
Status: RESOLVED FIXED
Alias: None
Product: Orion
Classification: ECD
Component: Client (show other bugs)
Version: 0.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 0.2   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 336178 (view as bug list)
Depends on: 334910
Blocks:
  Show dependency tree
 
Reported: 2011-04-15 09:52 EDT by John Arthorne CLA
Modified: 2011-09-01 11:42 EDT (History)
5 users (show)

See Also:


Attachments
Screen shot (5.25 KB, image/png)
2011-04-15 09:53 EDT, John Arthorne CLA
no flags Details
Screenshot (16.34 KB, image/png)
2011-04-21 05:25 EDT, Szymon Brandys CLA
no flags Details
Screenshot editing HTML file (13.67 KB, image/png)
2011-04-26 17:13 EDT, John Arthorne CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2011-04-15 09:52:06 EDT
Running latest from HEAD as of 20110415
Chrome 10.0.648.204

- Change Chrome's zoom to 120%
- Open an editor on a file of at least several hundred lines
- Go to the bottom of the file, and try selecting something with the mouse

-> Selection occurs a couple of lines lower. There seems to be a problem with calculating line height.
Comment 1 John Arthorne CLA 2011-04-15 09:53:24 EDT
Created attachment 193375 [details]
Screen shot

You can also see the problem looking at the line numbers. This file does have 212 lines, but in the screen shot you can see there are two more lines after the "212" number in the margin. The line numbers aren't matching the lines.
Comment 2 Szymon Brandys CLA 2011-04-21 05:25:24 EDT
Created attachment 193790 [details]
Screenshot

I see the same problem on:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.16) Gecko/20110319 (CK-IBM) Firefox/3.6.16 ( .NET CLR 3.5.30729)

I opened gitCommand.js. Scrolled to the middle of the file. Then I was trying to select with the mouse the line marked with the red arrow on the screenshot. The line below was selected instead.
Comment 3 Felipe Heidrich CLA 2011-04-21 16:14:22 EDT
There a couple for factors causing this problem.
First and more important is that line height is a float number at these zoom levels. We can workaround that by replacing:
_getLineHeight: function() {
	var document = this._frameDocument;
	var body = document.body;
	return parseInt(body.style.lineHeight, 10);
},
By:
_getLineHeight: function() {
	var document = this._frameDocument;
	var body = document.body;
	var lineHeight = parseFloat(body.style.lineHeight);
	return Math.round(lineHeight);
},

Not sure this is enterily correct, maybe Math.ceil is better here. 
The real height is the height for the line div.

The other problem is that, on Chrome, at 120% zoom lines with bold are taller than lines without bold. This can only be fixed with Bug 334910.
Comment 4 John Arthorne CLA 2011-04-26 17:13:28 EDT
Created attachment 194110 [details]
Screenshot editing HTML file

Another symptom seems to be that the cursor is totally broken when editing HTML files at 120% zoom on chrome. See in this screen shot the cursor is on line 1, but the status line shows the cursor is on line 4. If I start typing the characters appear on line 4. Basically the arrow keys don't seem to move the cursor. At 100% zoom it is fine, and it is fine in FireFox 4.
Comment 5 Felipe Heidrich CLA 2011-04-28 16:53:38 EDT
We fixed a couple problems on the code with CSS pixel versus screen pixel, but the problem with bold fonts will only be fixed when we fix bug 334910.
If you remove bold from the CSS file you should be able to use the editor with zoom.
Comment 6 Silenio Quarti CLA 2011-05-06 15:42:52 EDT
We add support for bold,italic,bold|italic styling without implementing variable line height. Please try the latest.

Fixed
http://git.eclipse.org/c/e4/org.eclipse.orion.client.git/commit/?id=72cb95a23a0216ca2d89974ea81d212f30da002f
Comment 7 Silenio Quarti CLA 2011-05-06 15:45:06 EDT
*** Bug 344751 has been marked as a duplicate of this bug. ***
Comment 8 Felipe Heidrich CLA 2011-05-06 15:46:06 EDT
*** Bug 336178 has been marked as a duplicate of this bug. ***