]>
git.saurik.com Git - iphone-api.git/blob - WebCore/ScriptElement.h
2 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 #ifndef ScriptElement_h
22 #define ScriptElement_h
24 #include "CachedResourceClient.h"
25 #include "CachedResourceHandle.h"
31 class ScriptElementData
;
32 class ScriptSourceCode
;
37 virtual ~ScriptElement() { }
39 virtual String
scriptContent() const = 0;
41 virtual String
sourceAttributeValue() const = 0;
42 virtual String
charsetAttributeValue() const = 0;
43 virtual String
typeAttributeValue() const = 0;
44 virtual String
languageAttributeValue() const = 0;
46 virtual void dispatchLoadEvent() = 0;
47 virtual void dispatchErrorEvent() = 0;
49 // A charset for loading the script (may be overridden by HTTP headers or a BOM).
50 virtual String
scriptCharset() const = 0;
53 // Helper functions used by our parent classes.
54 static void insertedIntoDocument(ScriptElementData
&, const String
& sourceUrl
);
55 static void removedFromDocument(ScriptElementData
&);
56 static void childrenChanged(ScriptElementData
&);
57 static void finishParsingChildren(ScriptElementData
&, const String
& sourceUrl
);
58 static void handleSourceAttribute(ScriptElementData
&, const String
& sourceUrl
);
61 // HTML/SVGScriptElement hold this struct as member variable
62 // and pass it to the static helper functions in ScriptElement
63 class ScriptElementData
: private CachedResourceClient
{
65 ScriptElementData(ScriptElement
*, Element
*);
66 virtual ~ScriptElementData();
68 bool ignoresLoadRequest() const;
69 bool shouldExecuteAsJavaScript() const;
71 String
scriptContent() const;
72 String
scriptCharset() const;
74 Element
* element() const { return m_element
; }
75 bool createdByParser() const { return m_createdByParser
; }
76 void setCreatedByParser(bool value
) { m_createdByParser
= value
; }
77 bool haveFiredLoadEvent() const { return m_firedLoad
; }
78 void setHaveFiredLoadEvent(bool firedLoad
) { m_firedLoad
= firedLoad
; }
80 void requestScript(const String
& sourceUrl
);
81 void evaluateScript(const ScriptSourceCode
&);
82 void stopLoadRequest();
85 virtual void notifyFinished(CachedResource
*);
88 ScriptElement
* m_scriptElement
;
90 CachedResourceHandle
<CachedScript
> m_cachedScript
;
91 bool m_createdByParser
;
96 ScriptElement
* toScriptElement(Element
*);