| Summary: | [Accessibility] Font attributes are repeated at the beginning of lines | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Scott Kovatch <skovatch> | ||||
| Component: | SWT | Assignee: | Scott Kovatch <skovatch> | ||||
| Status: | RESOLVED FIXED | QA Contact: | Carolyn MacLeod <carolynmacleod4> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | Silenio_Quarti | ||||
| Version: | 3.6 | Flags: | carolynmacleod4:
review+
Silenio_Quarti: review+ |
||||
| Target Milestone: | 3.6 RC2 | ||||||
| Hardware: | Macintosh | ||||||
| OS: | Mac OS X | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Scott Kovatch
Created attachment 169028 [details]
Fix
Attribute locations set on the returned attributed string must start at zero. Code could set a negative location, depending on where the attribute started. Likewise, they can't run off the end of the string.
Ready for review. This is the extra code I accidentally checked in last week, and this was the bug it was fixing. I do not quite understand what the code is doing, but I believe the portion of the code below is comparing offsets with lengths which cannot be right.
if (attributeRange.location + attributeRange.length > range.length) {
attributeRange.length = range.length - attributeRange.location;
}
Shouldn't it be this instead?
if (attributeRange.location + attributeRange.length > range.location + range.length) {
attributeRange.length = (range.location + range.length) - attributeRange.location;
}
(In reply to comment #3) > I do not quite understand what the code is doing, but I believe the portion of > the code below is comparing offsets with lengths which cannot be right. getAttributedStringForRangeParameterizedAttribute needs to return an attributed string which is a substring of the entire content. If the requested location falls in the middle of a style run we compute an attribute on the returned substring with a negative location. Likewise, if the end of the requested range falls in the middle of a run, we have to shorten the returned length so it doesn't run off the end of the substring. > if (attributeRange.location + attributeRange.length > range.length) { > attributeRange.length = range.length - attributeRange.location; > } I agree, it is a bit confusing. range.location is the start location of the substring that needs to be returned, not the location in the returned string. It doesn't change. The starting location here is 0. We're making sure the current attribute to be set would not run past the end of the returned substring. Ok, I understand it now. After wrapping 2 tired brains around the math once more, we are both good with the change in comment 1. Thanks! Fixed > 20100519. |