2
* This file is part of the DOM implementation for KDE.
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.
9
* This library is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Library General Public
11
* License as published by the Free Software Foundation; either
12
* version 2 of the License, or (at your option) any later version.
14
* This library is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* Library General Public License for more details.
19
* You should have received a copy of the GNU Library General Public License
20
* along with this library; see the file COPYING.LIB. If not, write to
21
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22
* Boston, MA 02111-1307, USA.
25
#include "HTMLTitleElement.h"
28
#include "HTMLNames.h"
33
using namespace HTMLNames;
35
HTMLTitleElement::HTMLTitleElement(Document* doc)
36
: HTMLElement(titleTag, doc)
41
HTMLTitleElement::~HTMLTitleElement()
45
void HTMLTitleElement::insertedIntoDocument()
47
HTMLElement::insertedIntoDocument();
48
document()->setTitle(m_title, this);
51
void HTMLTitleElement::removedFromDocument()
53
HTMLElement::removedFromDocument();
54
document()->removeTitle(this);
57
void HTMLTitleElement::childrenChanged()
59
HTMLElement::childrenChanged();
61
for (Node* c = firstChild(); c != 0; c = c->nextSibling())
62
if (c->nodeType() == TEXT_NODE || c->nodeType() == CDATA_SECTION_NODE)
63
m_title += c->nodeValue();
65
document()->setTitle(m_title, this);
68
String HTMLTitleElement::text() const
72
for (Node *n = firstChild(); n; n = n->nextSibling()) {
74
val += static_cast<Text*>(n)->data();
80
void HTMLTitleElement::setText(const String &value)
83
int numChildren = childNodeCount();
85
if (numChildren == 1 && firstChild()->isTextNode())
86
static_cast<Text*>(firstChild())->setData(value, ec);
91
appendChild(document()->createTextNode(value.impl()), ec);