Closed Bug 514745 Opened 13 years ago Closed 13 years ago

Implement resizer themeing from bug 510333 for rtl

Categories

(Core :: Widget: Cocoa, defect)

All
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.3a1

People

(Reporter: enndeakin, Assigned: mstange)

References

Details

(Keywords: rtl)

Attachments

(1 file)

I've tried but cannot get the image drawn to appear in reverse. The folowing code doesn't seem to work:

+        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+        CGContextRef bitmapctx = CGBitmapContextCreate(NULL,
+                                                       (size_t) ceil(macRect.size.width),
+                                                       (size_t) ceil(macRect.size.height),
+                                                       8,
+                                                       (size_t) ceil(macRect.size.width) * 4,
+                                                       colorSpace,
+                                                       kCGImageAlphaPremultipliedFirst);
+        CGColorSpaceRelease(colorSpace);
+        HIPoint pnt = { 0, 0 };
+        HIThemeDrawGrowBox(&pnt, &drawInfo, bitmapctx, kHIThemeOrientationNormal);
+
+        CGAffineTransform ctm = CGContextGetCTM(cgContext);
+        CGImageRef bitmap = CGBitmapContextCreateImage(bitmapctx);
+
+        CGContextTranslateCTM(cgContext, macRect.size.width, macRect.size.height);
+        CGContextScaleCTM(cgContext, -1.0f, -1.0f);
+
+        CGContextDrawImage(cgContext, macRect, bitmap);
+        CGContextSetCTM(cgContext, ctm);
+        CGImageRelease(bitmap);
+        CGContextRelease(bitmapctx);

I've tried many different variations of arguments passed to the translate and scale methods as well as to the structure of the code, but nothing seems to work.
Assignee: nobody → mstange
Status: NEW → ASSIGNED
Keywords: rtl
I think the problem with your code is that you pass macRect into CGContextDrawImage, which still has the original x and y position. The flip transform that you set gets applied to these coordinates, too, so the image will end up in a completely wrong place.
My patch gets around that by pushing a translation transform first, then pushing the flip transform, and then drawing the image at the position 0,0.
Blocks: 492155
Attached patch v1Splinter Review
This patch fixes the scrollbar drawing code (and thus bug 492155), generalizes it to take a rendering callback function and uses the generalized implementation to draw resizers.
I don't know if the reftests pass on other platforms; the tryserver seems very unhappy right now so I'll ask him again tomorrow.
Attachment #402551 - Flags: review?(joshmoz)
This works great!
Attachment #402551 - Flags: review?(joshmoz) → review+
Hardware: x86 → All
http://hg.mozilla.org/mozilla-central/rev/074779c640fb

(Transformed scrollbars are bug 492155.)
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a1
Attachment #402551 - Flags: approval1.9.2?
Oops, transformed scrollbars are still bug 492155... I mentioned the wrong bug in the 1.9.2 commit message, too.
Comment on attachment 402551 [details] [diff] [review]
v1

approval1.9.2 requests aren't currently being monitored, since we're nearing RC freeze and there are too many outstanding requests, so I'm clearing this request. Feel free to re-request approval if you are confident that it's worth drivers' time to consider whether this non-blocker needs to land for 1.9.2 at this stage.
Attachment #402551 - Flags: approval1.9.2?
Blocks: 572455
You need to log in before you can comment on or make changes to this bug.