Bug 534888 - [code mining] Compute width/height of inlined annotation outside the draw process
Summary: [code mining] Compute width/height of inlined annotation outside the draw pro...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.8   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 532924
  Show dependency tree
 
Reported: 2018-05-19 11:12 EDT by Angelo ZERR CLA
Modified: 2019-05-02 07:02 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Angelo ZERR CLA 2018-05-19 11:12:18 EDT
Today the compute of size of inlined annotation:

 * width for line content annotation
 * height for line header annotation

are done in the AbstractInlinedAnnotation#draw method. In other words:

 * the first time the draw of inlined annotation draws inside the Styledtext in the wrong place : the content of the inlined annotation overlaps the text of the line. This draw compute the well width/height.
 * once the width/height are computed, the GlyphMetrics style is updated (with StyledText#setStyleRange to take the well place and the annotation is redrawn in the well place.

In windows OS, there is no problem, but in MacOS and sometimes in Linux OS, it can have some trouble like 

 * for Linux https://github.com/angelozerr/jdt-codemining/issues/27
 * for MacOS https://bugs.eclipse.org/bugs/show_bug.cgi?id=532924

To fix this problem, annotation#draw must call only when width/height are computed and GlyphMetrics style is updated. The idea is to provide a new method 

---------------------------------------------------------
Point AbstractInlinedAnnotation#computeSize(GC gc)
---------------------------------------------------------

And for codemining we should have a new API

---------------------------------------------------------
Point ICodeMining#computeSize(GC gc)
---------------------------------------------------------

I know Photon is frozen for the API, but it's a bad design to compute size in the draw of annotation. 

@Mickael I suppose this important issue cannot be done for Photon but for Photon+1 by using some IInlinedAnnotationExtension and ICodeMiningExtension. is that?

@Lars I think this issue will fix your problem  with https://github.com/angelozerr/jdt-codemining/issues/27 but not completely because it seems the problem of overlaps comes from that setStyleRange is not updated, why? I don't know? 

@Martin for MacOS, it will improve the render of inlined annotation but not sure it will fix totally the problem with https://bugs.eclipse.org/bugs/show_bug.cgi?id=532924
Comment 1 Eclipse Genie CLA 2018-05-24 05:57:11 EDT
New Gerrit change created: https://git.eclipse.org/r/123245
Comment 2 Mickael Istria CLA 2019-05-02 07:02:10 EDT
This doesn't appear to be critical in current usage, reducing priority as enhancment.