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.
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.
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.
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.
22 #ifndef StyleRuleImport_h
23 #define StyleRuleImport_h
25 #include "core/css/StyleRule.h"
26 #include "core/fetch/ResourcePtr.h"
27 #include "core/fetch/StyleSheetResourceClient.h"
28 #include "platform/heap/Handle.h"
32 class CSSStyleSheetResource;
34 class StyleSheetContents;
36 class StyleRuleImport : public StyleRuleBase {
37 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
39 static PassRefPtrWillBeRawPtr<StyleRuleImport> create(const String& href, PassRefPtrWillBeRawPtr<MediaQuerySet>);
43 StyleSheetContents* parentStyleSheet() const { return m_parentStyleSheet; }
44 void setParentStyleSheet(StyleSheetContents* sheet) { ASSERT(sheet); m_parentStyleSheet = sheet; }
45 void clearParentStyleSheet() { m_parentStyleSheet = nullptr; }
47 String href() const { return m_strHref; }
48 StyleSheetContents* styleSheet() const { return m_styleSheet.get(); }
50 bool isLoading() const;
51 MediaQuerySet* mediaQueries() { return m_mediaQueries.get(); }
53 void requestStyleSheet();
55 void traceAfterDispatch(Visitor*);
58 // FIXME: inherit from StyleSheetResourceClient directly to eliminate raw back pointer, as there are no space savings in this.
59 // NOTE: We put the StyleSheetResourceClient in a member instead of inheriting from it
60 // to avoid adding a vptr to StyleRuleImport.
61 class ImportedStyleSheetClient FINAL : public StyleSheetResourceClient {
63 ImportedStyleSheetClient(StyleRuleImport* ownerRule) : m_ownerRule(ownerRule) { }
64 virtual ~ImportedStyleSheetClient() { }
65 virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CSSStyleSheetResource* sheet) OVERRIDE
67 m_ownerRule->setCSSStyleSheet(href, baseURL, charset, sheet);
70 StyleRuleImport* m_ownerRule;
73 void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CSSStyleSheetResource*);
74 friend class ImportedStyleSheetClient;
76 StyleRuleImport(const String& href, PassRefPtrWillBeRawPtr<MediaQuerySet>);
78 RawPtrWillBeMember<StyleSheetContents> m_parentStyleSheet;
80 ImportedStyleSheetClient m_styleSheetClient;
82 RefPtrWillBeMember<MediaQuerySet> m_mediaQueries;
83 RefPtrWillBeMember<StyleSheetContents> m_styleSheet;
84 ResourcePtr<CSSStyleSheetResource> m_resource;
88 DEFINE_STYLE_RULE_TYPE_CASTS(Import);