2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2006 Apple Computer, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #include "StyleSheet.h"
23 #include "MediaList.h"
27 StyleSheet::StyleSheet(StyleSheet* parentSheet, const String& originalURL, const KURL& finalURL)
28 : StyleList(parentSheet)
30 , m_originalURL(originalURL)
31 , m_finalURL(finalURL)
36 StyleSheet::StyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL)
38 , m_parentNode(parentNode)
39 , m_originalURL(originalURL)
40 , m_finalURL(finalURL)
45 StyleSheet::StyleSheet(StyleBase* owner, const String& originalURL, const KURL& finalURL)
48 , m_originalURL(originalURL)
49 , m_finalURL(finalURL)
54 StyleSheet::~StyleSheet()
57 m_media->setParent(0);
60 StyleSheet* StyleSheet::parentStyleSheet() const
62 return (parent() && parent()->isStyleSheet()) ? static_cast<StyleSheet*>(parent()) : 0;
65 void StyleSheet::setMedia(PassRefPtr<MediaList> media)
68 m_media->setParent(0);
71 m_media->setParent(this);
74 KURL StyleSheet::completeURL(const String& url) const
76 // Always return a null URL when passed a null string.
77 // FIXME: Should we change the KURL constructor to have this behavior?
78 // See also Document::completeURL(const String&)
81 return KURL(baseURL(), url);