Reviewed by Hyatt.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Jan 2006 23:40:47 +0000 (23:40 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Jan 2006 23:40:47 +0000 (23:40 +0000)
        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6914
          REGRESSION: fast/block/basic/014.html crashes Safari

        * rendering/render_image.h:
        (WebCore::RenderImage::image): Return a null image when m_cachedImage is 0.
        (WebCore::RenderImage::errorOccurred): Return false when m_cachedImage is 0.
        * rendering/render_image.cpp: (WebCore::RenderImage::nullImage): Added.
        Returns a global null image for use when we have no cached image.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6919
          REGRESSION: Background images don't paint when they are finished loading

        * rendering/render_object.h: Renamed the old setImage to imageChanged, the
        new name for the same function.
        * rendering/render_object.cpp: (WebCore::RenderObject::imageChanged): Ditto.
        * rendering/render_list.cpp: (RenderListMarker::imageChanged): Changed the
        call to parent to call the new imageChanged instead of the old setImage.

        - fixed something else that was causing some layout test crashes

        * kwq/KWQRenderTreeDebug.cpp: (externalRepresentation): Rearrange so we won't
        ever dereference a null pointer here.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@12466 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/kwq/KWQRenderTreeDebug.cpp
WebCore/rendering/render_image.cpp
WebCore/rendering/render_image.h
WebCore/rendering/render_list.cpp
WebCore/rendering/render_object.cpp
WebCore/rendering/render_object.h

index 7cb0291b0a4d4f70f42831bad7d1df86ccd59d0e..96d4e61f143023f203cafd7189b72426e7148265 100644 (file)
@@ -1,3 +1,30 @@
+2006-01-29  Darin Adler  <darin@apple.com>
+
+        Reviewed by Hyatt.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6914
+          REGRESSION: fast/block/basic/014.html crashes Safari
+
+        * rendering/render_image.h:
+        (WebCore::RenderImage::image): Return a null image when m_cachedImage is 0.
+        (WebCore::RenderImage::errorOccurred): Return false when m_cachedImage is 0.
+        * rendering/render_image.cpp: (WebCore::RenderImage::nullImage): Added.
+        Returns a global null image for use when we have no cached image.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6919
+          REGRESSION: Background images don't paint when they are finished loading
+
+        * rendering/render_object.h: Renamed the old setImage to imageChanged, the
+        new name for the same function.
+        * rendering/render_object.cpp: (WebCore::RenderObject::imageChanged): Ditto.
+        * rendering/render_list.cpp: (RenderListMarker::imageChanged): Changed the
+        call to parent to call the new imageChanged instead of the old setImage.
+
+        - fixed something else that was causing some layout test crashes
+
+        * kwq/KWQRenderTreeDebug.cpp: (externalRepresentation): Rearrange so we won't
+        ever dereference a null pointer here.
+
 2006-01-29  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Darin.
index e4d088b82400d3316d3b4f63fe02aa60f5c29c79..4943e05f940be15325de652d5b1b86237829a53d 100644 (file)
@@ -421,25 +421,23 @@ bool debuggingRenderTree()
     return debuggingRenderTreeFlag;
 }
 
