[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
hyatt
hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:38:44 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 511c9d1de13c103d27f231aaa0c12d905e354c28
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon May 10 21:29:42 2004 +0000
Move image loading to content.
Reviewed by kocienda
* khtml/html/html_imageimpl.cpp:
(m_imageComplete):
(HTMLImageLoader::~HTMLImageLoader):
(HTMLImageLoader::updateFromElement):
(HTMLImageLoader::removedFromDocument):
(HTMLImageLoader::dispatchLoadEvent):
(HTMLImageLoader::notifyFinished):
(HTMLImageElementImpl::HTMLImageElementImpl):
(HTMLImageElementImpl::parseHTMLAttribute):
(HTMLImageElementImpl::attach):
(HTMLImageElementImpl::detach):
(HTMLImageElementImpl::removedFromDocument):
(HTMLImageElementImpl::currentImage):
* khtml/html/html_imageimpl.h:
(DOM::):
* khtml/html/html_objectimpl.cpp:
(HTMLObjectElementImpl::HTMLObjectElementImpl):
(HTMLObjectElementImpl::removedFromDocument):
(HTMLObjectElementImpl::attach):
* khtml/html/html_objectimpl.h:
* khtml/misc/loader.cpp:
(CachedImage::ref):
* khtml/rendering/render_image.cpp:
(RenderImage::RenderImage):
(RenderImage::setImage):
(RenderImage::updateAltText):
* khtml/rendering/render_image.h:
(khtml::RenderImage::getImage):
* khtml/rendering/render_object.cpp:
(RenderObject::canvas):
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::dispatchImageLoadEventSoon):
(DocumentImpl::removeImage):
(DocumentImpl::dispatchImageLoadEventsNow):
* khtml/xml/dom_docimpl.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6566 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 1b376a4..0d074b3 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,45 @@
+2004-05-10 David Hyatt <hyatt at apple.com>
+
+ Move image loading to content.
+
+ Reviewed by kocienda
+
+ * khtml/html/html_imageimpl.cpp:
+ (m_imageComplete):
+ (HTMLImageLoader::~HTMLImageLoader):
+ (HTMLImageLoader::updateFromElement):
+ (HTMLImageLoader::removedFromDocument):
+ (HTMLImageLoader::dispatchLoadEvent):
+ (HTMLImageLoader::notifyFinished):
+ (HTMLImageElementImpl::HTMLImageElementImpl):
+ (HTMLImageElementImpl::parseHTMLAttribute):
+ (HTMLImageElementImpl::attach):
+ (HTMLImageElementImpl::detach):
+ (HTMLImageElementImpl::removedFromDocument):
+ (HTMLImageElementImpl::currentImage):
+ * khtml/html/html_imageimpl.h:
+ (DOM::):
+ * khtml/html/html_objectimpl.cpp:
+ (HTMLObjectElementImpl::HTMLObjectElementImpl):
+ (HTMLObjectElementImpl::removedFromDocument):
+ (HTMLObjectElementImpl::attach):
+ * khtml/html/html_objectimpl.h:
+ * khtml/misc/loader.cpp:
+ (CachedImage::ref):
+ * khtml/rendering/render_image.cpp:
+ (RenderImage::RenderImage):
+ (RenderImage::setImage):
+ (RenderImage::updateAltText):
+ * khtml/rendering/render_image.h:
+ (khtml::RenderImage::getImage):
+ * khtml/rendering/render_object.cpp:
+ (RenderObject::canvas):
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::dispatchImageLoadEventSoon):
+ (DocumentImpl::removeImage):
+ (DocumentImpl::dispatchImageLoadEventsNow):
+ * khtml/xml/dom_docimpl.h:
+
2004-05-10 Darin Adler <darin at apple.com>
Reviewed by Vicki.
diff --git a/WebCore/khtml/html/html_imageimpl.cpp b/WebCore/khtml/html/html_imageimpl.cpp
index ef34931..a7bfd43 100644
--- a/WebCore/khtml/html/html_imageimpl.cpp
+++ b/WebCore/khtml/html/html_imageimpl.cpp
@@ -50,10 +50,86 @@
using namespace DOM;
using namespace khtml;
+HTMLImageLoader::HTMLImageLoader(ElementImpl* elt)
+:m_element(elt), m_image(0), m_firedLoad(true), m_imageComplete(true)
+{
+}
+
+HTMLImageLoader::~HTMLImageLoader()
+{
+ if (m_image)
+ m_image->deref(this);
+}
+
+void HTMLImageLoader::updateFromElement()
+{
+ // If we're not making renderers for the page, then don't load images. We don't want to slow
+ // down the raw HTML parsing case by loading images we don't intend to display.
+ if (!element()->getDocument()->renderer())
+ return;
+
+ AtomicString attr;
+ if (element()->id() == ID_OBJECT)
+ attr = element()->getAttribute(ATTR_DATA);
+ else
+ attr = element()->getAttribute(ATTR_SRC);
+
+ // Treat a lack of src or empty string for src as no image at all.
+ CachedImage* newImage = 0;
+ if (!attr.isEmpty())
+ newImage = element()->getDocument()->docLoader()->requestImage(khtml::parseURL(attr));
+
+ if (newImage != m_image) {
+ m_firedLoad = false;
+ m_imageComplete = false;
+ CachedImage* oldImage = m_image;
+ m_image = newImage;
+ if (m_image)
+ m_image->ref(this);
+ if (oldImage)
+ oldImage->deref(this);
+ }
+}
+
+void HTMLImageLoader::removedFromDocument()
+{
+ if (m_image) {
+ m_image->deref(this);
+ m_image = 0;
+ m_element->getDocument()->removeImage(this);
+ }
+
+ m_firedLoad = true;
+ m_imageComplete = true;
+}
+
+void HTMLImageLoader::dispatchLoadEvent()
+{
+ if (!m_firedLoad) {
+ m_firedLoad = true;
+ if (m_image->isErrorImage())
+ element()->dispatchHTMLEvent(EventImpl::ERROR_EVENT, false, false);
+ else
+ element()->dispatchHTMLEvent(EventImpl::LOAD_EVENT, false, false);
+ }
+}
+
+void HTMLImageLoader::notifyFinished(CachedObject* image)
+{
+ m_imageComplete = true;
+ DocumentImpl* document = element()->getDocument();
+ if (document)
+ document->dispatchImageLoadEventSoon(this);
+ if (element()->renderer()) {
+ RenderImage* imageObj = static_cast<RenderImage*>(element()->renderer());
+ imageObj->setImage(m_image);
+ }
+}
+
// -------------------------------------------------------------------------
HTMLImageElementImpl::HTMLImageElementImpl(DocumentPtr *doc)
- : HTMLElementImpl(doc)
+ : HTMLElementImpl(doc), m_imageLoader(this)
{
ismap = false;
}
@@ -97,8 +173,10 @@ void HTMLImageElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
switch (attr->id())
{
case ATTR_ALT:
+ if (m_render) static_cast<RenderImage*>(m_render)->updateAltText();
+ break;
case ATTR_SRC:
- if (m_render) m_render->updateFromElement();
+ m_imageLoader.updateFromElement();
break;
case ATTR_WIDTH:
addCSSLength(attr, CSS_PROP_WIDTH, attr->value());
@@ -180,11 +258,7 @@ void HTMLImageElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
}
#if APPLE_CHANGES
case ATTR_COMPOSITE:
- {
_compositeOperator = attr->value().string();
- if (m_render)
- m_render->updateFromElement();
- }
#endif
// fall through
default:
@@ -222,8 +296,10 @@ RenderObject *HTMLImageElementImpl::createRenderer(RenderArena *arena, RenderSty
void HTMLImageElementImpl::attach()
{
HTMLElementImpl::attach();
- if (m_render) {
- m_render->updateFromElement();
+
+ if (renderer()) {
+ RenderImage* imageObj = static_cast<RenderImage*>(renderer());
+ imageObj->setImage(m_imageLoader.image());
}
if (getDocument()->isHTMLDocument()) {
@@ -236,14 +312,19 @@ void HTMLImageElementImpl::attach()
void HTMLImageElementImpl::detach()
{
if (getDocument()->isHTMLDocument()) {
- HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
- document->removeNamedImageOrForm(oldIdAttr);
- document->removeNamedImageOrForm(oldNameAttr);
+ HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+ document->removeNamedImageOrForm(oldIdAttr);
+ document->removeNamedImageOrForm(oldNameAttr);
}
HTMLElementImpl::detach();
}
+void HTMLImageElementImpl::removedFromDocument()
+{
+ m_imageLoader.removedFromDocument();
+}
+
long HTMLImageElementImpl::width() const
{
if (!m_render) {
@@ -295,10 +376,8 @@ long HTMLImageElementImpl::height() const
QImage HTMLImageElementImpl::currentImage() const
{
RenderImage *r = static_cast<RenderImage*>(renderer());
-
- if(r)
+ if (r)
return r->pixmap().convertToImage();
-
return QImage();
}
diff --git a/WebCore/khtml/html/html_imageimpl.h b/WebCore/khtml/html/html_imageimpl.h
index 472e5bb..654724b 100644
--- a/WebCore/khtml/html/html_imageimpl.h
+++ b/WebCore/khtml/html/html_imageimpl.h
@@ -28,11 +28,42 @@
#include "rendering/render_object.h"
#include <qregion.h>
+#include <qmap.h>
+#include <qpixmap.h>
+
+namespace khtml {
+ class CachedImage;
+ class CachedObjectClient;
+}
namespace DOM {
class DOMString;
+class HTMLImageLoader: public khtml::CachedObjectClient {
+public:
+ HTMLImageLoader(ElementImpl* elt);
+ virtual ~HTMLImageLoader();
+
+ void updateFromElement();
+ void removedFromDocument();
+
+ void dispatchLoadEvent();
+
+ ElementImpl* element() const { return m_element; }
+ bool imageComplete() const { return m_imageComplete; }
+ khtml::CachedImage* image() const { return m_image; }
+
+ // CachedObjectClient API
+ virtual void notifyFinished(khtml::CachedObject *finishedObj);
+
+private:
+ ElementImpl* m_element;
+ khtml::CachedImage* m_image;
+ bool m_firedLoad : 1;
+ bool m_imageComplete : 1;
+};
+
class HTMLImageElementImpl
: public HTMLElementImpl
{
@@ -49,7 +80,8 @@ public:
virtual void attach();
virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
virtual void detach();
-
+ virtual void removedFromDocument();
+
long width() const;
long height() const;
@@ -67,6 +99,7 @@ public:
#endif
protected:
+ HTMLImageLoader m_imageLoader;
DOMString usemap;
bool ismap;
QString oldIdAttr;
diff --git a/WebCore/khtml/html/html_objectimpl.cpp b/WebCore/khtml/html/html_objectimpl.cpp
index a9f8dc7..4c48f34 100644
--- a/WebCore/khtml/html/html_objectimpl.cpp
+++ b/WebCore/khtml/html/html_objectimpl.cpp
@@ -339,7 +339,8 @@ bool HTMLEmbedElementImpl::isURLAttribute(AttributeImpl *attr) const
// -------------------------------------------------------------------------
-HTMLObjectElementImpl::HTMLObjectElementImpl(DocumentPtr *doc) : HTMLElementImpl(doc)
+HTMLObjectElementImpl::HTMLObjectElementImpl(DocumentPtr *doc)
+: HTMLElementImpl(doc), m_imageLoader(this)
{
needWidgetUpdate = false;
}
@@ -449,13 +450,20 @@ RenderObject *HTMLObjectElementImpl::createRenderer(RenderArena *arena, RenderSt
return new (arena) RenderPartObject(this);
}
+void HTMLObjectElementImpl::removedFromDocument()
+{
+ m_imageLoader.removedFromDocument();
+}
+
void HTMLObjectElementImpl::attach()
{
HTMLElementImpl::attach();
if (m_render) {
if (canRenderImageType(serviceType)) {
- m_render->updateFromElement();
+ m_imageLoader.updateFromElement();
+ RenderImage* imageObj = static_cast<RenderImage*>(renderer());
+ imageObj->setImage(m_imageLoader.image());
} else {
// If we are already cleared, then it means that we were attach()-ed previously
// with no renderer. We will actually need to do an update in order to ensure
diff --git a/WebCore/khtml/html/html_objectimpl.h b/WebCore/khtml/html/html_objectimpl.h
index f30e0f7..b6cf307 100644
--- a/WebCore/khtml/html/html_objectimpl.h
+++ b/WebCore/khtml/html/html_objectimpl.h
@@ -23,7 +23,7 @@
#ifndef HTML_OBJECTIMPL_H
#define HTML_OBJECTIMPL_H
-#include "html_elementimpl.h"
+#include "html_imageimpl.h"
#include "xml/dom_stringimpl.h"
#include "java/kjavaappletcontext.h"
@@ -117,7 +117,9 @@ public:
virtual bool rendererIsNeeded(khtml::RenderStyle *);
virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
virtual void detach();
-
+
+ virtual void removedFromDocument();
+
virtual void recalcStyle( StyleChange ch );
DocumentImpl* contentDocument() const;
@@ -128,6 +130,7 @@ public:
QString url;
QString classId;
bool needWidgetUpdate;
+ HTMLImageLoader m_imageLoader;
};
// -------------------------------------------------------------------------
diff --git a/WebCore/khtml/misc/loader.cpp b/WebCore/khtml/misc/loader.cpp
index 87dc473..709f7ac 100644
--- a/WebCore/khtml/misc/loader.cpp
+++ b/WebCore/khtml/misc/loader.cpp
@@ -556,7 +556,7 @@ void CachedImage::ref( CachedObjectClient *c )
}
// for mouseovers, dynamic changes
- if ( m_status >= Persistent && !valid_rect().isNull() )
+ if (!valid_rect().isNull())
c->setPixmap( pixmap(), valid_rect(), this);
if(!m_loading) c->notifyFinished(this);
diff --git a/WebCore/khtml/rendering/render_image.cpp b/WebCore/khtml/rendering/render_image.cpp
index 85da492..19f3514 100644
--- a/WebCore/khtml/rendering/render_image.cpp
+++ b/WebCore/khtml/rendering/render_image.cpp
@@ -54,7 +54,6 @@ RenderImage::RenderImage(NodeImpl *_node)
{
image = 0;
berrorPic = false;
- loadEventSent = false;
m_selectionState = SelectionNone;
setIntrinsicWidth( 0 );
@@ -82,6 +81,15 @@ void RenderImage::setContentObject(CachedObject* co)
}
}
+void RenderImage::setImage(CachedImage* newImage)
+{
+ if (image)
+ image->deref(this);
+ image = newImage;
+ if (image)
+ image->ref(this);
+}
+
void RenderImage::setPixmap( const QPixmap &p, const QRect& r, CachedImage *o)
{
if(o != image) {
@@ -520,57 +528,6 @@ void RenderImage::layout()
setNeedsLayout(false);
}
-void RenderImage::notifyFinished(CachedObject *finishedObj)
-{
- if (image == finishedObj) {
- NodeImpl *node = element();
- if (node) {
- DocumentImpl *document = node->getDocument();
- if (document) {
- document->dispatchImageLoadEventSoon(this);
- }
- }
- }
-}
-
-void RenderImage::dispatchLoadEvent()
-{
- if (!loadEventSent) {
- NodeImpl *node = element();
- if (node) {
- loadEventSent = true;
- if (image->isErrorImage()) {
- node->dispatchHTMLEvent(EventImpl::ERROR_EVENT, false, false);
- } else {
- node->dispatchHTMLEvent(EventImpl::LOAD_EVENT, false, false);
- }
- }
- }
-}
-
-#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()
-{
- NodeImpl *node = element();
- if (node) {
- DocumentImpl *document = node->getDocument();
- if (document) {
- document->removeImage(this);
- }
- }
- RenderReplaced::detach();
-}
-
HTMLMapElementImpl* RenderImage::imageMap()
{
HTMLImageElementImpl* i = element()->id() == ID_IMG ? static_cast<HTMLImageElementImpl*>(element()) : 0;
@@ -597,33 +554,8 @@ bool RenderImage::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty,
return inside;
}
-void RenderImage::updateFromElement()
+void RenderImage::updateAltText()
{
- DOMString attr;
- // Support images in OBJECT tags.
- if (element()->id() == ID_OBJECT) {
- attr = element()->getAttribute(ATTR_DATA);
- } else {
- attr = element()->getAttribute(ATTR_SRC);
- }
-
- // Treat a lack of src or empty string for src as no image at all, not the page itself
- // loaded as an image.
- CachedImage *new_image;
- if (attr.isEmpty())
- new_image = NULL;
- else
- new_image = element()->getDocument()->docLoader()->requestImage(khtml::parseURL(attr));
-
- if(new_image && new_image != image && (!style() || !style()->contentData())) {
- loadEventSent = false;
- CachedImage *old_image = image;
- image = new_image;
- image->ref(this);
- berrorPic = image->isErrorImage();
- if (old_image) old_image->deref(this);
- }
-
if (element()->id() == ID_INPUT)
alt = static_cast<HTMLInputElementImpl*>(element())->altText();
else if (element()->id() == ID_IMG)
diff --git a/WebCore/khtml/rendering/render_image.h b/WebCore/khtml/rendering/render_image.h
index 4eb33c4..7439809 100644
--- a/WebCore/khtml/rendering/render_image.h
+++ b/WebCore/khtml/rendering/render_image.h
@@ -66,19 +66,17 @@ public:
// hook to keep RendeObject::m_inline() up to date
virtual void setStyle(RenderStyle *style);
- virtual void updateFromElement();
-
- virtual void notifyFinished(CachedObject *finishedObj);
- void dispatchLoadEvent();
-
+ void updateAltText();
+
+ void setImage(CachedImage* image);
+ CachedImage* getImage() const { return image; }
+
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty,
HitTestAction hitTestAction = HitTestAll, bool inside=false);
virtual int calcReplacedWidth() const;
virtual int calcReplacedHeight() const;
- virtual void detach();
-
// Called to set generated content images (e.g., :before/:after generated images).
void setContentObject(CachedObject* co);
@@ -110,7 +108,6 @@ private:
CachedImage *image;
bool berrorPic : 1;
- bool loadEventSent : 1;
SelectionState m_selectionState : 3;
};
diff --git a/WebCore/khtml/rendering/render_object.cpp b/WebCore/khtml/rendering/render_object.cpp
index 56fa118..e8387e5 100644
--- a/WebCore/khtml/rendering/render_object.cpp
+++ b/WebCore/khtml/rendering/render_object.cpp
@@ -1544,11 +1544,7 @@ int RenderObject::paddingRight() const
RenderCanvas* RenderObject::canvas() const
{
- RenderObject* o = const_cast<RenderObject*>( this );
- while ( o->parent() ) o = o->parent();
-
- KHTMLAssert( o->isCanvas() );
- return static_cast<RenderCanvas*>( o );
+ return static_cast<RenderCanvas*>(document()->renderer());
}
RenderObject *RenderObject::container() const
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 555cce5..84b6560 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -2407,7 +2407,7 @@ EventListener *DocumentImpl::createHTMLEventListener(QString code)
}
}
-void DocumentImpl::dispatchImageLoadEventSoon(RenderImage *image)
+void DocumentImpl::dispatchImageLoadEventSoon(HTMLImageLoader *image)
{
m_imageLoadEventDispatchSoonList.append(image);
if (!m_imageLoadEventTimer) {
@@ -2415,7 +2415,7 @@ void DocumentImpl::dispatchImageLoadEventSoon(RenderImage *image)
}
}
-void DocumentImpl::removeImage(RenderImage *image)
+void DocumentImpl::removeImage(HTMLImageLoader* image)
{
// Remove instances of this image from both lists.
// Use loops because we allow multiple instances to get into the lists.
@@ -2436,11 +2436,11 @@ void DocumentImpl::dispatchImageLoadEventsNow()
m_imageLoadEventDispatchingList = m_imageLoadEventDispatchSoonList;
m_imageLoadEventDispatchSoonList.clear();
- for (QPtrListIterator<RenderImage> it(m_imageLoadEventDispatchingList); it.current(); ) {
- RenderImage *image = it.current();
+ for (QPtrListIterator<HTMLImageLoader> it(m_imageLoadEventDispatchingList); it.current(); ) {
+ HTMLImageLoader* image = it.current();
// Must advance iterator *before* dispatching call.
// Otherwise, it might be advanced automatically if dispatching the call had a side effect
- // of destroying the current RenderImage, and then we would advance past the *next* item,
+ // of destroying the current HTMLImageLoader, and then we would advance past the *next* item,
// missing one altogether.
++it;
image->dispatchLoadEvent();
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index db2ce55..564dc11 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -92,6 +92,7 @@ namespace DOM {
class GenericRONamedNodeMapImpl;
class HTMLDocumentImpl;
class HTMLElementImpl;
+ class HTMLImageLoader;
class HTMLMapElementImpl;
class NodeFilter;
class NodeFilterImpl;
@@ -476,9 +477,9 @@ public:
*/
void processHttpEquiv(const DOMString &equiv, const DOMString &content);
- void dispatchImageLoadEventSoon(khtml::RenderImage *);
+ void dispatchImageLoadEventSoon(HTMLImageLoader*);
void dispatchImageLoadEventsNow();
- void removeImage(khtml::RenderImage *);
+ void removeImage(HTMLImageLoader*);
virtual void timerEvent(QTimerEvent *);
// Returns the owning element in the parent document.
@@ -601,8 +602,8 @@ protected:
KWQAccObjectCache* m_accCache;
#endif
- QPtrList<khtml::RenderImage> m_imageLoadEventDispatchSoonList;
- QPtrList<khtml::RenderImage> m_imageLoadEventDispatchingList;
+ QPtrList<HTMLImageLoader> m_imageLoadEventDispatchSoonList;
+ QPtrList<HTMLImageLoader> m_imageLoadEventDispatchingList;
int m_imageLoadEventTimer;
NodeImpl* m_cssTarget;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list