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 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.
23 #include "CSSStyleRule.h"
25 #include "CSSMutableStyleDeclaration.h"
26 #include "CSSParser.h"
27 #include "CSSSelector.h"
28 #include "CSSStyleSheet.h"
30 #include "StyleSheet.h"
34 CSSStyleRule::CSSStyleRule(CSSStyleSheet* parent, int sourceLine)
36 , m_sourceLine(sourceLine)
40 CSSStyleRule::~CSSStyleRule()
43 m_style->setParent(0);
46 String CSSStyleRule::selectorText() const
49 for (CSSSelector* s = selectorList().first(); s; s = CSSSelectorList::next(s)) {
50 if (s != selectorList().first())
52 str += s->selectorText();
57 void CSSStyleRule::setSelectorText(const String& selectorText)
60 StyleSheet* ownerStyleSheet = m_style->stylesheet();
61 if (ownerStyleSheet) {
62 if (ownerStyleSheet->isCSSStyleSheet())
63 doc = static_cast<CSSStyleSheet*>(ownerStyleSheet)->document();
65 doc = ownerStyleSheet->ownerNode() ? ownerStyleSheet->ownerNode()->document() : 0;
68 doc = m_style->node() ? m_style->node()->document() : 0;
74 CSSSelectorList selectorList;
75 p.parseSelector(selectorText, doc, selectorList);
76 if (!selectorList.first())
79 String oldSelectorText = this->selectorText();
80 m_selectorList.adopt(selectorList);
81 if (this->selectorText() == oldSelectorText)
84 doc->styleSelectorChanged(DeferRecalcStyle);
87 String CSSStyleRule::cssText() const
89 String result = selectorText();
92 result += m_style->cssText();
98 bool CSSStyleRule::parseString(const String& /*string*/, bool /*strict*/)
104 void CSSStyleRule::setDeclaration(PassRefPtr<CSSMutableStyleDeclaration> style)
109 void CSSStyleRule::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
112 m_style->addSubresourceStyleURLs(urls);
115 } // namespace WebCore