Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: Source/core/html/HTMLTitleElement.cpp

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLTextFormControlElement.cpp ('k') | Source/core/html/HTMLTrackElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 PassRefPtr<HTMLTitleElement> HTMLTitleElement::create(const QualifiedName& tagNa me, Document* document) 46 PassRefPtr<HTMLTitleElement> HTMLTitleElement::create(const QualifiedName& tagNa me, Document* document)
47 { 47 {
48 return adoptRef(new HTMLTitleElement(tagName, document)); 48 return adoptRef(new HTMLTitleElement(tagName, document));
49 } 49 }
50 50
51 Node::InsertionNotificationRequest HTMLTitleElement::insertedInto(ContainerNode* insertionPoint) 51 Node::InsertionNotificationRequest HTMLTitleElement::insertedInto(ContainerNode* insertionPoint)
52 { 52 {
53 HTMLElement::insertedInto(insertionPoint); 53 HTMLElement::insertedInto(insertionPoint);
54 if (inDocument() && !isInShadowTree()) 54 if (inDocument() && !isInShadowTree())
55 document()->setTitleElement(text(), this); 55 document().setTitleElement(text(), this);
56 return InsertionDone; 56 return InsertionDone;
57 } 57 }
58 58
59 void HTMLTitleElement::removedFrom(ContainerNode* insertionPoint) 59 void HTMLTitleElement::removedFrom(ContainerNode* insertionPoint)
60 { 60 {
61 HTMLElement::removedFrom(insertionPoint); 61 HTMLElement::removedFrom(insertionPoint);
62 if (insertionPoint->inDocument() && !insertionPoint->isInShadowTree()) 62 if (insertionPoint->inDocument() && !insertionPoint->isInShadowTree())
63 document()->removeTitle(this); 63 document().removeTitle(this);
64 } 64 }
65 65
66 void HTMLTitleElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) 66 void HTMLTitleElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
67 { 67 {
68 HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, chi ldCountDelta); 68 HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, chi ldCountDelta);
69 if (inDocument() && !isInShadowTree()) 69 if (inDocument() && !isInShadowTree())
70 document()->setTitleElement(text(), this); 70 document().setTitleElement(text(), this);
71 } 71 }
72 72
73 String HTMLTitleElement::text() const 73 String HTMLTitleElement::text() const
74 { 74 {
75 StringBuilder result; 75 StringBuilder result;
76 76
77 for (Node *n = firstChild(); n; n = n->nextSibling()) { 77 for (Node *n = firstChild(); n; n = n->nextSibling()) {
78 if (n->isTextNode()) 78 if (n->isTextNode())
79 result.append(toText(n)->data()); 79 result.append(toText(n)->data());
80 } 80 }
(...skipping 11 matching lines...) Expand all
92 toText(firstChild())->setData(value); 92 toText(firstChild())->setData(value);
93 else { 93 else {
94 // We make a copy here because entity of "value" argument can be Documen t::m_title, 94 // We make a copy here because entity of "value" argument can be Documen t::m_title,
95 // which goes empty during removeChildren() invocation below, 95 // which goes empty during removeChildren() invocation below,
96 // which causes HTMLTitleElement::childrenChanged(), which ends up Docum ent::setTitle(). 96 // which causes HTMLTitleElement::childrenChanged(), which ends up Docum ent::setTitle().
97 String valueCopy(value); 97 String valueCopy(value);
98 98
99 if (numChildren > 0) 99 if (numChildren > 0)
100 removeChildren(); 100 removeChildren();
101 101
102 appendChild(document()->createTextNode(valueCopy.impl()), IGNORE_EXCEPTI ON); 102 appendChild(document().createTextNode(valueCopy.impl()), IGNORE_EXCEPTIO N);
103 } 103 }
104 } 104 }
105 105
106 } 106 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLTextFormControlElement.cpp ('k') | Source/core/html/HTMLTrackElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698