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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 void CharacterData::appendData(const String& data) | 111 void CharacterData::appendData(const String& data) |
112 { | 112 { |
113 String newStr = m_data + data; | 113 String newStr = m_data + data; |
114 | 114 |
115 setDataAndUpdate(newStr, m_data.length(), 0, data.length()); | 115 setDataAndUpdate(newStr, m_data.length(), 0, data.length()); |
116 | 116 |
117 // FIXME: Should we call textInserted here? | 117 // FIXME: Should we call textInserted here? |
118 } | 118 } |
119 | 119 |
120 void CharacterData::insertData(unsigned offset, const String& data, ExceptionSta
te& es, AttachBehavior attachBehavior) | 120 void CharacterData::insertData(unsigned offset, const String& data, ExceptionSta
te& es, RecalcStyleBehavior recalcStyleBehavior) |
121 { | 121 { |
122 if (offset > length()) { | 122 if (offset > length()) { |
123 es.throwDOMException(IndexSizeError); | 123 es.throwDOMException(IndexSizeError); |
124 return; | 124 return; |
125 } | 125 } |
126 | 126 |
127 String newStr = m_data; | 127 String newStr = m_data; |
128 newStr.insert(data, offset); | 128 newStr.insert(data, offset); |
129 | 129 |
130 setDataAndUpdate(newStr, offset, 0, data.length(), attachBehavior); | 130 setDataAndUpdate(newStr, offset, 0, data.length(), recalcStyleBehavior); |
131 | 131 |
132 document().textInserted(this, offset, data.length()); | 132 document().textInserted(this, offset, data.length()); |
133 } | 133 } |
134 | 134 |
135 void CharacterData::deleteData(unsigned offset, unsigned count, ExceptionState&
es, AttachBehavior attachBehavior) | 135 void CharacterData::deleteData(unsigned offset, unsigned count, ExceptionState&
es, RecalcStyleBehavior recalcStyleBehavior) |
136 { | 136 { |
137 if (offset > length()) { | 137 if (offset > length()) { |
138 es.throwDOMException(IndexSizeError); | 138 es.throwDOMException(IndexSizeError); |
139 return; | 139 return; |
140 } | 140 } |
141 | 141 |
142 unsigned realCount; | 142 unsigned realCount; |
143 if (offset + count > length()) | 143 if (offset + count > length()) |
144 realCount = length() - offset; | 144 realCount = length() - offset; |
145 else | 145 else |
146 realCount = count; | 146 realCount = count; |
147 | 147 |
148 String newStr = m_data; | 148 String newStr = m_data; |
149 newStr.remove(offset, realCount); | 149 newStr.remove(offset, realCount); |
150 | 150 |
151 setDataAndUpdate(newStr, offset, count, 0, attachBehavior); | 151 setDataAndUpdate(newStr, offset, count, 0, recalcStyleBehavior); |
152 | 152 |
153 document().textRemoved(this, offset, realCount); | 153 document().textRemoved(this, offset, realCount); |
154 } | 154 } |
155 | 155 |
156 void CharacterData::replaceData(unsigned offset, unsigned count, const String& d
ata, ExceptionState& es) | 156 void CharacterData::replaceData(unsigned offset, unsigned count, const String& d
ata, ExceptionState& es) |
157 { | 157 { |
158 if (offset > length()) { | 158 if (offset > length()) { |
159 es.throwDOMException(IndexSizeError); | 159 es.throwDOMException(IndexSizeError); |
160 return; | 160 return; |
161 } | 161 } |
(...skipping 23 matching lines...) Expand all Loading... |
185 bool CharacterData::containsOnlyWhitespace() const | 185 bool CharacterData::containsOnlyWhitespace() const |
186 { | 186 { |
187 return m_data.containsOnlyWhitespace(); | 187 return m_data.containsOnlyWhitespace(); |
188 } | 188 } |
189 | 189 |
190 void CharacterData::setNodeValue(const String& nodeValue) | 190 void CharacterData::setNodeValue(const String& nodeValue) |
191 { | 191 { |
192 setData(nodeValue); | 192 setData(nodeValue); |
193 } | 193 } |
194 | 194 |
195 void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfRep
lacedData, unsigned oldLength, unsigned newLength, AttachBehavior attachBehavior
) | 195 void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfRep
lacedData, unsigned oldLength, unsigned newLength, RecalcStyleBehavior recalcSty
leBehavior) |
196 { | 196 { |
197 String oldData = m_data; | 197 String oldData = m_data; |
198 m_data = newData; | 198 m_data = newData; |
199 | 199 |
200 ASSERT(!renderer() || isTextNode()); | 200 ASSERT(!renderer() || isTextNode()); |
201 if (isTextNode()) | 201 if (isTextNode()) |
202 toText(this)->updateTextRenderer(offsetOfReplacedData, oldLength, attach
Behavior); | 202 toText(this)->updateTextRenderer(offsetOfReplacedData, oldLength, recalc
StyleBehavior); |
203 | 203 |
204 if (nodeType() == PROCESSING_INSTRUCTION_NODE) | 204 if (nodeType() == PROCESSING_INSTRUCTION_NODE) |
205 toProcessingInstruction(this)->checkStyleSheet(); | 205 toProcessingInstruction(this)->checkStyleSheet(); |
206 | 206 |
207 if (document().frame()) | 207 if (document().frame()) |
208 document().frame()->selection().textWasReplaced(this, offsetOfReplacedDa
ta, oldLength, newLength); | 208 document().frame()->selection().textWasReplaced(this, offsetOfReplacedDa
ta, oldLength, newLength); |
209 | 209 |
210 document().incDOMTreeVersion(); | 210 document().incDOMTreeVersion(); |
211 didModifyData(oldData); | 211 didModifyData(oldData); |
212 } | 212 } |
(...skipping 18 matching lines...) Expand all Loading... |
231 { | 231 { |
232 return static_cast<int>(length()); | 232 return static_cast<int>(length()); |
233 } | 233 } |
234 | 234 |
235 bool CharacterData::offsetInCharacters() const | 235 bool CharacterData::offsetInCharacters() const |
236 { | 236 { |
237 return true; | 237 return true; |
238 } | 238 } |
239 | 239 |
240 } // namespace WebCore | 240 } // namespace WebCore |
OLD | NEW |