• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3  * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
4  * Copyright (C) 2002, 2006, 2008, 2012 Apple Inc. All rights reserved.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef StyleRuleImport_h
23 #define StyleRuleImport_h
24 
25 #include "core/css/StyleRule.h"
26 #include "core/fetch/ResourcePtr.h"
27 #include "core/fetch/StyleSheetResourceClient.h"
28 
29 namespace WebCore {
30 
31 class CSSStyleSheetResource;
32 class MediaQuerySet;
33 class StyleSheetContents;
34 
35 class StyleRuleImport : public StyleRuleBase {
36     WTF_MAKE_FAST_ALLOCATED;
37 public:
38     static PassRefPtr<StyleRuleImport> create(const String& href, PassRefPtr<MediaQuerySet>);
39 
40     ~StyleRuleImport();
41 
parentStyleSheet()42     StyleSheetContents* parentStyleSheet() const { return m_parentStyleSheet; }
setParentStyleSheet(StyleSheetContents * sheet)43     void setParentStyleSheet(StyleSheetContents* sheet) { ASSERT(sheet); m_parentStyleSheet = sheet; }
clearParentStyleSheet()44     void clearParentStyleSheet() { m_parentStyleSheet = 0; }
45 
href()46     String href() const { return m_strHref; }
styleSheet()47     StyleSheetContents* styleSheet() const { return m_styleSheet.get(); }
48 
49     bool isLoading() const;
mediaQueries()50     MediaQuerySet* mediaQueries() { return m_mediaQueries.get(); }
51 
52     void requestStyleSheet();
53 
54 private:
55     // NOTE: We put the StyleSheetResourceClient in a member instead of inheriting from it
56     // to avoid adding a vptr to StyleRuleImport.
57     class ImportedStyleSheetClient : public StyleSheetResourceClient {
58     public:
ImportedStyleSheetClient(StyleRuleImport * ownerRule)59         ImportedStyleSheetClient(StyleRuleImport* ownerRule) : m_ownerRule(ownerRule) { }
~ImportedStyleSheetClient()60         virtual ~ImportedStyleSheetClient() { }
setCSSStyleSheet(const String & href,const KURL & baseURL,const String & charset,const CSSStyleSheetResource * sheet)61         virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CSSStyleSheetResource* sheet)
62         {
63             m_ownerRule->setCSSStyleSheet(href, baseURL, charset, sheet);
64         }
65     private:
66         StyleRuleImport* m_ownerRule;
67     };
68 
69     void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CSSStyleSheetResource*);
70     friend class ImportedStyleSheetClient;
71 
72     StyleRuleImport(const String& href, PassRefPtr<MediaQuerySet>);
73 
74     StyleSheetContents* m_parentStyleSheet;
75 
76     ImportedStyleSheetClient m_styleSheetClient;
77     String m_strHref;
78     RefPtr<MediaQuerySet> m_mediaQueries;
79     RefPtr<StyleSheetContents> m_styleSheet;
80     ResourcePtr<CSSStyleSheetResource> m_resource;
81     bool m_loading;
82 };
83 
84 DEFINE_STYLE_RULE_TYPE_CASTS(Import);
85 
86 } // namespace WebCore
87 
88 #endif
89