[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

rjw rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:42:03 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit ca8930149a491621f7392fb1b96744bc95bc8302
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed May 14 01:30:48 2003 +0000

    WebKit:
    	Fixed 3014661.  We now display (a lame Lemay) image
    	when an image fails to load.  We also display the
    	alt text if it fits within the image container
    	above the missing image icon.  Alt text is also
    	now shown if image loading is disabled.
    
            Reviewed by John.
    
            * Resources/missing_image.tiff: Added.
            * WebCoreSupport.subproj/WebImageRenderer.h:
            * WebCoreSupport.subproj/WebImageRenderer.m:
            (-[WebImageRenderer initWithMIMEType:]):
            (-[WebImageRenderer initWithData:MIMEType:]):
            (-[WebImageRenderer initWithContentsOfFile:]):
            (-[WebImageRenderer copyWithZone:]):
            (-[WebImageRenderer isNull]):
            (-[WebImageRenderer incrementalLoadWithBytes:length:complete:]):
            * WebCoreSupport.subproj/WebImageRendererFactory.m:
            (-[WebImageRendererFactory imageRendererWithName:]):
            * WebKit.pbproj/project.pbxproj:
    
    WebCore:
    	Fixed 3014661.  We now display (a lame Lemay) image
    	when an image fails to load.  We also display the
    	alt text if it fits within the image container
    	above the missing image icon.  Alt text is also
    	now shown if image loading is disabled.
    
            Reviewed by John.
    
            * khtml/misc/loader.cpp:
            (CachedImage::data):
            (Cache::init):
            * khtml/rendering/render_image.cpp:
            (RenderImage::paintObject):
            (RenderImage::reload):
            * kwq/KWQPixmap.h:
            * kwq/KWQPixmap.mm:
            (KWQLoadPixmap):
            (QPixmap::QPixmap):
            (QPixmap::isNull):
            * kwq/WebCoreImageRenderer.h:
            * kwq/WebCoreImageRendererFactory.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4366 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index b34f677..d55b81c 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,27 @@
+2003-05-13  Richard Williamson   <rjw at apple.com>
+
+	Fixed 3014661.  We now display (a lame Lemay) image
+	when an image fails to load.  We also display the 
+	alt text if it fits within the image container
+	above the missing image icon.  Alt text is also
+	now shown if image loading is disabled.
+
+        Reviewed by John.
+
+        * khtml/misc/loader.cpp:
+        (CachedImage::data):
+        (Cache::init):
+        * khtml/rendering/render_image.cpp:
+        (RenderImage::paintObject):
+        (RenderImage::reload):
+        * kwq/KWQPixmap.h:
+        * kwq/KWQPixmap.mm:
+        (KWQLoadPixmap):
+        (QPixmap::QPixmap):
+        (QPixmap::isNull):
+        * kwq/WebCoreImageRenderer.h:
+        * kwq/WebCoreImageRendererFactory.h:
+
 2003-05-12  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by Darin.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index b34f677..d55b81c 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,27 @@
+2003-05-13  Richard Williamson   <rjw at apple.com>
+
+	Fixed 3014661.  We now display (a lame Lemay) image
+	when an image fails to load.  We also display the 
+	alt text if it fits within the image container
+	above the missing image icon.  Alt text is also
+	now shown if image loading is disabled.
+
+        Reviewed by John.
+
+        * khtml/misc/loader.cpp:
+        (CachedImage::data):
+        (Cache::init):
+        * khtml/rendering/render_image.cpp:
+        (RenderImage::paintObject):
+        (RenderImage::reload):
+        * kwq/KWQPixmap.h:
+        * kwq/KWQPixmap.mm:
+        (KWQLoadPixmap):
+        (QPixmap::QPixmap):
+        (QPixmap::isNull):
+        * kwq/WebCoreImageRenderer.h:
+        * kwq/WebCoreImageRendererFactory.h:
+
 2003-05-12  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by Darin.
diff --git a/WebCore/khtml/misc/loader.cpp b/WebCore/khtml/misc/loader.cpp
index e46c02c..237a765 100644
--- a/WebCore/khtml/misc/loader.cpp
+++ b/WebCore/khtml/misc/loader.cpp
@@ -937,11 +937,13 @@ void CachedImage::data ( QBuffer &_buffer, bool eof )
     if (canDraw || eof) {
         if (p->isNull()) {
             errorOccured = true;
-            do_notify(pixmap(), QRect(0, 0, 16, 16)); // load "broken image" icon
-        } else {
-            // May schedule a redraw.
-            do_notify(*p, p->rect());
+            QPixmap ep = pixmap();
+            do_notify (ep, ep.rect());
+            Cache::removeCacheEntry (this);
         }
+        else
+            do_notify(*p, p->rect());
+
         QSize s = pixmap_size();
         setSize(s.width() * s.height() * 2);
     }
@@ -1423,9 +1425,8 @@ void Cache::init()
 
     if ( !brokenPixmap )
 #if APPLE_CHANGES
-        brokenPixmap = new QPixmap;
+        brokenPixmap = KWQLoadPixmap("missing_image");
 #else
-//        brokenPixmap = new QPixmap(KHTMLFactory::instance()->iconLoader()->loadIcon("file_broken", KIcon::FileSystem, 16, KIcon::DisabledState));
         brokenPixmap = new QPixmap(KHTMLFactory::instance()->iconLoader()->loadIcon("file_broken", KIcon::Desktop, 16, KIcon::DisabledState));
 #endif
 
diff --git a/WebCore/khtml/rendering/render_image.cpp b/WebCore/khtml/rendering/render_image.cpp
index a04c28b..633d16b 100644
--- a/WebCore/khtml/rendering/render_image.cpp
+++ b/WebCore/khtml/rendering/render_image.cpp
@@ -209,12 +209,50 @@ void RenderImage::paintObject(QPainter *p, int /*_x*/, int /*_y*/, int /*_w*/, i
         {
 #if APPLE_CHANGES
             if ( !berrorPic ) {
-                //qDebug("qDrawShadePanel %d/%d/%d/%d", _tx + leftBorder, _ty + topBorder, cWidth, cHeight);
                 p->setPen (Qt::lightGray);
                 p->setBrush (Qt::NoBrush);
-                p->drawRect (_tx + leftBorder + leftPad, _ty + topBorder + topPad,
-                             cWidth, cHeight);
+                p->drawRect (_tx + leftBorder + leftPad, _ty + topBorder + topPad, cWidth, cHeight);
 	    }
+
+            bool errorPictureDrawn = false;
+            int imageX = 0, imageY = 0;
+            int usableWidth = cWidth - leftBorder - borderRight() - leftPad - paddingRight();
+            int usableHeight = cHeight - topBorder - borderBottom() - topPad - paddingBottom();
+            
+            if(berrorPic && !pix.isNull() && (usableWidth >= pix.width()) && (usableHeight >= pix.height()) )
+            {
+                // Center the error image, accounting for border and padding.
+                int centerX = (usableWidth - pix.width())/2;
+                if (centerX < 0)
+                    centerX = 0;
+                int centerY = (usableHeight - pix.height())/2;
+                if (centerY < 0)
+                    centerY = 0;
+                imageX = leftBorder + leftPad + centerX;
+                imageY = topBorder + topPad + centerY;
+                p->drawPixmap( QPoint(_tx + imageX, _ty + imageY), pix, pix.rect() );
+                errorPictureDrawn = true;
+            }
+            
+            if(!alt.isEmpty()) {
+                QString text = alt.string();
+                p->setFont (style()->font());
+                p->setPen (style()->color());
+                int ax = _tx + leftBorder + leftPad;
+                int ay = _ty + topBorder + topPad;
+                const QFontMetrics &fm = style()->fontMetrics();
+                int ascent = fm.ascent();
+                
+                // Only draw the alt text if it'll fit within the content box,
+                // and only if it fits above the error image.
+                int textWidth = fm.width (text, text.length());
+                if (errorPictureDrawn){
+                    if (usableWidth > textWidth && fm.height() <= imageY)
+                        p->drawText(ax, ay+ascent, 0 /* ignored */, 0 /* ignored */, Qt::WordBreak  /* not supported */, text );
+                }
+                else if (usableWidth >= textWidth && cHeight>=fm.height())
+                    p->drawText(ax, ay+ascent, 0 /* ignored */, 0 /* ignored */, Qt::WordBreak  /* not supported */, text );
+            }
 #else /* not APPLE_CHANGES */
             if ( !berrorPic ) {
                 //qDebug("qDrawShadePanel %d/%d/%d/%d", _tx + leftBorder, _ty + topBorder, cWidth, cHeight);
@@ -370,6 +408,17 @@ void RenderImage::dispatchLoadEvent()
     }
 }
 
+#ifdef FIX_3109150
+void RenderImage::reload()
+{
+    khtml::DocLoader *loader = element()->getDocument()->docLoader();
+    KIO::CacheControl savedCachePolicy = loader->cachePolicy();
+    loader->setCachePolicy(KIO::CC_Reload);
+    updateFromElement();
+    loader->setCachePolicy(savedCachePolicy);
+}
+#endif
+
 void RenderImage::detach(RenderArena *arena)
 {
     NodeImpl *node = element();
diff --git a/WebCore/kwq/KWQPixmap.h b/WebCore/kwq/KWQPixmap.h
index bec7ae1..7feb699 100644
--- a/WebCore/kwq/KWQPixmap.h
+++ b/WebCore/kwq/KWQPixmap.h
@@ -48,6 +48,7 @@ class NSString;
 class QWMatrix;
 
 bool canRenderImageType(const QString &type);
+QPixmap *KWQLoadPixmap(const char *name);
 
 class QPixmap : public QPaintDevice, public Qt {
 public:
@@ -58,6 +59,7 @@ public:
     QPixmap(const QByteArray&, void *MIMEType);
     QPixmap(int, int);
     QPixmap(const QPixmap &);
+    QPixmap(WebCoreImageRendererPtr);
     ~QPixmap();
     
     bool isNull() const;
@@ -80,6 +82,7 @@ public:
     void stopAnimations();
 
     WebCoreImageRendererPtr image() { return imageRenderer; };
+    
 private:
 
     WebCoreImageRendererPtr imageRenderer;
diff --git a/WebCore/kwq/KWQPixmap.mm b/WebCore/kwq/KWQPixmap.mm
index 299283b..f262b36 100644
--- a/WebCore/kwq/KWQPixmap.mm
+++ b/WebCore/kwq/KWQPixmap.mm
@@ -28,6 +28,12 @@
 #import "WebCoreImageRenderer.h"
 #import "WebCoreImageRendererFactory.h"
 
+QPixmap *KWQLoadPixmap(const char *name)
+{
+    QPixmap *p = new QPixmap([[WebCoreImageRendererFactory sharedFactory] imageRendererWithName:[NSString stringWithCString:name]]);
+    return p;
+}
+
 bool canRenderImageType(const QString &type)
 {
     return [[[WebCoreImageRendererFactory sharedFactory] supportedMIMETypes] containsObject:type.getNSString()];
@@ -40,6 +46,14 @@ QPixmap::QPixmap()
     needCopyOnWrite = false;
 }
 
+QPixmap::QPixmap(WebCoreImageRendererPtr r)
+{
+    imageRenderer = [r retain];
+    MIMEType = 0;
+    needCopyOnWrite = false;
+}
+
+
 QPixmap::QPixmap(void *MIME)
 {
     imageRenderer = nil;
@@ -105,7 +119,7 @@ bool QPixmap::mask() const
 
 bool QPixmap::isNull() const
 {
-    return imageRenderer == nil;
+    return imageRenderer == nil || [imageRenderer isNull];
 }
 
 QSize QPixmap::size() const
diff --git a/WebCore/kwq/WebCoreImageRenderer.h b/WebCore/kwq/WebCoreImageRenderer.h
index 196e9b7..34d15aa 100644
--- a/WebCore/kwq/WebCoreImageRenderer.h
+++ b/WebCore/kwq/WebCoreImageRenderer.h
@@ -34,5 +34,6 @@
 - (void)beginAnimationInRect:(NSRect)ir fromRect:(NSRect)fr;
 - (void)stopAnimation;
 - (void)tileInRect:(NSRect)r fromPoint:(NSPoint)p;
+- (BOOL)isNull;
 
 @end
diff --git a/WebCore/kwq/WebCoreImageRendererFactory.h b/WebCore/kwq/WebCoreImageRendererFactory.h
index fd85125..796b21c 100644
--- a/WebCore/kwq/WebCoreImageRendererFactory.h
+++ b/WebCore/kwq/WebCoreImageRendererFactory.h
@@ -34,6 +34,7 @@
 - (id <WebCoreImageRenderer>)imageRendererWithBytes:(const void *)bytes length:(unsigned)length;
 - (id <WebCoreImageRenderer>)imageRendererWithBytes:(const void *)bytes length:(unsigned)length MIMEType:(NSString *)MIMEType;
 - (id <WebCoreImageRenderer>)imageRendererWithSize:(NSSize)size;
+- (id <WebCoreImageRenderer>)imageRendererWithName:(NSString *)name;
 - (NSArray *)supportedMIMETypes;
 
 @end
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index c643a38..f9a6e6d 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,26 @@
+2003-05-13  Richard Williamson   <rjw at apple.com>
+
+	Fixed 3014661.  We now display (a lame Lemay) image
+	when an image fails to load.  We also display the 
+	alt text if it fits within the image container
+	above the missing image icon.  Alt text is also
+	now shown if image loading is disabled.
+
+        Reviewed by John.
+
+        * Resources/missing_image.tiff: Added.
+        * WebCoreSupport.subproj/WebImageRenderer.h:
+        * WebCoreSupport.subproj/WebImageRenderer.m:
+        (-[WebImageRenderer initWithMIMEType:]):
+        (-[WebImageRenderer initWithData:MIMEType:]):
+        (-[WebImageRenderer initWithContentsOfFile:]):
+        (-[WebImageRenderer copyWithZone:]):
+        (-[WebImageRenderer isNull]):
+        (-[WebImageRenderer incrementalLoadWithBytes:length:complete:]):
+        * WebCoreSupport.subproj/WebImageRendererFactory.m:
+        (-[WebImageRendererFactory imageRendererWithName:]):
+        * WebKit.pbproj/project.pbxproj:
+
 2003-05-13  Darin Adler  <darin at apple.com>
 
         Reviewed by Chris and Richard.
diff --git a/WebKit/Resources/missing_image.tiff b/WebKit/Resources/missing_image.tiff
new file mode 100644
index 0000000..4eb7cce
Binary files /dev/null and b/WebKit/Resources/missing_image.tiff differ
diff --git a/WebKit/WebCoreSupport.subproj/WebImageRenderer.h b/WebKit/WebCoreSupport.subproj/WebImageRenderer.h
index 09c3432..285613d 100644
--- a/WebKit/WebCoreSupport.subproj/WebImageRenderer.h
+++ b/WebKit/WebCoreSupport.subproj/WebImageRenderer.h
@@ -26,6 +26,7 @@
     int GIFExtensionBufferLength;
     
     NSString *MIMEType;
+    BOOL isNull;
 }
 
 - (id)initWithMIMEType:(NSString *)MIME;
diff --git a/WebKit/WebCoreSupport.subproj/WebImageRenderer.m b/WebKit/WebCoreSupport.subproj/WebImageRenderer.m
index 0ca08f2..506f769 100644
--- a/WebKit/WebCoreSupport.subproj/WebImageRenderer.m
+++ b/WebKit/WebCoreSupport.subproj/WebImageRenderer.m
@@ -97,6 +97,7 @@ static NSMutableArray *activeImageRenderers;
     if (self != nil) {
         MIMEType = [MIME copy];
     }
+    isNull = YES;
     return self;
 }
 
@@ -109,25 +110,42 @@ static NSMutableArray *activeImageRenderers;
         [self checkDataForGIFExtensionSignature:data];
 #endif
         MIMEType = [MIME copy];
+        if ([data length] > 0)
+            isNull = NO;
+        else
+            isNull = YES;
     }
     return self;
 }
 
+- (id)initWithContentsOfFile:(NSString *)filename
+{
+    NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+    NSString *imagePath = [bundle pathForResource:filename ofType:@"tiff"];
+    self = [super initWithContentsOfFile:imagePath];
+    if (self)
+        isNull = NO;
+    return self;
+}
 
 - copyWithZone:(NSZone *)zone
 {
     WebImageRenderer *copy = [super copyWithZone:zone];
     
     // FIXME: If we copy while doing an incremental load, it won't work.
-    
     copy->frameTimer = nil;
     copy->frameView = nil;
     copy->patternColor = nil;
     copy->MIMEType = [MIMEType copy];
+    copy->isNull = isNull;
         
     return copy;
 }
 
+- (BOOL)isNull
+{
+    return isNull;
+}
 
 - (BOOL)incrementalLoadWithBytes:(const void *)bytes length:(unsigned)length complete:(BOOL)isComplete
 {
@@ -135,7 +153,6 @@ static NSMutableArray *activeImageRenderers;
     NSData *data = [[NSData alloc] initWithBytes:bytes length:length];
     NSSize size;
 
-
 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
     // Part of the workaround for bug 3090341.
     [self checkDataForGIFExtensionSignature:data];
@@ -165,10 +182,12 @@ static NSMutableArray *activeImageRenderers;
         size = NSMakeSize([imageRep pixelsWide], [imageRep pixelsHigh]);
         [imageRep setSize:size];
         [self setSize:size];
+        isNull = NO;
         return YES;
     default:
         //printf ("incrementalLoadWithBytes: size %d, isComplete %d\n", length, isComplete);
-        // We have some data.  Return YES so we can attempt to draw what we've got.
+        // We have some valid data.  Return YES so we can attempt to draw what we've got.
+        isNull = NO;
         return YES;
     }
     
diff --git a/WebKit/WebCoreSupport.subproj/WebImageRendererFactory.m b/WebKit/WebCoreSupport.subproj/WebImageRendererFactory.m
index 7a205d9..16c5bb9 100644
--- a/WebKit/WebCoreSupport.subproj/WebImageRendererFactory.m
+++ b/WebKit/WebCoreSupport.subproj/WebImageRendererFactory.m
@@ -90,6 +90,15 @@
     return imageRenderer;
 }
 
