1 /**
2 * This file is part of the DOM implementation for KDE.
3 *
4 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
5 * Copyright (C) 2004, 2006 Apple Computer, Inc.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22 #include "config.h"
23 #include "StyleSheet.h"
24
25 #include "MediaList.h"
26
27 namespace WebCore {
28
StyleSheet(StyleSheet * parentSheet,const String & href)29 StyleSheet::StyleSheet(StyleSheet* parentSheet, const String& href)
30 : StyleList(parentSheet)
31 , m_parentNode(0)
32 , m_strHref(href)
33 , m_disabled(false)
34 {
35 }
36
37
StyleSheet(Node * parentNode,const String & href)38 StyleSheet::StyleSheet(Node* parentNode, const String& href)
39 : StyleList(0)
40 , m_parentNode(parentNode)
41 , m_strHref(href)
42 , m_disabled(false)
43 {
44 }
45
StyleSheet(StyleBase * owner,const String & href)46 StyleSheet::StyleSheet(StyleBase* owner, const String& href)
47 : StyleList(owner)
48 , m_parentNode(0)
49 , m_strHref(href)
50 , m_disabled(false)
51 {
52 }
53
~StyleSheet()54 StyleSheet::~StyleSheet()
55 {
56 if (m_media)
57 m_media->setParent(0);
58 }
59
parentStyleSheet() const60 StyleSheet* StyleSheet::parentStyleSheet() const
61 {
62 return (parent() && parent()->isStyleSheet()) ? static_cast<StyleSheet*>(parent()) : 0;
63 }
64
setMedia(PassRefPtr<MediaList> media)65 void StyleSheet::setMedia(PassRefPtr<MediaList> media)
66 {
67 if (m_media)
68 m_media->setParent(0);
69
70 m_media = media;
71 m_media->setParent(this);
72 }
73
completeURL(const String & url) const74 KURL StyleSheet::completeURL(const String& url) const
75 {
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&)
79 if (url.isNull())
80 return KURL();
81 return KURL(baseURL(), url);
82 }
83
84 }
85