Oilpan: fix build after r202625.
[chromium-blink-merge.git] / third_party / WebKit / Source / core / css / CSSImportRule.cpp
blobe37aae16832d4ecff320c734933058b619ce5abc
1 /*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2002, 2005, 2006, 2008, 2009, 2010, 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 #include "config.h"
23 #include "core/css/CSSImportRule.h"
25 #include "core/css/CSSStyleSheet.h"
26 #include "core/css/MediaList.h"
27 #include "core/css/StyleRuleImport.h"
28 #include "core/css/StyleSheetContents.h"
29 #include "wtf/text/StringBuilder.h"
31 namespace blink {
33 CSSImportRule::CSSImportRule(StyleRuleImport* importRule, CSSStyleSheet* parent)
34 : CSSRule(parent)
35 , m_importRule(importRule)
39 CSSImportRule::~CSSImportRule()
41 #if !ENABLE(OILPAN)
42 if (m_styleSheetCSSOMWrapper)
43 m_styleSheetCSSOMWrapper->clearOwnerRule();
45 if (m_mediaCSSOMWrapper)
46 m_mediaCSSOMWrapper->clearParentRule();
47 #endif // ENABLE(OILPAN)
50 String CSSImportRule::href() const
52 return m_importRule->href();
55 MediaList* CSSImportRule::media() const
57 if (!m_mediaCSSOMWrapper)
58 m_mediaCSSOMWrapper = MediaList::create(m_importRule->mediaQueries(), const_cast<CSSImportRule*>(this));
59 return m_mediaCSSOMWrapper.get();
62 String CSSImportRule::cssText() const
64 StringBuilder result;
65 result.appendLiteral("@import url(\"");
66 result.append(m_importRule->href());
67 result.appendLiteral("\")");
69 if (m_importRule->mediaQueries()) {
70 String mediaText = m_importRule->mediaQueries()->mediaText();
71 if (!mediaText.isEmpty()) {
72 result.append(' ');
73 result.append(mediaText);
76 result.append(';');
78 return result.toString();
81 CSSStyleSheet* CSSImportRule::styleSheet() const
83 if (!m_importRule->styleSheet())
84 return nullptr;
86 if (!m_styleSheetCSSOMWrapper)
87 m_styleSheetCSSOMWrapper = CSSStyleSheet::create(m_importRule->styleSheet(), const_cast<CSSImportRule*>(this));
88 return m_styleSheetCSSOMWrapper.get();
91 void CSSImportRule::reattach(StyleRuleBase*)
93 // FIXME: Implement when enabling caching for stylesheets with import rules.
94 ASSERT_NOT_REACHED();
97 DEFINE_TRACE(CSSImportRule)
99 visitor->trace(m_importRule);
100 visitor->trace(m_mediaCSSOMWrapper);
101 visitor->trace(m_styleSheetCSSOMWrapper);
102 CSSRule::trace(visitor);
105 } // namespace blink