| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 return; | 51 return; |
| 52 | 52 |
| 53 RefPtr<CharacterData> protect = this; | 53 RefPtr<CharacterData> protect = this; |
| 54 | 54 |
| 55 unsigned oldLength = length(); | 55 unsigned oldLength = length(); |
| 56 | 56 |
| 57 setDataAndUpdate(nonNullData, 0, oldLength, nonNullData.length()); | 57 setDataAndUpdate(nonNullData, 0, oldLength, nonNullData.length()); |
| 58 document().didRemoveText(this, 0, oldLength); | 58 document().didRemoveText(this, 0, oldLength); |
| 59 } | 59 } |
| 60 | 60 |
| 61 String CharacterData::substringData(unsigned offset, unsigned count, ExceptionSt
ate& es) | 61 String CharacterData::substringData(unsigned offset, unsigned count, ExceptionSt
ate& exceptionState) |
| 62 { | 62 { |
| 63 if (offset > length()) { | 63 if (offset > length()) { |
| 64 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute(
"substringData", "CharacterData", "The offset " + String::number(offset) + " is
greater than the node's length (" + String::number(length()) + ").")); | 64 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToExecute("substringData", "CharacterData", "The offset " + String::number(off
set) + " is greater than the node's length (" + String::number(length()) + ").")
); |
| 65 return String(); | 65 return String(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 return m_data.substring(offset, count); | 68 return m_data.substring(offset, count); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void CharacterData::parserAppendData(const String& string) | 71 void CharacterData::parserAppendData(const String& string) |
| 72 { | 72 { |
| 73 unsigned oldLength = m_data.length(); | 73 unsigned oldLength = m_data.length(); |
| 74 m_data.append(string); | 74 m_data.append(string); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 85 | 85 |
| 86 void CharacterData::appendData(const String& data) | 86 void CharacterData::appendData(const String& data) |
| 87 { | 87 { |
| 88 String newStr = m_data + data; | 88 String newStr = m_data + data; |
| 89 | 89 |
| 90 setDataAndUpdate(newStr, m_data.length(), 0, data.length()); | 90 setDataAndUpdate(newStr, m_data.length(), 0, data.length()); |
| 91 | 91 |
| 92 // FIXME: Should we call textInserted here? | 92 // FIXME: Should we call textInserted here? |
| 93 } | 93 } |
| 94 | 94 |
| 95 void CharacterData::insertData(unsigned offset, const String& data, ExceptionSta
te& es, RecalcStyleBehavior recalcStyleBehavior) | 95 void CharacterData::insertData(unsigned offset, const String& data, ExceptionSta
te& exceptionState, RecalcStyleBehavior recalcStyleBehavior) |
| 96 { | 96 { |
| 97 if (offset > length()) { | 97 if (offset > length()) { |
| 98 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute(
"insertData", "CharacterData", "The offset " + String::number(offset) + " is gre
ater than the node's length (" + String::number(length()) + ").")); | 98 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToExecute("insertData", "CharacterData", "The offset " + String::number(offset
) + " is greater than the node's length (" + String::number(length()) + ").")); |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 | 101 |
| 102 String newStr = m_data; | 102 String newStr = m_data; |
| 103 newStr.insert(data, offset); | 103 newStr.insert(data, offset); |
| 104 | 104 |
| 105 setDataAndUpdate(newStr, offset, 0, data.length(), recalcStyleBehavior); | 105 setDataAndUpdate(newStr, offset, 0, data.length(), recalcStyleBehavior); |
| 106 | 106 |
| 107 document().didInsertText(this, offset, data.length()); | 107 document().didInsertText(this, offset, data.length()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void CharacterData::deleteData(unsigned offset, unsigned count, ExceptionState&
es, RecalcStyleBehavior recalcStyleBehavior) | 110 void CharacterData::deleteData(unsigned offset, unsigned count, ExceptionState&
exceptionState, RecalcStyleBehavior recalcStyleBehavior) |
| 111 { | 111 { |
| 112 if (offset > length()) { | 112 if (offset > length()) { |
| 113 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute(
"deleteData", "CharacterData", "The offset " + String::number(offset) + " is gre
ater than the node's length (" + String::number(length()) + ").")); | 113 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToExecute("deleteData", "CharacterData", "The offset " + String::number(offset
) + " is greater than the node's length (" + String::number(length()) + ").")); |
| 114 return; | 114 return; |
| 115 } | 115 } |
| 116 | 116 |
| 117 unsigned realCount; | 117 unsigned realCount; |
| 118 if (offset + count > length()) | 118 if (offset + count > length()) |
| 119 realCount = length() - offset; | 119 realCount = length() - offset; |
| 120 else | 120 else |
| 121 realCount = count; | 121 realCount = count; |
| 122 | 122 |
| 123 String newStr = m_data; | 123 String newStr = m_data; |
| 124 newStr.remove(offset, realCount); | 124 newStr.remove(offset, realCount); |
| 125 | 125 |
| 126 setDataAndUpdate(newStr, offset, count, 0, recalcStyleBehavior); | 126 setDataAndUpdate(newStr, offset, count, 0, recalcStyleBehavior); |
| 127 | 127 |
| 128 document().didRemoveText(this, offset, realCount); | 128 document().didRemoveText(this, offset, realCount); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void CharacterData::replaceData(unsigned offset, unsigned count, const String& d
ata, ExceptionState& es) | 131 void CharacterData::replaceData(unsigned offset, unsigned count, const String& d
ata, ExceptionState& exceptionState) |
| 132 { | 132 { |
| 133 if (offset > length()) { | 133 if (offset > length()) { |
| 134 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute(
"replaceData", "CharacterData", "The offset " + String::number(offset) + " is gr
eater than the node's length (" + String::number(length()) + ").")); | 134 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToExecute("replaceData", "CharacterData", "The offset " + String::number(offse
t) + " is greater than the node's length (" + String::number(length()) + ").")); |
| 135 return; | 135 return; |
| 136 } | 136 } |
| 137 | 137 |
| 138 unsigned realCount; | 138 unsigned realCount; |
| 139 if (offset + count > length()) | 139 if (offset + count > length()) |
| 140 realCount = length() - offset; | 140 realCount = length() - offset; |
| 141 else | 141 else |
| 142 realCount = count; | 142 realCount = count; |
| 143 | 143 |
| 144 String newStr = m_data; | 144 String newStr = m_data; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 { | 206 { |
| 207 return static_cast<int>(length()); | 207 return static_cast<int>(length()); |
| 208 } | 208 } |
| 209 | 209 |
| 210 bool CharacterData::offsetInCharacters() const | 210 bool CharacterData::offsetInCharacters() const |
| 211 { | 211 { |
| 212 return true; | 212 return true; |
| 213 } | 213 } |
| 214 | 214 |
| 215 } // namespace WebCore | 215 } // namespace WebCore |
| OLD | NEW |