KHtml

html_imageimpl.h
1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright (C) 1999 Lars Knoll ([email protected])
5  * (C) 1999 Antti Koivisto ([email protected])
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  */
23 #ifndef HTML_IMAGEIMPL_H
24 #define HTML_IMAGEIMPL_H
25 
26 #include "html/html_inlineimpl.h"
27 #include "misc/khtmllayout.h"
28 #include "misc/loader_client.h"
29 #include "rendering/render_object.h"
30 
31 #include <QRegion>
32 
33 namespace DOM
34 {
35 
36 class DOMString;
37 class HTMLFormElementImpl;
38 class HTMLCollectionImpl;
39 
40 class HTMLImageElementImpl
41  : public HTMLElementImpl, public khtml::CachedObjectClient
42 {
43  friend class HTMLFormElementImpl;
44 public:
45  HTMLImageElementImpl(DocumentImpl *doc, HTMLFormElementImpl *f = nullptr);
46  ~HTMLImageElementImpl();
47 
48  Id id() const override;
49 
50  void parseAttribute(AttributeImpl *) override;
51 
52  void attach() override;
53  void removedFromDocument() override;
54  void insertedIntoDocument() override;
55  void addId(const DOMString &id) override;
56  void removeId(const DOMString &id) override;
57 
58  long width() const;
59  long height() const;
60  void setWidth(long width);
61  void setHeight(long height);
62 
63  long x() const;
64  long y() const;
65 
66  bool isServerMap() const
67  {
68  return (ismap && !usemap.length());
69  }
70  /** Return the image for this element.
71  * This has to convert the pixmap into an image first.
72  * This will return undefined results if complete() is not true.
73  */
74  QImage currentImage() const;
75  /** Return the pixmap for this element.
76  * This will return undefined results if complete() is not true.
77  */
78  QPixmap currentPixmap() const;
79 
80  DOMString altText() const;
81 
82  DOMString imageMap() const
83  {
84  return usemap;
85  }
86  /** See if the image has been completely downloaded.
87  * @return True if and only if the image is completely downloaded yet*/
88  bool complete() const;
89 
90  void notifyFinished(khtml::CachedObject *finishedObj) override;
91  void dispatchLoadEvent();
92 
93  khtml::CachedImage *image()
94  {
95  return m_image;
96  }
97 
98  // This returns true if this image has (or ever had!) cross-domain data; which will make
99  // it unsafe to getImageData() it in canvas;
100  bool isUnsafe() const
101  {
102  return unsafe;
103  }
104 protected:
105  DOMString usemap;
106  bool ismap;
107  bool loadEventSent;
108  bool unsafe;
109  khtml::CachedImage *m_image;
110  HTMLFormElementImpl *m_form;
111  DOMString m_name;
112 };
113 
114 //------------------------------------------------------------------
115 
116 class HTMLAreaElementImpl : public HTMLAnchorElementImpl
117 {
118 public:
119 
120  enum Shape { Default, Poly, Rect, Circle, Unknown };
121 
122  HTMLAreaElementImpl(DocumentImpl *doc);
123  ~HTMLAreaElementImpl();
124 
125  Id id() const override;
126 
127  void parseAttribute(AttributeImpl *attr) override;
128 
129  bool isDefault() const
130  {
131  return shape == Default;
132  }
133 
134  bool mapMouseEvent(int x_, int y_, int width_, int height_,
135  khtml::RenderObject::NodeInfo &info);
136 
137  QRect getRect() const override;
138 
139  QRegion cachedRegion() const
140  {
141  return region;
142  }
143 
144 protected:
145  QRegion getRegion(int width_, int height) const;
146  QRegion region;
147  khtml::Length *m_coords;
148  int m_coordsLen;
149  int lastw, lasth;
150  KDE_BF_ENUM(Shape) shape : 3;
151  bool nohref : 1;
152 };
153 
154 // -------------------------------------------------------------------------
155 
156 class HTMLMapElementImpl : public HTMLElementImpl
157 {
158 public:
159  HTMLMapElementImpl(DocumentImpl *doc);
160 
161  ~HTMLMapElementImpl();
162 
163  Id id() const override;
164 
165  virtual DOMString getName() const
166  {
167  return name;
168  }
169 
170  void parseAttribute(AttributeImpl *attr) override;
171 
172  bool mapMouseEvent(int x_, int y_, int width_, int height_,
173  khtml::RenderObject::NodeInfo &info);
174 
175  HTMLCollectionImpl *areas();
176 private:
177 
178  QString name;
179 };
180 
181 } //namespace
182 
183 #endif
QString name(const QVariant &location)
a cached image
Definition: loader.h:359
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
int64_t Id
This library provides a full-featured HTML parser and widget.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.