Home | History | Annotate | Download | only in css
      1 /*
      2  * (C) 1999-2003 Lars Knoll (knoll (at) kde.org)
      3  * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
      4  *
      5  * This library is free software; you can redistribute it and/or
      6  * modify it under the terms of the GNU Library General Public
      7  * License as published by the Free Software Foundation; either
      8  * version 2 of the License, or (at your option) any later version.
      9  *
     10  * This library is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13  * Library General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU Library General Public License
     16  * along with this library; see the file COPYING.LIB.  If not, write to
     17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     18  * Boston, MA 02110-1301, USA.
     19  */
     20 
     21 #ifndef StyleSheet_h
     22 #define StyleSheet_h
     23 
     24 #include "KURLHash.h"
     25 #include "PlatformString.h"
     26 #include "StyleList.h"
     27 #include <wtf/ListHashSet.h>
     28 
     29 namespace WebCore {
     30 
     31 class CachedCSSStyleSheet;
     32 class MediaList;
     33 class Node;
     34 
     35 class StyleSheet : public StyleList {
     36 public:
     37     virtual ~StyleSheet();
     38 
     39     bool disabled() const { return m_disabled; }
     40     void setDisabled(bool disabled) { m_disabled = disabled; styleSheetChanged(); }
     41 
     42     Node* ownerNode() const { return m_parentNode; }
     43     void clearOwnerNode() { m_parentNode = 0; }
     44     StyleSheet *parentStyleSheet() const;
     45 
     46     // Note that href is the URL that started the redirect chain that led to
     47     // this style sheet. This property probably isn't useful for much except
     48     // the JavaScript binding (which needs to use this value for security).
     49     const String& href() const { return m_originalURL; }
     50 
     51     void setFinalURL(const KURL& finalURL) { m_finalURL = finalURL; }
     52     const KURL& finalURL() const { return m_finalURL; }
     53 
     54     const String& title() const { return m_strTitle; }
     55     void setTitle(const String& s) { m_strTitle = s; }
     56     MediaList* media() const { return m_media.get(); }
     57     void setMedia(PassRefPtr<MediaList>);
     58 
     59     virtual String type() const = 0;
     60     virtual bool isLoading() = 0;
     61     virtual void styleSheetChanged() { }
     62 
     63     virtual KURL completeURL(const String& url) const;
     64     virtual void addSubresourceStyleURLs(ListHashSet<KURL>&) { }
     65 
     66     virtual bool parseString(const String&, bool strict = true) = 0;
     67 
     68 protected:
     69     StyleSheet(Node* ownerNode, const String& href, const KURL& finalURL);
     70     StyleSheet(StyleSheet* parentSheet, const String& href, const KURL& finalURL);
     71     StyleSheet(StyleBase* owner, const String& href, const KURL& finalURL);
     72 
     73 private:
     74     virtual bool isStyleSheet() const { return true; }
     75 
     76     Node* m_parentNode;
     77     String m_originalURL;
     78     KURL m_finalURL;
     79     String m_strTitle;
     80     RefPtr<MediaList> m_media;
     81     bool m_disabled;
     82 };
     83 
     84 } // namespace
     85 
     86 #endif
     87