File indexing completed on 2024-05-05 16:10:13
0001 /* 0002 * This file is part of the DOM implementation for KDE. 0003 * 0004 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 0005 * (C) 1999 Antti Koivisto (koivisto@kde.org) 0006 * (C) 2002-2003 Apple Computer, Inc. 0007 * 0008 * This library is free software; you can redistribute it and/or 0009 * modify it under the terms of the GNU Library General Public 0010 * License as published by the Free Software Foundation; either 0011 * version 2 of the License, or (at your option) any later version. 0012 * 0013 * This library is distributed in the hope that it will be useful, 0014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 * Library General Public License for more details. 0017 * 0018 * You should have received a copy of the GNU Library General Public License 0019 * along with this library; see the file COPYING.LIB. If not, write to 0020 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0021 * Boston, MA 02110-1301, USA. 0022 * 0023 */ 0024 #ifndef HTML_HEADIMPL_H 0025 #define HTML_HEADIMPL_H 0026 0027 #include "html/html_elementimpl.h" 0028 #include "misc/loader_client.h" 0029 #include "css/css_stylesheetimpl.h" 0030 0031 namespace khtml 0032 { 0033 class CachedCSSStyleSheet; 0034 class CachedObject; 0035 } 0036 0037 namespace DOM 0038 { 0039 0040 class DOMString; 0041 class StyleSheetImpl; 0042 class CSSStyleSheetImpl; 0043 0044 class HTMLBaseElementImpl : public HTMLElementImpl 0045 { 0046 public: 0047 HTMLBaseElementImpl(DocumentImpl *doc) 0048 : HTMLElementImpl(doc) {} 0049 0050 DOMString href() const 0051 { 0052 return DOMString(m_href); 0053 } 0054 DOMString target() const 0055 { 0056 return m_target; 0057 } 0058 0059 Id id() const override; 0060 void parseAttribute(AttributeImpl *attr) override; 0061 void insertedIntoDocument() override; 0062 void removedFromDocument() override; 0063 0064 void process(); 0065 0066 protected: 0067 QString m_href; 0068 DOMString m_target; 0069 }; 0070 0071 // ------------------------------------------------------------------------- 0072 0073 class HTMLLinkElementImpl : public khtml::CachedObjectClient, public HTMLElementImpl 0074 { 0075 public: 0076 HTMLLinkElementImpl(DocumentImpl *doc) 0077 : HTMLElementImpl(doc), m_cachedSheet(nullptr), m_sheet(nullptr), m_isDisabled(false), 0078 m_loading(false), m_alternate(false), m_isCSSSheet(false) {} 0079 0080 ~HTMLLinkElementImpl(); 0081 0082 Id id() const override; 0083 0084 const StyleSheetImpl *sheet() const 0085 { 0086 return m_sheet; 0087 } 0088 StyleSheetImpl *sheet() 0089 { 0090 return m_sheet; 0091 } 0092 0093 // overload from HTMLElementImpl 0094 void parseAttribute(AttributeImpl *attr) override; 0095 0096 void process(); 0097 0098 void insertedIntoDocument() override; 0099 void removedFromDocument() override; 0100 0101 // from CachedObjectClient 0102 void setStyleSheet(const DOM::DOMString &url, const DOM::DOMString &sheet, const DOM::DOMString &charset, const DOM::DOMString &mimetype) override; 0103 void error(int err, const QString &text) override; 0104 bool isLoading() const; 0105 bool checkAddPendingSheet() override; 0106 bool checkRemovePendingSheet() override; 0107 0108 bool isAlternate() const 0109 { 0110 return m_alternate; 0111 } 0112 bool isCSSStyleSheet() const 0113 { 0114 return m_isCSSSheet; 0115 } 0116 bool isDisabled() const 0117 { 0118 return m_isDisabled; 0119 } 0120 void setDisabled(bool disabled) 0121 { 0122 m_isDisabled = disabled; 0123 } 0124 0125 protected: 0126 void finished(); 0127 0128 khtml::CachedCSSStyleSheet *m_cachedSheet; 0129 CSSStyleSheetImpl *m_sheet; 0130 DOMString m_url; 0131 QString m_media; 0132 bool m_isDisabled : 1; 0133 bool m_loading : 1; 0134 bool m_alternate : 1; 0135 bool m_isCSSSheet : 1; 0136 }; 0137 0138 // ------------------------------------------------------------------------- 0139 0140 class HTMLMetaElementImpl : public HTMLElementImpl 0141 { 0142 public: 0143 HTMLMetaElementImpl(DocumentImpl *doc) 0144 : HTMLElementImpl(doc) {} 0145 0146 Id id() const override; 0147 void parseAttribute(AttributeImpl *attr) override; 0148 void insertedIntoDocument() override; 0149 0150 void process(); 0151 0152 protected: 0153 DOMString m_equiv; 0154 DOMString m_content; 0155 }; 0156 0157 // ------------------------------------------------------------------------- 0158 0159 class HTMLScriptElementImpl : public HTMLElementImpl, public khtml::CachedObjectClient 0160 { 0161 public: 0162 HTMLScriptElementImpl(DocumentImpl *doc); 0163 ~HTMLScriptElementImpl(); 0164 0165 void parseAttribute(AttributeImpl *attr) override; 0166 void insertedIntoDocument() override; 0167 void removedFromDocument() override; 0168 void notifyFinished(khtml::CachedObject *finishedObj) override; 0169 void childrenChanged() override; 0170 0171 Id id() const override; 0172 virtual bool isURLAttribute(AttributeImpl *attr) const; 0173 0174 void setCreatedByParser(bool createdByParser) 0175 { 0176 m_createdByParser = createdByParser; 0177 } 0178 0179 bool isValidScript() const; 0180 void evaluateScript(const QString &, const DOMString &); 0181 0182 DOMString text() const; 0183 void setText(const DOMString &str); 0184 0185 DOMString htmlFor() const; 0186 void setHtmlFor(const DOMString &); 0187 0188 DOMString event() const; 0189 void setEvent(const DOMString &); 0190 0191 DOMString charset() const; 0192 void setCharset(const DOMString &); 0193 0194 bool defer() const; 0195 void setDefer(bool); 0196 0197 DOMString src() const; 0198 void setSrc(const DOMString &); 0199 0200 DOMString type() const; 0201 void setType(const DOMString &); 0202 0203 private: 0204 void loadFromUrl(const DOMString &url); 0205 khtml::CachedScript *m_cachedScript; 0206 bool m_createdByParser; 0207 bool m_evaluated; 0208 bool m_hasNonEmptyForAttribute; 0209 }; 0210 0211 // ------------------------------------------------------------------------- 0212 0213 class HTMLStyleElementImpl : public HTMLElementImpl 0214 { 0215 public: 0216 HTMLStyleElementImpl(DocumentImpl *doc) 0217 : HTMLElementImpl(doc), m_sheet(nullptr), m_loading(false) {} 0218 ~HTMLStyleElementImpl(); 0219 0220 Id id() const override; 0221 0222 CSSStyleSheetImpl *sheet() 0223 { 0224 return m_sheet; 0225 } 0226 0227 // overload from HTMLElementImpl 0228 void parseAttribute(AttributeImpl *attr) override; 0229 void insertedIntoDocument() override; 0230 void removedFromDocument() override; 0231 void childrenChanged() override; 0232 0233 bool isLoading() const; 0234 bool checkAddPendingSheet() override; 0235 bool checkRemovePendingSheet() override; 0236 0237 protected: 0238 void parseText(); 0239 0240 CSSStyleSheetImpl *m_sheet; 0241 DOMString m_type; 0242 QString m_media; 0243 bool m_loading; 0244 }; 0245 0246 // ------------------------------------------------------------------------- 0247 0248 class HTMLTitleElementImpl : public HTMLElementImpl 0249 { 0250 public: 0251 HTMLTitleElementImpl(DocumentImpl *doc) 0252 : HTMLElementImpl(doc) {} 0253 0254 DOMString text(); 0255 void setText(const DOMString &str); 0256 0257 Id id() const override; 0258 0259 void childrenChanged() override; 0260 0261 protected: 0262 DOMString m_title; 0263 }; 0264 0265 } //namespace 0266 0267 #endif