| 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 * |
| 11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| 15 * | 15 * |
| 16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
| 17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
| 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #include "config.h" | 22 #include "config.h" |
| 23 #include "core/dom/CharacterData.h" | 23 #include "core/dom/CharacterData.h" |
| 24 | 24 |
| 25 #include "bindings/v8/ExceptionMessages.h" | |
| 26 #include "bindings/v8/ExceptionState.h" | 25 #include "bindings/v8/ExceptionState.h" |
| 27 #include "core/dom/Document.h" | 26 #include "core/dom/Document.h" |
| 28 #include "core/dom/ExceptionCode.h" | 27 #include "core/dom/ExceptionCode.h" |
| 29 #include "core/dom/MutationObserverInterestGroup.h" | 28 #include "core/dom/MutationObserverInterestGroup.h" |
| 30 #include "core/dom/MutationRecord.h" | 29 #include "core/dom/MutationRecord.h" |
| 31 #include "core/dom/ProcessingInstruction.h" | 30 #include "core/dom/ProcessingInstruction.h" |
| 32 #include "core/dom/Text.h" | 31 #include "core/dom/Text.h" |
| 33 #include "core/editing/FrameSelection.h" | 32 #include "core/editing/FrameSelection.h" |
| 34 #include "core/events/MutationEvent.h" | 33 #include "core/events/MutationEvent.h" |
| 35 #include "core/events/ThreadLocalEventNames.h" | 34 #include "core/events/ThreadLocalEventNames.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 54 | 53 |
| 55 unsigned oldLength = length(); | 54 unsigned oldLength = length(); |
| 56 | 55 |
| 57 setDataAndUpdate(nonNullData, 0, oldLength, nonNullData.length()); | 56 setDataAndUpdate(nonNullData, 0, oldLength, nonNullData.length()); |
| 58 document().didRemoveText(this, 0, oldLength); | 57 document().didRemoveText(this, 0, oldLength); |
| 59 } | 58 } |
| 60 | 59 |
| 61 String CharacterData::substringData(unsigned offset, unsigned count, ExceptionSt
ate& exceptionState) | 60 String CharacterData::substringData(unsigned offset, unsigned count, ExceptionSt
ate& exceptionState) |
| 62 { | 61 { |
| 63 if (offset > length()) { | 62 if (offset > 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()) + ").")
); | 63 exceptionState.throwDOMException(IndexSizeError, "The offset " + String:
:number(offset) + " is greater than the node's length (" + String::number(length
()) + ")."); |
| 65 return String(); | 64 return String(); |
| 66 } | 65 } |
| 67 | 66 |
| 68 return m_data.substring(offset, count); | 67 return m_data.substring(offset, count); |
| 69 } | 68 } |
| 70 | 69 |
| 71 void CharacterData::parserAppendData(const String& string) | 70 void CharacterData::parserAppendData(const String& string) |
| 72 { | 71 { |
| 73 unsigned oldLength = m_data.length(); | 72 unsigned oldLength = m_data.length(); |
| 74 m_data.append(string); | 73 m_data.append(string); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 88 String newStr = m_data + data; | 87 String newStr = m_data + data; |
| 89 | 88 |
| 90 setDataAndUpdate(newStr, m_data.length(), 0, data.length()); | 89 setDataAndUpdate(newStr, m_data.length(), 0, data.length()); |
| 91 | 90 |
| 92 // FIXME: Should we call textInserted here? | 91 // FIXME: Should we call textInserted here? |
| 93 } | 92 } |
| 94 | 93 |
| 95 void CharacterData::insertData(unsigned offset, const String& data, ExceptionSta
te& exceptionState, RecalcStyleBehavior recalcStyleBehavior) | 94 void CharacterData::insertData(unsigned offset, const String& data, ExceptionSta
te& exceptionState, RecalcStyleBehavior recalcStyleBehavior) |
| 96 { | 95 { |
| 97 if (offset > length()) { | 96 if (offset > 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()) + ").")); | 97 exceptionState.throwDOMException(IndexSizeError, "The offset " + String:
:number(offset) + " is greater than the node's length (" + String::number(length
()) + ")."); |
| 99 return; | 98 return; |
| 100 } | 99 } |
| 101 | 100 |
| 102 String newStr = m_data; | 101 String newStr = m_data; |
| 103 newStr.insert(data, offset); | 102 newStr.insert(data, offset); |
| 104 | 103 |
| 105 setDataAndUpdate(newStr, offset, 0, data.length(), recalcStyleBehavior); | 104 setDataAndUpdate(newStr, offset, 0, data.length(), recalcStyleBehavior); |
| 106 | 105 |
| 107 document().didInsertText(this, offset, data.length()); | 106 document().didInsertText(this, offset, data.length()); |
| 108 } | 107 } |
| 109 | 108 |
| 110 void CharacterData::deleteData(unsigned offset, unsigned count, ExceptionState&
exceptionState, RecalcStyleBehavior recalcStyleBehavior) | 109 void CharacterData::deleteData(unsigned offset, unsigned count, ExceptionState&
exceptionState, RecalcStyleBehavior recalcStyleBehavior) |
| 111 { | 110 { |
| 112 if (offset > length()) { | 111 if (offset > 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()) + ").")); | 112 exceptionState.throwDOMException(IndexSizeError, "The offset " + String:
:number(offset) + " is greater than the node's length (" + String::number(length
()) + ")."); |
| 114 return; | 113 return; |
| 115 } | 114 } |
| 116 | 115 |
| 117 unsigned realCount; | 116 unsigned realCount; |
| 118 if (offset + count > length()) | 117 if (offset + count > length()) |
| 119 realCount = length() - offset; | 118 realCount = length() - offset; |
| 120 else | 119 else |
| 121 realCount = count; | 120 realCount = count; |
| 122 | 121 |
| 123 String newStr = m_data; | 122 String newStr = m_data; |
| 124 newStr.remove(offset, realCount); | 123 newStr.remove(offset, realCount); |
| 125 | 124 |
| 126 setDataAndUpdate(newStr, offset, count, 0, recalcStyleBehavior); | 125 setDataAndUpdate(newStr, offset, count, 0, recalcStyleBehavior); |
| 127 | 126 |
| 128 document().didRemoveText(this, offset, realCount); | 127 document().didRemoveText(this, offset, realCount); |
| 129 } | 128 } |
| 130 | 129 |
| 131 void CharacterData::replaceData(unsigned offset, unsigned count, const String& d
ata, ExceptionState& exceptionState) | 130 void CharacterData::replaceData(unsigned offset, unsigned count, const String& d
ata, ExceptionState& exceptionState) |
| 132 { | 131 { |
| 133 if (offset > length()) { | 132 if (offset > 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()) + ").")); | 133 exceptionState.throwDOMException(IndexSizeError, "The offset " + String:
:number(offset) + " is greater than the node's length (" + String::number(length
()) + ")."); |
| 135 return; | 134 return; |
| 136 } | 135 } |
| 137 | 136 |
| 138 unsigned realCount; | 137 unsigned realCount; |
| 139 if (offset + count > length()) | 138 if (offset + count > length()) |
| 140 realCount = length() - offset; | 139 realCount = length() - offset; |
| 141 else | 140 else |
| 142 realCount = count; | 141 realCount = count; |
| 143 | 142 |
| 144 String newStr = m_data; | 143 String newStr = m_data; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 { | 205 { |
| 207 return static_cast<int>(length()); | 206 return static_cast<int>(length()); |
| 208 } | 207 } |
| 209 | 208 |
| 210 bool CharacterData::offsetInCharacters() const | 209 bool CharacterData::offsetInCharacters() const |
| 211 { | 210 { |
| 212 return true; | 211 return true; |
| 213 } | 212 } |
| 214 | 213 |
| 215 } // namespace WebCore | 214 } // namespace WebCore |
| OLD | NEW |