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 "CachedResourceHandle.h" 26#include "CachedStyleSheetClient.h" 27#include "StyleRule.h" 28 29namespace WebCore { 30 31class CachedCSSStyleSheet; 32class MediaQuerySet; 33class StyleSheetContents; 34 35class StyleRuleImport : public StyleRuleBase { 36 WTF_MAKE_FAST_ALLOCATED; 37public: 38 static PassRefPtr<StyleRuleImport> create(const String& href, PassRefPtr<MediaQuerySet>); 39 40 ~StyleRuleImport(); 41 42 StyleSheetContents* parentStyleSheet() const { return m_parentStyleSheet; } 43 void setParentStyleSheet(StyleSheetContents* sheet) { ASSERT(sheet); m_parentStyleSheet = sheet; } 44 void clearParentStyleSheet() { m_parentStyleSheet = 0; } 45 46 String href() const { return m_strHref; } 47 StyleSheetContents* styleSheet() const { return m_styleSheet.get(); } 48 49 bool isLoading() const; 50 MediaQuerySet* mediaQueries() { return m_mediaQueries.get(); } 51 52 void requestStyleSheet(); 53 54private: 55 // NOTE: We put the CachedStyleSheetClient in a member instead of inheriting from it 56 // to avoid adding a vptr to StyleRuleImport. 57 class ImportedStyleSheetClient : public CachedStyleSheetClient { 58 public: 59 ImportedStyleSheetClient(StyleRuleImport* ownerRule) : m_ownerRule(ownerRule) { } 60 virtual ~ImportedStyleSheetClient() { } 61 virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* 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 CachedCSSStyleSheet*); 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 CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet; 81 bool m_loading; 82}; 83 84} // namespace WebCore 85 86#endif 87