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

Side by Side Diff: sky/engine/core/dom/CharacterData.cpp

Issue 698123002: Remove more API from Node and ContainerNode. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « sky/engine/core/dom/CharacterData.h ('k') | sky/engine/core/dom/ContainerNode.h » ('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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r ights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r ights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 void CharacterData::parserAppendData(const String& string) 66 void CharacterData::parserAppendData(const String& string)
67 { 67 {
68 unsigned oldLength = m_data.length(); 68 unsigned oldLength = m_data.length();
69 m_data = m_data + string; 69 m_data = m_data + string;
70 70
71 ASSERT(!renderer() || isTextNode()); 71 ASSERT(!renderer() || isTextNode());
72 if (isTextNode()) 72 if (isTextNode())
73 toText(this)->updateTextRenderer(oldLength, 0); 73 toText(this)->updateTextRenderer(oldLength, 0);
74 74
75 if (parentNode()) { 75 if (parentNode()) {
76 ContainerNode::ChildrenChange change = {ContainerNode::TextChanged, prev iousSibling(), nextSibling(), ContainerNode::ChildrenChangeSourceParser}; 76 ContainerNode::ChildrenChange change = {ContainerNode::TextChanged, Cont ainerNode::ChildrenChangeSourceParser};
77 parentNode()->childrenChanged(change); 77 parentNode()->childrenChanged(change);
78 } 78 }
79 } 79 }
80 80
81 void CharacterData::appendData(const String& data) 81 void CharacterData::appendData(const String& data)
82 { 82 {
83 String newStr = m_data + data; 83 String newStr = m_data + data;
84 84
85 setDataAndUpdate(newStr, m_data.length(), 0, data.length()); 85 setDataAndUpdate(newStr, m_data.length(), 0, data.length());
86 86
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 newStr.remove(offset, realCount); 144 newStr.remove(offset, realCount);
145 newStr.insert(data, offset); 145 newStr.insert(data, offset);
146 146
147 setDataAndUpdate(newStr, offset, realCount, data.length()); 147 setDataAndUpdate(newStr, offset, realCount, data.length());
148 148
149 // update the markers for spell checking and grammar checking 149 // update the markers for spell checking and grammar checking
150 document().didRemoveText(this, offset, realCount); 150 document().didRemoveText(this, offset, realCount);
151 document().didInsertText(this, offset, data.length()); 151 document().didInsertText(this, offset, data.length());
152 } 152 }
153 153
154 String CharacterData::nodeValue() const
155 {
156 return m_data;
157 }
158
159 bool CharacterData::containsOnlyWhitespace() const 154 bool CharacterData::containsOnlyWhitespace() const
160 { 155 {
161 return m_data.containsOnlyWhitespace(); 156 return m_data.containsOnlyWhitespace();
162 } 157 }
163 158
164 void CharacterData::setNodeValue(const String& nodeValue)
165 {
166 setData(nodeValue);
167 }
168
169 void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfRep lacedData, unsigned oldLength, unsigned newLength, RecalcStyleBehavior recalcSty leBehavior) 159 void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfRep lacedData, unsigned oldLength, unsigned newLength, RecalcStyleBehavior recalcSty leBehavior)
170 { 160 {
171 String oldData = m_data; 161 String oldData = m_data;
172 m_data = newData; 162 m_data = newData;
173 163
174 ASSERT(!renderer() || isTextNode()); 164 ASSERT(!renderer() || isTextNode());
175 if (isTextNode()) 165 if (isTextNode())
176 toText(this)->updateTextRenderer(offsetOfReplacedData, oldLength, recalc StyleBehavior); 166 toText(this)->updateTextRenderer(offsetOfReplacedData, oldLength, recalc StyleBehavior);
177 167
178 if (document().frame()) 168 if (document().frame())
179 document().frame()->selection().didUpdateCharacterData(this, offsetOfRep lacedData, oldLength, newLength); 169 document().frame()->selection().didUpdateCharacterData(this, offsetOfRep lacedData, oldLength, newLength);
180 170
181 didModifyData(oldData); 171 didModifyData(oldData);
182 } 172 }
183 173
184 void CharacterData::didModifyData(const String& oldData) 174 void CharacterData::didModifyData(const String& oldData)
185 { 175 {
186 if (OwnPtr<MutationObserverInterestGroup> mutationRecipients = MutationObser verInterestGroup::createForCharacterDataMutation(*this)) 176 if (OwnPtr<MutationObserverInterestGroup> mutationRecipients = MutationObser verInterestGroup::createForCharacterDataMutation(*this))
187 mutationRecipients->enqueueMutationRecord(MutationRecord::createCharacte rData(this, oldData)); 177 mutationRecipients->enqueueMutationRecord(MutationRecord::createCharacte rData(this, oldData));
188 178
189 if (parentNode()) { 179 if (parentNode()) {
190 ContainerNode::ChildrenChange change = {ContainerNode::TextChanged, prev iousSibling(), nextSibling(), ContainerNode::ChildrenChangeSourceAPI}; 180 ContainerNode::ChildrenChange change = {ContainerNode::TextChanged, Cont ainerNode::ChildrenChangeSourceAPI};
191 parentNode()->childrenChanged(change); 181 parentNode()->childrenChanged(change);
192 } 182 }
193 } 183 }
194 184
195 int CharacterData::maxCharacterOffset() const 185 int CharacterData::maxCharacterOffset() const
196 { 186 {
197 return static_cast<int>(length()); 187 return static_cast<int>(length());
198 } 188 }
199 189
200 bool CharacterData::offsetInCharacters() const 190 bool CharacterData::offsetInCharacters() const
201 { 191 {
202 return true; 192 return true;
203 } 193 }
204 194
205 } // namespace blink 195 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/dom/CharacterData.h ('k') | sky/engine/core/dom/ContainerNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698