-QString externalRepresentation(RenderObject *o)
+QString externalRepresentation(RenderObjecto)
 {
     debuggingRenderTreeFlag = true;
     JSEditor::setSupportsPasteCommand(true);
 
     QString s;
-    {
+    if (o) {
         QTextStream ts(&s);
 #if SVG_SUPPORT
         ts.precision(2);
         writeRenderResources(ts, o->document());
 #endif
-        if (o) {
-            o->canvas()->view()->layout();
-            RenderLayer* l = o->layer();
-            if (l) {
-                writeLayers(ts, l, l, IntRect(l->xPos(), l->yPos(), l->width(), l->height()));
-                writeSelection(ts, o);
-            }
+        o->canvas()->view()->layout();
+        RenderLayer* l = o->layer();
+        if (l) {
+            writeLayers(ts, l, l, IntRect(l->xPos(), l->yPos(), l->width(), l->height()));
+            writeSelection(ts, o);
         }
     }
     return s;
index 58fe14ad4418c5711cea6676ee0fc94005602fed..e4f4f754ca0bc7e874f909b2e46c8569d1180b1d 100644 (file)
@@ -385,4 +385,10 @@ int RenderImage::calcReplacedHeight() const
     return RenderReplaced::calcReplacedHeight();
 }
 
+const Image& RenderImage::nullImage()
+{
+    static Image sharedNullImage;
+    return sharedNullImage;
+}
+
 }
index bf8ffd46c5c24a450eebc81e27a68d1bd2581dac..58cce88ad04db7f075706a62741fba776f6ce5a4 100644 (file)
 #ifndef RENDER_IMAGE_H
 #define RENDER_IMAGE_H
 
+#include "CachedImage.h"
 #include "HTMLElementImpl.h"
-#include "render_replaced.h"
 #include "dom_string.h"
-#include "CachedImage.h"
+#include "render_replaced.h"
 
 namespace WebCore {
 
@@ -41,12 +41,12 @@ public:
     RenderImage(NodeImpl*);
     virtual ~RenderImage();
 
-    virtual const char *renderName() const { return "RenderImage"; }
+    virtual const charrenderName() const { return "RenderImage"; }
 
     virtual bool isImage() const { return true; }
     virtual bool isImageButton() const { return false; }
     
-    virtual void paint(PaintInfo& i, int tx, int ty);
+    virtual void paint(PaintInfo&, int tx, int ty);
 
     virtual void layout();
 
@@ -56,26 +56,24 @@ public:
     HTMLElementImpl* element() const
         { return static_cast<HTMLElementImpl*>(RenderReplaced::element()); }
 
-
     // hook to keep RendeObject::m_inline() up to date
     virtual void setStyle(RenderStyle *style);
     void updateAltText();
     
-    void setCachedImage(CachedImage* image);
+    void setCachedImage(CachedImage*);
     CachedImage* cachedImage() const { return m_cachedImage; }
     
-    const Image& image() { return m_cachedImage->image(); }
+    const Image& image() { return m_cachedImage ? m_cachedImage->image() : nullImage(); }
 
-    virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty,
-                             HitTestAction hitTestAction);
+    virtual bool nodeAtPoint(NodeInfo&, int x, int y, int tx, int ty, HitTestAction);
     
     virtual int calcReplacedWidth() const;
     virtual int calcReplacedHeight() const;
 
     // Called to set generated content images (e.g., :before/:after generated images).
-    void setContentObject(CachedObject* co);
+    void setContentObject(CachedObject*);
     
-    bool errorOccurred() const { return m_cachedImage->isErrorImage(); }
+    bool errorOccurred() const { return m_cachedImage && m_cachedImage->isErrorImage(); }
     
     HTMLMapElementImpl* imageMap();
 
@@ -88,8 +86,10 @@ private:
     // The image we are rendering.
     CachedImage* m_cachedImage;
 
-    // Text to display as long as the image isn't available
+    // Text to display as long as the image isn't available.
     DOMString m_altText;
+
+    static const Image& nullImage();
 };
 
 } //namespace
index 97ab0514ce984387674a4106e6d561012a52e503..a9885a5c445497fbedc10db7b6b2014d0bc2e5bc 100644 (file)
@@ -517,7 +517,7 @@ void RenderListMarker::layout()
 void RenderListMarker::imageChanged(CachedImage *o, const IntRect& r)
 {
     if (o != m_listImage) {
-        RenderBox::setImage(o, r);
+        RenderBox::imageChanged(o, r);
         return;
     }
 
index ac0922281a8c9a9af0db7beaa01a668f37c9c024..27d6cb071c4c0b90d4fc39cd2846b742c40f4f84 100644 (file)
@@ -2549,14 +2549,13 @@ QChar RenderObject::backslashAsCurrencySymbol() const
     return codec->backslashAsCurrencySymbol();
 }
 
-void RenderObject::setImage(CachedImage *image, const IntRect&)
+void RenderObject::imageChanged(CachedImage *image, const IntRect&)
 {
     // Repaint when the background image or border image finishes loading.
     // This is needed for RenderBox objects, and also for table objects that hold
     // backgrounds that are then respected by the table cells (which are RenderBox
     // subclasses). It would be even better to find a more elegant way of doing this that
     // would avoid putting this function and the CachedObjectClient base class into RenderObject.
-
     if (image && image->imageSize() == image->decodedRect().size() && parent()) {
         if (canvas() && element() && (element()->hasTagName(htmlTag) || element()->hasTagName(bodyTag)))
             canvas()->repaint();    // repaint the entire canvas since the background gets propagated up
index 166ebc3387412f83cb7fa6209e542288cebe018b..f1b7491c37ee62c33d50ee493612df7ed260fde5 100644 (file)
@@ -851,7 +851,7 @@ public:
     virtual int previousOffset (int current) const;
     virtual int nextOffset (int current) const;
 
-    virtual void setImage(CachedImage*, const IntRect&);
+    virtual void imageChanged(CachedImage*, const IntRect&);
 
     virtual void selectionStartEnd(int& spos, int& epos);