Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 336021

Summary: [editor] Editor steals scrolling from containing page
Product: [ECD] Orion Reporter: Andrew Niefer <aniefer>
Component: ClientAssignee: Felipe Heidrich <eclipse.felipe>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe, john.arthorne
Version: 0.2   
Target Milestone: 0.2   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Andrew Niefer CLA 2011-02-01 17:18:47 EST
I have written a blog post that contains the orion editor embedded to show code snippets:  
http://aniefer.blogspot.com/2011/02/overriding-pdebuild-with-ant-import.html


If you scroll down the page using the mouse wheel, as soon as the mouse cursor is over top of an editor, then editor starts consuming the scroll and the page stops moving. 

 If the editor contains a verticle scrollbar (there is one at the bottom of the post with one), then the wheel scrolls the editor.  However, if there is no scrollbar in the editor, then nothing happens.

We should expect that if the editor does not contain a verticle scrollbar, then the page should continue scrolling.
Comment 1 John Arthorne CLA 2011-02-01 17:31:53 EST
Looking at your blog in FF 3.6, all the snippets have vertical scrollbars... Maybe the editor needs an option to disable scrollbars.
Comment 2 Felipe Heidrich CLA 2011-02-02 09:52:42 EST
What browser/platform are you using ?

John, it is possible to disable the scrollbar for the editor, it is a CSS attribute. Andrew, is that something that you would like to do (I can go find the correct attribute name and value for you) ?

Personally I find it would look nicer if:
- the height was set to lineCount*lineHeight (no scrollbars, no waste white space at bottom)
- a nice border around the editor, set it on the parent div.
Comment 3 Andrew Niefer CLA 2011-02-02 12:49:47 EST
I don't mind having the scroll bars when the editor contains more content. 
 The trick here  is that I'm not sure how to determine the lineheight.
If I can find the lineheight using javascript, then what I could do is set the div height to some number in the html, and then in javascript when I create the editor adjust the height according to the length of the text.
Comment 4 Andrew Niefer CLA 2011-02-02 13:48:35 EST
btw, I'm looking at the post on windows xp with firefox 3.6.13.
I was also using firefox 3.6.12 on SLES and Chrome 6.0.472.63 on SLES when I wrote it.
Comment 5 Felipe Heidrich CLA 2011-02-02 13:49:46 EST
Not sure I follow the whole picture but I hope this can help:
http://orion.eclipse.org/jsdoc/symbols/eclipse.Editor.html#getLineHeight
Comment 6 Andrew Niefer CLA 2011-02-02 15:58:50 EST
Thanks Felipe, here is what I'm using to set the height:
div.style.height = (editor.getLineHeight() * (editor.getModel().getLineCount() + 1)) + 2 + 'px'; 
Before adding the +1 to the linecount, I found I had to add the + 2 to make the vertical scroll bar not appear, there must be a border.  I added the +1 to the lineCount to make room for a horizontal scrollbar.


As for scrolling the page with the mouse wheel, none of my editors have vertical scrollbars, and firefox 3.6.13 on windows doesn't scroll past the editor.  However, IE 8 is scrolling past the editor just fine.
Comment 7 Felipe Heidrich CLA 2011-02-03 10:32:48 EST
(In reply to comment #6)
> Thanks Felipe, here is what I'm using to set the height:
> div.style.height = (editor.getLineHeight() * (editor.getModel().getLineCount()
> + 1)) + 2 + 'px'; 
> Before adding the +1 to the linecount, I found I had to add the + 2 to make the
> vertical scroll bar not appear, there must be a border.  I added the +1 to the
> lineCount to make room for a horizontal scrollbar.

I knew you would need some "extra" space in there.
lineCount*lineHeight gives the size for the client area. You would need something of "computeTrim" to compute the bounding box size (add the space for the scrollbars, borders, etc). I will take a look in what can be done here to help the app to solve this prolem.

The problem with your approach is that it assumes that height of hscrollbar is lineHeight, that can fail (changing the font size for example would break the code).

> As for scrolling the page with the mouse wheel, none of my editors have
> vertical scrollbars, and firefox 3.6.13 on windows doesn't scroll past the
> editor.  However, IE 8 is scrolling past the editor just fine.

That is a bug, I'll take a look at it.
Comment 9 Felipe Heidrich CLA 2011-02-04 16:40:39 EST
fixed
Comment 10 Andrew Niefer CLA 2011-02-04 17:56:26 EST
Thanks Felipe, I updated with your changes and scrolling works great for me now.