[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.0/kdelibs/khtml
From:       Maks Orlovich <maksim () kde ! org>
Date:       2008-01-14 2:26:36
Message-ID: 1200277596.608619.22850.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 761091 by orlovich:

- Make sure we handle image-type objects as RenderImage even when the
mimetype is not explicitly given, by giving the dom a chance to
cancel the request and do its own thing when processObjectRequest is
called from KHTMLRun..

fixes css21/t0801-c412-hz-box-00-b-a.html

- Fix a crasher caused by immediate deletion of objects in part container base..
Better just clean the objects in KHTMLPart, like we do for frames

 M  +22 -2     html/html_objectimpl.cpp  
 M  +9 -1      html/html_objectimpl.h  
 M  +13 -0     khtml_part.cpp  


--- branches/KDE/4.0/kdelibs/khtml/html/html_objectimpl.cpp #761090:761091
@@ -4,6 +4,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2000 Stefan Schimanski (1Stein@gmx.de)
+ *           (C) 2007, 2008 Maks Orlovich (maksim@kde.org)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -63,8 +64,8 @@
     if (m_render)
         detach();
 
-    // This has to be deleted immediately for proper exit cleanup..
-    delete m_childWidget;
+    if (m_childWidget)
+        m_childWidget->deleteLater();
 }
 
 void HTMLPartContainerElementImpl::recalcStyle(StyleChange ch)
@@ -120,6 +121,11 @@
     setWidget(0);
 }
 
+bool HTMLPartContainerElementImpl::mimetypeHandledInternally(const QString&)
+{
+    return false;
+}
+
 // -------------------------------------------------------------------------
 HTMLObjectBaseElementImpl::HTMLObjectBaseElementImpl(DocumentImpl *doc)
     : HTMLPartContainerElementImpl(doc)
@@ -313,6 +319,20 @@
     return 0;
 }
 
+bool HTMLObjectBaseElementImpl::mimetypeHandledInternally(const QString& mime)
+{
+    QStringList supportedImageTypes = \
khtmlImLoad::ImageManager::loaderDatabase()->supportedMimeTypes(); +
+    bool newImageLike = supportedImageTypes.contains(mime);
+
+    if (newImageLike != m_imageLike) {
+        m_imageLike = newImageLike;
+        requestRerender();
+    }
+    
+    return newImageLike; // No need for kpart for that.
+}
+
 void HTMLObjectBaseElementImpl::computeContent()
 {
     QStringList params;
--- branches/KDE/4.0/kdelibs/khtml/html/html_objectimpl.h #761090:761091
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ *           (C) 2007, 2008 Maks Orlovich (maksim@kde.org)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -26,7 +27,9 @@
 #include "html_elementimpl.h"
 #include "xml/dom_stringimpl.h"
 #include <QtCore/QObject>
+#include <QtCore/QPointer>
 #include <QtCore/QStringList>
+#include <QtGui/QWidget>
 
 
 // -------------------------------------------------------------------------
@@ -61,6 +64,10 @@
     // Note: setWidgetNotify may be called with 0...
     virtual void setWidgetNotify(QWidget *widget) = 0; 
     virtual void partLoadingErrorNotify();
+    
+    // This is called when a mimetype is discovered, and should return true 
+    // if KHTMLPart should not make a kpart for it, but rather let it be handled \
directly. +    virtual bool mimetypeHandledInternally(const QString& mime);
 
     // IMPORTANT: you should call this when requesting a URL, to make sure 
     // that we don't get stale references to iframes or such.
@@ -76,7 +83,7 @@
     bool m_needToComputeContent; // This flag is set to true when 
                                  // we may have to load a new KPart, due to 
                                  // source changing, etc.
-    QWidget* m_childWidget;
+    QPointer<QWidget> m_childWidget; // may be deleted by global child widget \
cleanup on us..  };
 
 class HTMLObjectBaseElementImpl : public HTMLPartContainerElementImpl
@@ -110,6 +117,7 @@
 
     virtual void setWidgetNotify( QWidget *widget );
     virtual void partLoadingErrorNotify();
+    virtual bool mimetypeHandledInternally(const QString& mime);
 
     // This method figures out what to render -- perhaps KPart, perhaps an image, \
perhaps   // alternative content, and forces a reattach if need be.
--- branches/KDE/4.0/kdelibs/khtml/khtml_part.cpp #761090:761091
@@ -1483,7 +1483,11 @@
     const ConstFrameIt oiEnd = objects.end();
 
     for (; oi != oiEnd; ++oi )
+    {
+      if ( (*oi)->m_part )
+          delete (KParts::ReadOnlyPart *)(*oi)->m_part;
       delete *oi;
+    }
   }
 
   // Listen to part changes again
@@ -4392,6 +4396,15 @@
 
   if ( child->m_serviceType != mimetype || !child->m_part || (child->m_run && \
child->m_run->serverSuggestsSave()))  {
+    // This may have come from a delayed response from KHTMLPart, in regards to 
+    // an object/iframe/etc. In this case, let the element veto this.
+    if ( child->m_partContainerElement && 
+         child->m_partContainerElement->mimetypeHandledInternally(mimetype) ) {
+      child->m_bCompleted = true;
+      checkCompleted();
+      return true;
+    }
+  
     // Before attempting to load a part, check if the user wants that.
     // Many don't like getting ZIP files embedded.
     // However we don't want to ask for flash and other plugin things..


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic