#ifndef HTML_IMAGEIMPL_H
#define HTML_IMAGEIMPL_H
#include "html/html_inlineimpl.h"
#include "misc/khtmllayout.h"
#include "rendering/render_object.h"
#include <loader.h>
#include <qregion.h>
#include <qmap.h>
#include <qpixmap.h>
namespace khtml {
class CachedImage;
class CachedObjectClient;
}
namespace DOM {
class DOMString;
class HTMLFormElementImpl;
class HTMLImageLoader: public khtml::CachedObjectClient {
public:
HTMLImageLoader(ElementImpl* elt);
virtual ~HTMLImageLoader();
void updateFromElement();
void dispatchLoadEvent();
ElementImpl* element() const { return m_element; }
bool imageComplete() const { return m_imageComplete; }
khtml::CachedImage* image() const { return m_image; }
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
{
friend class HTMLFormElementImpl;
public:
HTMLImageElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f = 0);
~HTMLImageElementImpl();
virtual Id id() const;
virtual bool mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const;
virtual void parseHTMLAttribute(HTMLAttributeImpl *);
virtual void attach();
virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
virtual void detach();
long width(bool ignorePendingStylesheets = false) const;
long height(bool ignorePendingStylesheets = false) const;
bool isServerMap() const { return ( ismap && !usemap.length() ); }
QImage currentImage() const;
DOMString altText() const;
DOMString imageMap() const { return usemap; }
virtual bool isURLAttribute(AttributeImpl *attr) const;
#if APPLE_CHANGES
QString compositeOperator() const { return _compositeOperator; }
const QPixmap &pixmap() { return m_imageLoader.image()->pixmap(); }
#endif
protected:
HTMLImageLoader m_imageLoader;
DOMString usemap;
bool ismap;
HTMLFormElementImpl *m_form;
QString oldIdAttr;
QString oldNameAttr;
#if APPLE_CHANGES
QString _compositeOperator;
#endif
};
class HTMLAreaElementImpl : public HTMLAnchorElementImpl
{
public:
enum Shape { Default, Poly, Rect, Circle, Unknown };
HTMLAreaElementImpl(DocumentPtr *doc);
~HTMLAreaElementImpl();
virtual Id id() const;
virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
bool isDefault() const { return shape==Default; }
bool mapMouseEvent(int x_, int y_, int width_, int height_,
khtml::RenderObject::NodeInfo& info);
virtual QRect getRect(khtml::RenderObject* obj) const;
protected:
QRegion getRegion(int width_, int height) const;
QRegion region;
khtml::Length* m_coords;
int m_coordsLen;
int lastw, lasth;
Shape shape;
};
class HTMLMapElementImpl : public HTMLElementImpl
{
public:
HTMLMapElementImpl(DocumentPtr *doc);
~HTMLMapElementImpl();
virtual Id id() const;
virtual DOMString getName() const { return name; }
virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
bool mapMouseEvent(int x_, int y_, int width_, int height_,
khtml::RenderObject::NodeInfo& info);
private:
DOMString name;
};
};
#endif