Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 350820 - [client] Line height is sometimes wrong
Summary: [client] Line height is sometimes wrong
Status: RESOLVED FIXED
Alias: None
Product: Orion
Classification: ECD
Component: Client (show other bugs)
Version: 0.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 0.2   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-30 09:14 EDT by Mihai Sucan CLA
Modified: 2011-09-01 11:41 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mihai Sucan CLA 2011-06-30 09:14:44 EDT
Build Identifier: 

On Ubuntu machines the TextView code seems to calculate an incorrect line height, or perhaps the styling given to the elements is wrong. Some lines that are empty or that have only keywords have a weird bottom padding.

One of the Mozilla QA team members found this bug and made the following screen cast:

http://dl.dropbox.com/u/22633148/codeeditoribm.ogv

This bug affects our integration code pretty badly on Ubuntu.

Reproducible: Always
Comment 1 Mihai Sucan CLA 2011-06-30 13:36:32 EDT
Proposed fix:

https://github.com/eclipse/orion.client/pull/7

The \u200C character causes line heights to be wrong when there are only lines with keywords, or empty lines, and so on. This seems to happen only on Ubuntu with the default fonts. On a system with different font configs I cannot reproduce the issue.

The fix makes Orion use \uFEFF for Firefox. With this patch Orion behaves correctly on Ubuntu as well.

Please note that if using the \uFEFF character in Firefox causes problems on other systems, then I would suggest using an   for all browsers. If needed, set span.style.width to 0. Would this be acceptable?

Please let me know if further changes are needed - we would like this bug fixed as early as possible. Thank you!
Comment 2 Felipe Heidrich CLA 2011-06-30 15:22:45 EDT
This code is very tricky.

Your is not correct because, as you said, FEFF is not always correct (the breaks firefox on mac for instance).

NBSP is not correct because on browsers that do select line delimiter (IE8) it will case the selection to be too big (looks ugly). For that reason, we were using zero-width characters.

span.style.width = "0px" does not work, it is not respected by the browsers. In the past I also had problem setting the size on HTML elements because IE would show resizing grips for them.

Apparently "the best zero-width characters" to use depends on the font, in which case out of luck.

My current thinking is to use " ", and only use FEFF for IE8 when fullSelection=false. 

With fullSelection=true the extra width added  by the training whitespace will be hidden by the selection div.

The only problem I can see is when you start to deal with bidi reordering.

I will have to ask Silenio why we didn't use " " as the default whitespace trailing when we added fullSelection, maybe there was a reason that I'm failing to remember.
Comment 3 Felipe Heidrich CLA 2011-06-30 17:06:49 EDT
I changed the code as this:
http://git.eclipse.org/c/e4/org.eclipse.orion.client.git/commit/?id=f813e768feffac3f31908f866fd78230ecd7c9a9

I tested on 
windows seven: ie9, ff5, chrome, opera
windows vista: ie8, ff3.6
linux: ff, chrome
mac: safari, ff, chrome

It all looked good to me.

Mihai, please let me know if the current code solves the problem for you.
(I will only be back in the office Tuesday, lets fix that mac keybinding next)
Comment 4 Mihai Sucan CLA 2011-07-01 07:20:38 EDT
(In reply to comment #3)
> I changed the code as this:
> http://git.eclipse.org/c/e4/org.eclipse.orion.client.git/commit/?id=f813e768feffac3f31908f866fd78230ecd7c9a9
> 
> I tested on 
> windows seven: ie9, ff5, chrome, opera
> windows vista: ie8, ff3.6
> linux: ff, chrome
> mac: safari, ff, chrome
> 
> It all looked good to me.

I have tested in Ubuntu 10.04 LTS non-clean install (my workstation). Firefox 7 nightly and Opera 11.5 look good. Chrome 13 does not.

I see the line height padding in Chrome 13, when I load the JavaScript file, in the demo, line 30:

 * @param {orion.textview.TextModel} [options.model] the text model for the view. If this options is not set the view creates an empty {@link orion.textview.TextModel}.

I bumped into this problem when I submitted my patch. For Webkit we have to use \u200C. The \uFEFF char always causes rendering problems with the longest line that does not fit the iframe editor width.


> Mihai, please let me know if the current code solves the problem for you.
> (I will only be back in the office Tuesday, lets fix that mac keybinding next)

It solves my problem indeed. In Ubuntu 11.04 clean install, Firefox 7, I no longer have line height issues.

Still note that the change that got pushed does cause a Webkit regression.

Thanks for the push!

(I am looking forward for that mac keybindings patch to get landed! :) )
Comment 5 Felipe Heidrich CLA 2011-07-05 14:25:54 EDT
wow this is a bad bug.
I knew I was forgetting something, adding " " to the end of the line causes the line to be wider (doh). We ignore the size of the " " internally using the ignoreChars in _getLineBoundingClientRect (if we don't do that the h scrollbar can be visible when it should not).
But in Webkit we can't stop text wrapping, so when the line is wider than the client area (by the width of the extra " ") we have the problem of the line wrapping.

The fix is, as you said, to always use \u200C for webkit.
Comment 6 Felipe Heidrich CLA 2011-07-05 14:52:58 EDT
The history of trailing whitespace:

before full selection

Add " " to firefox, opera and ie9 to all lines
Add "\u200C" to webkit for empty lines
Add "\uFEFF" to ie8 for empty lines

after full selection
(note that with full selection we added the concept that every line should be always be tall enough to have bold, italic, bold-italic of the default font, we implemented that using the trailing whitespace)

Full selection:
  Add "\u200C" to webkit and firefox
  Add "\uFEFF" to all others
Regular selection:
  Add " " to firefox, opera and ie9
  Add "\u200C" to webkit
  Add "\uFEFF" to ie8

New code:
Add "\u200C" to webkit (always full selection)
Add "\FEFF" to ie8  (never full selection)
Add " " to firefox, ie9, opera, etc (regardless of selection type)
Comment 7 Felipe Heidrich CLA 2011-07-05 15:09:30 EDT
fixed:
http://git.eclipse.org/c/e4/org.eclipse.orion.client.git/commit/?id=c07f1496d1683958cee05e38e4026375bbbd786f


Note: it seems that using "\uFEFF" in chrome these days is fine, but I kept "\u200C" for history reasons.

Thank you Mihai for all the help.
Comment 8 Felipe Heidrich CLA 2011-07-05 15:09:42 EDT
fixed.