OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2010 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2010 Apple Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 setHasCustomStyleCallbacks(); | 43 setHasCustomStyleCallbacks(); |
44 ScriptWrappable::init(this); | 44 ScriptWrappable::init(this); |
45 } | 45 } |
46 | 46 |
47 DEFINE_NODE_FACTORY(HTMLTitleElement) | 47 DEFINE_NODE_FACTORY(HTMLTitleElement) |
48 | 48 |
49 Node::InsertionNotificationRequest HTMLTitleElement::insertedInto(ContainerNode*
insertionPoint) | 49 Node::InsertionNotificationRequest HTMLTitleElement::insertedInto(ContainerNode*
insertionPoint) |
50 { | 50 { |
51 HTMLElement::insertedInto(insertionPoint); | 51 HTMLElement::insertedInto(insertionPoint); |
52 if (inDocument() && !isInShadowTree()) | 52 if (inDocument() && !isInShadowTree()) |
53 document().setTitleElement(text(), this); | 53 document().setTitleElement(this); |
54 return InsertionDone; | 54 return InsertionDone; |
55 } | 55 } |
56 | 56 |
57 void HTMLTitleElement::removedFrom(ContainerNode* insertionPoint) | 57 void HTMLTitleElement::removedFrom(ContainerNode* insertionPoint) |
58 { | 58 { |
59 HTMLElement::removedFrom(insertionPoint); | 59 HTMLElement::removedFrom(insertionPoint); |
60 if (insertionPoint->inDocument() && !insertionPoint->isInShadowTree()) | 60 if (insertionPoint->inDocument() && !insertionPoint->isInShadowTree()) |
61 document().removeTitle(this); | 61 document().removeTitle(this); |
62 } | 62 } |
63 | 63 |
64 void HTMLTitleElement::childrenChanged(const ChildrenChange& change) | 64 void HTMLTitleElement::childrenChanged(const ChildrenChange& change) |
65 { | 65 { |
66 HTMLElement::childrenChanged(change); | 66 HTMLElement::childrenChanged(change); |
67 if (inDocument() && !isInShadowTree() && !m_ignoreTitleUpdatesWhenChildrenCh
ange) | 67 if (inDocument() && !isInShadowTree() && !m_ignoreTitleUpdatesWhenChildrenCh
ange) |
68 document().setTitleElement(text(), this); | 68 document().setTitleElement(this); |
69 } | 69 } |
70 | 70 |
71 String HTMLTitleElement::text() const | 71 String HTMLTitleElement::text() const |
72 { | 72 { |
73 StringBuilder result; | 73 StringBuilder result; |
74 | 74 |
75 for (Node *n = firstChild(); n; n = n->nextSibling()) { | 75 for (Node *n = firstChild(); n; n = n->nextSibling()) { |
76 if (n->isTextNode()) | 76 if (n->isTextNode()) |
77 result.append(toText(n)->data()); | 77 result.append(toText(n)->data()); |
78 } | 78 } |
79 | 79 |
80 return result.toString(); | 80 return result.toString(); |
81 } | 81 } |
82 | 82 |
83 void HTMLTitleElement::setText(const String &value) | 83 void HTMLTitleElement::setText(const String &value) |
84 { | 84 { |
85 RefPtrWillBeRawPtr<Node> protectFromMutationEvents(this); | 85 RefPtrWillBeRawPtr<Node> protectFromMutationEvents(this); |
86 ChildListMutationScope mutation(*this); | 86 ChildListMutationScope mutation(*this); |
87 | 87 |
88 // Avoid calling Document::setTitleElement() during intermediate steps. | 88 // Avoid calling Document::setTitleElement() during intermediate steps. |
89 m_ignoreTitleUpdatesWhenChildrenChange = !value.isEmpty(); | 89 m_ignoreTitleUpdatesWhenChildrenChange = !value.isEmpty(); |
90 removeChildren(); | 90 removeChildren(); |
91 m_ignoreTitleUpdatesWhenChildrenChange = false; | 91 m_ignoreTitleUpdatesWhenChildrenChange = false; |
92 | 92 |
93 if (!value.isEmpty()) | 93 if (!value.isEmpty()) |
94 appendChild(document().createTextNode(value.impl()), IGNORE_EXCEPTION); | 94 appendChild(document().createTextNode(value.impl()), IGNORE_EXCEPTION); |
95 } | 95 } |
96 | 96 |
97 } | 97 } |
OLD | NEW |