Home | History | Annotate | Download | only in html
      1 /*
      2  * Copyright (C) 1999 Lars Knoll (knoll (at) kde.org)
      3  *           (C) 1999 Antti Koivisto (koivisto (at) kde.org)
      4  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
      5  * Copyright (C) 2008 Nikolas Zimmermann <zimmermann (at) kde.org>
      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 
     24 #ifndef HTMLScriptElement_h
     25 #define HTMLScriptElement_h
     26 
     27 #include "ScriptElement.h"
     28 #include "HTMLElement.h"
     29 
     30 namespace WebCore {
     31 
     32 class HTMLScriptElement : public HTMLElement
     33                         , public ScriptElement {
     34 public:
     35     HTMLScriptElement(const QualifiedName&, Document*, bool createdByParser);
     36     ~HTMLScriptElement();
     37 
     38     virtual bool shouldExecuteAsJavaScript() const;
     39     virtual String scriptContent() const;
     40 
     41     virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
     42     virtual int tagPriority() const { return 1; }
     43     virtual bool checkDTD(const Node* newChild) { return newChild->isTextNode(); }
     44 
     45     virtual void parseMappedAttribute(MappedAttribute*);
     46     virtual void insertedIntoDocument();
     47     virtual void removedFromDocument();
     48     virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
     49 
     50     virtual bool isURLAttribute(Attribute*) const;
     51     virtual void finishParsingChildren();
     52 
     53     String text() const;
     54     void setText(const String&);
     55 
     56     String htmlFor() const;
     57     void setHtmlFor(const String&);
     58 
     59     String event() const;
     60     void setEvent(const String&);
     61 
     62     String charset() const;
     63     void setCharset(const String&);
     64 
     65     bool defer() const;
     66     void setDefer(bool);
     67 
     68     KURL src() const;
     69     void setSrc(const String&);
     70 
     71     String type() const;
     72     void setType(const String&);
     73 
     74     virtual String scriptCharset() const;
     75 
     76     virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
     77 
     78     bool haveFiredLoadEvent() const { return m_data.haveFiredLoadEvent(); }
     79 
     80 protected:
     81     virtual String sourceAttributeValue() const;
     82     virtual String charsetAttributeValue() const;
     83     virtual String typeAttributeValue() const;
     84     virtual String languageAttributeValue() const;
     85     virtual String forAttributeValue() const;
     86 
     87     virtual void dispatchLoadEvent();
     88     virtual void dispatchErrorEvent();
     89 
     90 private:
     91     ScriptElementData m_data;
     92 };
     93 
     94 } //namespace
     95 
     96 #endif
     97