+- (id <WebCoreImageRenderer>)imageRendererWithName:(NSString *)name
+{
+    WebImageRenderer *imageRenderer = [[[WebImageRenderer alloc] initWithContentsOfFile:name] autorelease];
+    [imageRenderer setScalesWhenResized:NO];
+    [imageRenderer setFlipped:YES];
+    return imageRenderer;
+}
+
+
 - (NSArray *)supportedMIMETypes
 {
     static NSArray *imageMIMETypes = nil;
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index 70ab122..c7933e3 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -305,6 +305,7 @@
 				9345D17D0365BF35008635CE,
 				F5883BDF025E5C6A01000102,
 				F5B67131023EDF8901C1A525,
+				5128F1FA04719A4200CA2D3A,
 			);
 			isa = PBXResourcesBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -429,6 +430,7 @@
 				F5B67130023EDF8901C1A525,
 				F5F732D202FF4D4F01A80180,
 				9345D4E70365C58D008635CE,
+				5128F1F904719A4200CA2D3A,
 			);
 			isa = PBXGroup;
 			name = Resources;
@@ -1036,6 +1038,18 @@
 //512
 //513
 //514
+		5128F1F904719A4200CA2D3A = {
+			isa = PBXFileReference;
+			name = missing_image.tiff;
+			path = Resources/missing_image.tiff;
+			refType = 4;
+		};
+		5128F1FA04719A4200CA2D3A = {
+			fileRef = 5128F1F904719A4200CA2D3A;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		513D422E034CF55A00CA2ACD = {
 			fileEncoding = 30;
 			isa = PBXFileReference;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list