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, 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 28 matching lines...) Expand all Loading... |
39 { | 39 { |
40 m_data = AtomicString(m_data); | 40 m_data = AtomicString(m_data); |
41 } | 41 } |
42 | 42 |
43 void CharacterData::setData(const String& data) | 43 void CharacterData::setData(const String& data) |
44 { | 44 { |
45 const String& nonNullData = !data.isNull() ? data : emptyString(); | 45 const String& nonNullData = !data.isNull() ? data : emptyString(); |
46 if (m_data == nonNullData) | 46 if (m_data == nonNullData) |
47 return; | 47 return; |
48 | 48 |
| 49 document().dataWillChange(*this); |
| 50 |
49 unsigned oldLength = length(); | 51 unsigned oldLength = length(); |
50 | 52 |
51 setDataAndUpdate(nonNullData, 0, oldLength, nonNullData.length(), UpdateFrom
NonParser); | 53 setDataAndUpdate(nonNullData, 0, oldLength, nonNullData.length(), UpdateFrom
NonParser); |
52 document().didRemoveText(this, 0, oldLength); | 54 document().didRemoveText(this, 0, oldLength); |
53 } | 55 } |
54 | 56 |
55 String CharacterData::substringData(unsigned offset, unsigned count, ExceptionSt
ate& exceptionState) | 57 String CharacterData::substringData(unsigned offset, unsigned count, ExceptionSt
ate& exceptionState) |
56 { | 58 { |
57 if (offset > length()) { | 59 if (offset > length()) { |
58 exceptionState.throwDOMException(IndexSizeError, "The offset " + String:
:number(offset) + " is greater than the node's length (" + String::number(length
()) + ")."); | 60 exceptionState.throwDOMException(IndexSizeError, "The offset " + String:
:number(offset) + " is greater than the node's length (" + String::number(length
()) + ")."); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 return m_data.containsOnlyWhitespace(); | 154 return m_data.containsOnlyWhitespace(); |
153 } | 155 } |
154 | 156 |
155 void CharacterData::setNodeValue(const String& nodeValue) | 157 void CharacterData::setNodeValue(const String& nodeValue) |
156 { | 158 { |
157 setData(nodeValue); | 159 setData(nodeValue); |
158 } | 160 } |
159 | 161 |
160 void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfRep
lacedData, unsigned oldLength, unsigned newLength, UpdateSource source, RecalcSt
yleBehavior recalcStyleBehavior) | 162 void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfRep
lacedData, unsigned oldLength, unsigned newLength, UpdateSource source, RecalcSt
yleBehavior recalcStyleBehavior) |
161 { | 163 { |
| 164 if (source != UpdateFromParser) |
| 165 document().dataWillChange(*this); |
| 166 |
162 String oldData = m_data; | 167 String oldData = m_data; |
163 m_data = newData; | 168 m_data = newData; |
164 | 169 |
165 DCHECK(!layoutObject() || isTextNode()); | 170 DCHECK(!layoutObject() || isTextNode()); |
166 if (isTextNode()) | 171 if (isTextNode()) |
167 toText(this)->updateTextLayoutObject(offsetOfReplacedData, oldLength, re
calcStyleBehavior); | 172 toText(this)->updateTextLayoutObject(offsetOfReplacedData, oldLength, re
calcStyleBehavior); |
168 | 173 |
169 if (source != UpdateFromParser) { | 174 if (source != UpdateFromParser) { |
170 if (getNodeType() == PROCESSING_INSTRUCTION_NODE) | 175 if (getNodeType() == PROCESSING_INSTRUCTION_NODE) |
171 toProcessingInstruction(this)->didAttributeChanged(); | 176 toProcessingInstruction(this)->didAttributeChanged(); |
(...skipping 26 matching lines...) Expand all Loading... |
198 } | 203 } |
199 InspectorInstrumentation::characterDataModified(this); | 204 InspectorInstrumentation::characterDataModified(this); |
200 } | 205 } |
201 | 206 |
202 int CharacterData::maxCharacterOffset() const | 207 int CharacterData::maxCharacterOffset() const |
203 { | 208 { |
204 return static_cast<int>(length()); | 209 return static_cast<int>(length()); |
205 } | 210 } |
206 | 211 |
207 } // namespace blink | 212 } // namespace blink |
OLD | NEW |