Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / html / HTMLTitleElement.cpp
blob30e6735b7b4e2142721a3487127121d0848b73fc
1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2010 Apple Inc. All rights reserved.
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.
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.
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.
23 #include "config.h"
24 #include "core/html/HTMLTitleElement.h"
26 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
27 #include "core/HTMLNames.h"
28 #include "core/dom/ChildListMutationScope.h"
29 #include "core/dom/Document.h"
30 #include "core/dom/Text.h"
31 #include "core/style/ComputedStyle.h"
32 #include "core/style/StyleInheritedData.h"
33 #include "wtf/text/StringBuilder.h"
35 namespace blink {
37 using namespace HTMLNames;
39 inline HTMLTitleElement::HTMLTitleElement(Document& document)
40 : HTMLElement(titleTag, document)
41 , m_ignoreTitleUpdatesWhenChildrenChange(false)
45 DEFINE_NODE_FACTORY(HTMLTitleElement)
47 Node::InsertionNotificationRequest HTMLTitleElement::insertedInto(ContainerNode* insertionPoint)
49 HTMLElement::insertedInto(insertionPoint);
50 if (inDocument() && !isInShadowTree())
51 document().setTitleElement(this);
52 return InsertionDone;
55 void HTMLTitleElement::removedFrom(ContainerNode* insertionPoint)
57 HTMLElement::removedFrom(insertionPoint);
58 if (insertionPoint->inDocument() && !insertionPoint->isInShadowTree())
59 document().removeTitle(this);
62 void HTMLTitleElement::childrenChanged(const ChildrenChange& change)
64 HTMLElement::childrenChanged(change);
65 if (inDocument() && !isInShadowTree() && !m_ignoreTitleUpdatesWhenChildrenChange)
66 document().setTitleElement(this);
69 String HTMLTitleElement::text() const
71 StringBuilder result;
73 for (Node *n = firstChild(); n; n = n->nextSibling()) {
74 if (n->isTextNode())
75 result.append(toText(n)->data());
78 return result.toString();
81 void HTMLTitleElement::setText(const String &value)
83 RefPtrWillBeRawPtr<Node> protectFromMutationEvents(this);
84 ChildListMutationScope mutation(*this);
86 // Avoid calling Document::setTitleElement() during intermediate steps.
87 m_ignoreTitleUpdatesWhenChildrenChange = !value.isEmpty();
88 removeChildren(OmitSubtreeModifiedEvent);
89 m_ignoreTitleUpdatesWhenChildrenChange = false;
91 if (!value.isEmpty())
92 appendChild(document().createTextNode(value.impl()), IGNORE_EXCEPTION);