~ubuntu-branches/ubuntu/maverick/webkit/maverick

« back to all changes in this revision

Viewing changes to WebCore/html/HTMLStyleElement.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mike Hommey
  • Date: 2007-08-19 15:54:12 UTC
  • Revision ID: james.westby@ubuntu.com-20070819155412-uxxg1h9plpghmtbi
Tags: upstream-0~svn25144
ImportĀ upstreamĀ versionĀ 0~svn25144

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * This file is part of the DOM implementation for KDE.
 
3
 *
 
4
 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
 
5
 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
 
6
 *           (C) 2001 Dirk Mueller (mueller@kde.org)
 
7
 * Copyright (C) 2003 Apple Computer, Inc.
 
8
 *           (C) 2007 Rob Buis (buis@kde.org)
 
9
 *
 
10
 * This library is free software; you can redistribute it and/or
 
11
 * modify it under the terms of the GNU Library General Public
 
12
 * License as published by the Free Software Foundation; either
 
13
 * version 2 of the License, or (at your option) any later version.
 
14
 *
 
15
 * This library is distributed in the hope that it will be useful,
 
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
18
 * Library General Public License for more details.
 
19
 *
 
20
 * You should have received a copy of the GNU Library General Public License
 
21
 * along with this library; see the file COPYING.LIB.  If not, write to
 
22
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
23
 * Boston, MA 02111-1307, USA.
 
24
 */
 
25
#include "config.h"
 
26
#include "HTMLStyleElement.h"
 
27
 
 
28
#include "Document.h"
 
29
#include "HTMLNames.h"
 
30
 
 
31
namespace WebCore {
 
32
 
 
33
using namespace HTMLNames;
 
34
 
 
35
HTMLStyleElement::HTMLStyleElement(Document* doc)
 
36
    : HTMLElement(styleTag, doc)
 
37
    , m_loading(false)
 
38
    , m_createdByParser(false)
 
39
{
 
40
}
 
41
 
 
42
// other stuff...
 
43
void HTMLStyleElement::parseMappedAttribute(MappedAttribute *attr)
 
44
{
 
45
    if (attr->name() == mediaAttr)
 
46
        m_media = attr->value().domString().lower();
 
47
    else if (attr->name() == titleAttr && m_sheet)
 
48
        m_sheet->setTitle(attr->value());
 
49
     else
 
50
        HTMLElement::parseMappedAttribute(attr);
 
51
}
 
52
 
 
53
void HTMLStyleElement::finishedParsing()
 
54
{
 
55
    StyleElement::process(this);
 
56
    HTMLElement::finishedParsing();
 
57
}
 
58
 
 
59
void HTMLStyleElement::insertedIntoDocument()
 
60
{
 
61
    HTMLElement::insertedIntoDocument();
 
62
 
 
63
    if (!m_createdByParser)
 
64
        StyleElement::insertedIntoDocument(document(), this);
 
65
}
 
66
 
 
67
void HTMLStyleElement::removedFromDocument()
 
68
{
 
69
    HTMLElement::removedFromDocument();
 
70
    StyleElement::removedFromDocument(document());
 
71
}
 
72
 
 
73
void HTMLStyleElement::childrenChanged()
 
74
{
 
75
    StyleElement::process(this);
 
76
}
 
77
 
 
78
StyleSheet* HTMLStyleElement::sheet()
 
79
{
 
80
    return StyleElement::sheet(this);
 
81
}
 
82
 
 
83
bool HTMLStyleElement::isLoading() const
 
84
{
 
85
    if (m_loading)
 
86
        return true;
 
87
    if (!m_sheet)
 
88
        return false;
 
89
    return static_cast<CSSStyleSheet *>(m_sheet.get())->isLoading();
 
90
}
 
91
 
 
92
bool HTMLStyleElement::sheetLoaded()
 
93
{
 
94
    if (!isLoading()) {
 
95
        document()->removePendingSheet();
 
96
        return true;
 
97
    }
 
98
    return false;
 
99
}
 
100
 
 
101
bool HTMLStyleElement::disabled() const
 
102
{
 
103
    return !getAttribute(disabledAttr).isNull();
 
104
}
 
105
 
 
106
void HTMLStyleElement::setDisabled(bool disabled)
 
107
{
 
108
    setAttribute(disabledAttr, disabled ? "" : 0);
 
109
}
 
110
 
 
111
const AtomicString& HTMLStyleElement::media() const
 
112
{
 
113
    return getAttribute(mediaAttr);
 
114
}
 
115
 
 
116
void HTMLStyleElement::setMedia(const AtomicString &value)
 
117
{
 
118
    setAttribute(mediaAttr, value);
 
119
}
 
120
 
 
121
const AtomicString& HTMLStyleElement::type() const
 
122
{
 
123
    return getAttribute(typeAttr);
 
124
}
 
125
 
 
126
void HTMLStyleElement::setType(const AtomicString &value)
 
127
{
 
128
    setAttribute(typeAttr, value);
 
129
}
 
130
 
 
131
}