File indexing completed on 2024-04-28 11:38:11

0001 /*
0002  * This file is part of the DOM implementation for KDE.
0003  *
0004  * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
0005  *           (C) 2000-2003 Dirk Mueller (mueller@kde.org)
0006  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
0007  *           (C) 2000 Simon Hausmann <hausmann@kde.org>
0008  * Copyright (C) 2002 Apple Computer, Inc.
0009  *
0010  * This library is free software; you can redistribute it and/or
0011  * modify it under the terms of the GNU Library General Public
0012  * License as published by the Free Software Foundation; either
0013  * version 2 of the License, or (at your option) any later version.
0014  *
0015  * This library is distributed in the hope that it will be useful,
0016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0018  * Library General Public License for more details.
0019  *
0020  * You should have received a copy of the GNU Library General Public License
0021  * along with this library; see the file COPYING.LIB.  If not, write to
0022  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0023  * Boston, MA 02110-1301, USA.
0024  *
0025  */
0026 
0027 #ifndef HTML_BASEIMPL_H
0028 #define HTML_BASEIMPL_H
0029 
0030 #include "html/dtd.h"
0031 #include "html/html_elementimpl.h"
0032 #include "html/html_objectimpl.h"
0033 #include "misc/khtmllayout.h"
0034 
0035 class KHTMLPart;
0036 
0037 namespace khtml
0038 {
0039 class RenderFrameSet;
0040 class RenderFrame;
0041 class RenderPartObject;
0042 }
0043 
0044 namespace DOM
0045 {
0046 
0047 class DOMString;
0048 class CSSStyleSheetImpl;
0049 class HTMLFrameElement;
0050 
0051 // -------------------------------------------------------------------------
0052 
0053 class HTMLBodyElementImpl : public HTMLElementImpl
0054 {
0055 public:
0056     HTMLBodyElementImpl(DocumentImpl *doc);
0057     ~HTMLBodyElementImpl();
0058 
0059     Id id() const override;
0060 
0061     DOMString aLink() const;
0062     void setALink(const DOMString &value);
0063     DOMString bgColor() const;
0064     void setBgColor(const DOMString &value);
0065     DOMString link() const;
0066     void setLink(const DOMString &value);
0067     DOMString text() const;
0068     void setText(const DOMString &value);
0069     DOMString vLink() const;
0070     void setVLink(const DOMString &value);
0071 
0072     void parseAttribute(AttributeImpl *) override;
0073     void attach() override;
0074 
0075     void insertedIntoDocument() override;
0076     void removedFromDocument() override;
0077 
0078     CSSStyleSheetImpl *sheet() const
0079     {
0080         return m_styleSheet;
0081     }
0082 
0083 protected:
0084     CSSStyleSheetImpl *m_styleSheet;
0085     bool m_bgSet;
0086     bool m_fgSet;
0087 };
0088 
0089 // -------------------------------------------------------------------------
0090 
0091 class HTMLFrameElementImpl : public HTMLPartContainerElementImpl
0092 {
0093     friend class khtml::RenderFrame;
0094     friend class khtml::RenderPartObject;
0095 
0096 public:
0097     HTMLFrameElementImpl(DocumentImpl *doc);
0098 
0099     ~HTMLFrameElementImpl();
0100 
0101     Id id() const override;
0102 
0103     void parseAttribute(AttributeImpl *) override;
0104     void attach() override;
0105     void defaultEventHandler(EventImpl *evt) override;
0106 
0107     bool noResize()
0108     {
0109         return noresize;
0110     }
0111     void setLocation(const QString &str);
0112 
0113     bool isFocusableImpl(FocusType ft) const override;
0114     void setFocus(bool) override;
0115 
0116     DocumentImpl *contentDocument() const;
0117     KHTMLPart    *contentPart() const;
0118 
0119     QString url;
0120     DOMString name; //Computed name for the frame map
0121 
0122     int marginWidth;
0123     int marginHeight;
0124     Qt::ScrollBarPolicy scrolling;
0125 
0126     bool frameBorder : 1;
0127     bool frameBorderSet : 1;
0128     bool noresize : 1;
0129 
0130     void ensureUniqueName();
0131     void computeContent() override;
0132     void setWidgetNotify(QWidget *widget) override;
0133 };
0134 
0135 // -------------------------------------------------------------------------
0136 
0137 class HTMLFrameSetElementImpl : public HTMLElementImpl
0138 {
0139     friend class khtml::RenderFrameSet;
0140 public:
0141     HTMLFrameSetElementImpl(DocumentImpl *doc);
0142 
0143     ~HTMLFrameSetElementImpl();
0144 
0145     Id id() const override;
0146 
0147     void parseAttribute(AttributeImpl *) override;
0148     void attach() override;
0149 
0150     void defaultEventHandler(EventImpl *evt) override;
0151 
0152     bool frameBorder()
0153     {
0154         return frameborder;
0155     }
0156     bool noResize()
0157     {
0158         return noresize;
0159     }
0160 
0161     int totalRows() const
0162     {
0163         return m_totalRows;
0164     }
0165     int totalCols() const
0166     {
0167         return m_totalCols;
0168     }
0169     int border() const
0170     {
0171         return frameborder ? m_border : 0;
0172     }
0173     void detach() override;
0174 
0175     void recalcStyle(StyleChange ch) override;
0176 
0177 protected:
0178     khtml::Length *m_rows;
0179     khtml::Length *m_cols;
0180 
0181     int m_totalRows;
0182     int m_totalCols;
0183     int m_border;
0184 
0185     bool frameborder : 1;
0186     bool frameBorderSet : 1;
0187     bool noresize : 1;
0188     bool m_resizing : 1;  // is the user resizing currently
0189 };
0190 
0191 // -------------------------------------------------------------------------
0192 
0193 class HTMLHeadElementImpl : public HTMLElementImpl
0194 {
0195 public:
0196     HTMLHeadElementImpl(DocumentImpl *doc)
0197         : HTMLElementImpl(doc) {}
0198 
0199     Id id() const override;
0200 };
0201 
0202 // -------------------------------------------------------------------------
0203 
0204 class HTMLHtmlElementImpl : public HTMLElementImpl
0205 {
0206 public:
0207     HTMLHtmlElementImpl(DocumentImpl *doc)
0208         : HTMLElementImpl(doc) {}
0209 
0210     Id id() const override;
0211 };
0212 
0213 // -------------------------------------------------------------------------
0214 
0215 class HTMLIFrameElementImpl : public HTMLFrameElementImpl
0216 {
0217 public:
0218     HTMLIFrameElementImpl(DocumentImpl *doc);
0219 
0220     ~HTMLIFrameElementImpl();
0221 
0222     Id id() const override;
0223 
0224     void parseAttribute(AttributeImpl *attr) override;
0225     void attach() override;
0226 
0227     void computeContent() override;
0228     void setWidgetNotify(QWidget *widget) override;
0229 
0230     void insertedIntoDocument() override;
0231     void removedFromDocument() override;
0232 protected:
0233 
0234     void updateFrame();
0235     bool m_frame;
0236 };
0237 
0238 } //namespace
0239 
0240 #endif
0241