Correctly account for scaled image size and clipping.
Reviewed by Maciej.
* WebCoreSupport.subproj/WebImageData.h:
* WebCoreSupport.subproj/WebImageData.m:
* WebCoreSupport.subproj/WebImageRenderer.m:
(-[WebImageRenderer drawImageInRect:fromRect:compositeOperator:context:]):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8033
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2004-11-17 Richard Williamson <rjw@apple.com>
+
+ Fixed <rdar://problem/3885073> REGRESSION: Tab images at top of news.com.com replicated and squished
+
+ Correctly account for scaled image size and clipping.
+
+ Reviewed by Maciej.
+
+ * WebCoreSupport.subproj/WebImageData.h:
+ * WebCoreSupport.subproj/WebImageData.m:
+ * WebCoreSupport.subproj/WebImageRenderer.m:
+ (-[WebImageRenderer drawImageInRect:fromRect:compositeOperator:context:]):
+
2004-11-17 Maciej Stachowiak <mjs@apple.com>
Reviewed by Richard.
- (size_t)numberOfImages;
- (CGImageRef)imageAtIndex:(size_t)index;
- (BOOL)incrementalLoadWithBytes:(const void *)bytes length:(unsigned)length complete:(BOOL)isComplete;
+- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr adjustedSize:(CGSize)size compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext;
- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext;
- (void)tileInRect:(CGRect)rect fromPoint:(CGPoint)point context:(CGContextRef)aContext;
- (BOOL)isNull;
return YES;
}
-- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext;
+- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr adjustedSize:(CGSize)adjustedSize compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext;
{
CGImageRef image = [self imageAtIndex:index];
CGContextSaveGState (aContext);
- //float w = CGImageGetWidth(image);
+ // Get the height of the portion of the image that is currently decoded. This
+ // could be less that the actual height.
float h = CGImageGetHeight(image);
// Is the amount of available bands less than what we need to draw? If so,
// clip.
- BOOL clipping = NO;
+ BOOL clipped = NO;
if (h < fr.size.height) {
fr.size.height = h;
ir.size.height = h;
- clipping = YES;
+ clipped = YES;
}
// Flip the coords.
// If we're drawing a sub portion of the image then create
// a image for the sub portion and draw that.
// Test using example site at http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html
- if (fr.origin.x != 0 || fr.origin.y != 0 ||
- fr.size.width != ir.size.width || fr.size.height != fr.size.height ||
- clipping) {
+ if (clipped == NO && (fr.size.width != adjustedSize.width || fr.size.height != adjustedSize.height)) {
image = CGImageCreateWithImageInRect (image, fr);
if (image) {
CGContextDrawImage (aContext, ir, image);
CGContextRestoreGState (aContext);
}
+- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext;
+{
+ [self drawImageAtIndex:index inRect:ir fromRect:fr adjustedSize:[self size] compositeOperation:op context:aContext];
+}
+
static void drawPattern (void * info, CGContextRef context)
{
CGImageRef image = (CGImageRef)info;
if (op == kCGCompositeUnknown)
op = kCGCompositeSover;
- [imageData drawImageAtIndex:[imageData currentFrame] inRect:CGRectMake(ir.origin.x, ir.origin.y, ir.size.width, ir.size.height)
- fromRect:CGRectMake(fr.origin.x, fr.origin.y, fr.size.width, fr.size.height)
- compositeOperation:op context:aContext];
+ if (isSizeAdjusted) {
+ [imageData drawImageAtIndex:[imageData currentFrame] inRect:CGRectMake(ir.origin.x, ir.origin.y, ir.size.width, ir.size.height)
+ fromRect:CGRectMake(fr.origin.x, fr.origin.y, fr.size.width, fr.size.height)
+ adjustedSize:CGSizeMake(adjustedSize.width, adjustedSize.height)
+ compositeOperation:op context:aContext];
+ }
+ else {
+ [imageData drawImageAtIndex:[imageData currentFrame] inRect:CGRectMake(ir.origin.x, ir.origin.y, ir.size.width, ir.size.height)
+ fromRect:CGRectMake(fr.origin.x, fr.origin.y, fr.size.width, fr.size.height)
+ compositeOperation:op context:aContext];
+ }
targetAnimationRect = ir;
[self _startOrContinueAnimationIfNecessary];