| 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" |
| 25 #include "bindings/v8/ExceptionState.h" | 26 #include "bindings/v8/ExceptionState.h" |
| 26 #include "core/dom/Document.h" | 27 #include "core/dom/Document.h" |
| 27 #include "core/dom/EventNames.h" | 28 #include "core/dom/EventNames.h" |
| 28 #include "core/dom/ExceptionCode.h" | 29 #include "core/dom/ExceptionCode.h" |
| 29 #include "core/dom/MutationEvent.h" | 30 #include "core/dom/MutationEvent.h" |
| 30 #include "core/dom/MutationObserverInterestGroup.h" | 31 #include "core/dom/MutationObserverInterestGroup.h" |
| 31 #include "core/dom/MutationRecord.h" | 32 #include "core/dom/MutationRecord.h" |
| 32 #include "core/dom/ProcessingInstruction.h" | 33 #include "core/dom/ProcessingInstruction.h" |
| 33 #include "core/dom/Text.h" | 34 #include "core/dom/Text.h" |
| 34 #include "core/editing/FrameSelection.h" | 35 #include "core/editing/FrameSelection.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 54 | 55 |
| 55 unsigned oldLength = length(); | 56 unsigned oldLength = length(); |
| 56 | 57 |
| 57 setDataAndUpdate(nonNullData, 0, oldLength, nonNullData.length()); | 58 setDataAndUpdate(nonNullData, 0, oldLength, nonNullData.length()); |
| 58 document().didRemoveText(this, 0, oldLength); | 59 document().didRemoveText(this, 0, oldLength); |
| 59 } | 60 } |
| 60 | 61 |
| 61 String CharacterData::substringData(unsigned offset, unsigned count, ExceptionSt
ate& es) | 62 String CharacterData::substringData(unsigned offset, unsigned count, ExceptionSt
ate& es) |
| 62 { | 63 { |
| 63 if (offset > length()) { | 64 if (offset > length()) { |
| 64 es.throwDOMException(IndexSizeError); | 65 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute(
"substringData", "CharacterData", "The offset " + String::number(offset) + " is
greater than the node's length (" + String::number(length()) + ").")); |
| 65 return String(); | 66 return String(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 return m_data.substring(offset, count); | 69 return m_data.substring(offset, count); |
| 69 } | 70 } |
| 70 | 71 |
| 71 unsigned CharacterData::parserAppendData(const String& string, unsigned offset,
unsigned lengthLimit) | 72 unsigned CharacterData::parserAppendData(const String& string, unsigned offset,
unsigned lengthLimit) |
| 72 { | 73 { |
| 73 unsigned oldLength = m_data.length(); | 74 unsigned oldLength = m_data.length(); |
| 74 | 75 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 String newStr = m_data + data; | 114 String newStr = m_data + data; |
| 114 | 115 |
| 115 setDataAndUpdate(newStr, m_data.length(), 0, data.length()); | 116 setDataAndUpdate(newStr, m_data.length(), 0, data.length()); |
| 116 | 117 |
| 117 // FIXME: Should we call textInserted here? | 118 // FIXME: Should we call textInserted here? |
| 118 } | 119 } |
| 119 | 120 |
| 120 void CharacterData::insertData(unsigned offset, const String& data, ExceptionSta
te& es, RecalcStyleBehavior recalcStyleBehavior) | 121 void CharacterData::insertData(unsigned offset, const String& data, ExceptionSta
te& es, RecalcStyleBehavior recalcStyleBehavior) |
| 121 { | 122 { |
| 122 if (offset > length()) { | 123 if (offset > length()) { |
| 123 es.throwDOMException(IndexSizeError); | 124 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute(
"insertData", "CharacterData", "The offset " + String::number(offset) + " is gre
ater than the node's length (" + String::number(length()) + ").")); |
| 124 return; | 125 return; |
| 125 } | 126 } |
| 126 | 127 |
| 127 String newStr = m_data; | 128 String newStr = m_data; |
| 128 newStr.insert(data, offset); | 129 newStr.insert(data, offset); |
| 129 | 130 |
| 130 setDataAndUpdate(newStr, offset, 0, data.length(), recalcStyleBehavior); | 131 setDataAndUpdate(newStr, offset, 0, data.length(), recalcStyleBehavior); |
| 131 | 132 |
| 132 document().didInsertText(this, offset, data.length()); | 133 document().didInsertText(this, offset, data.length()); |
| 133 } | 134 } |
| 134 | 135 |
| 135 void CharacterData::deleteData(unsigned offset, unsigned count, ExceptionState&
es, RecalcStyleBehavior recalcStyleBehavior) | 136 void CharacterData::deleteData(unsigned offset, unsigned count, ExceptionState&
es, RecalcStyleBehavior recalcStyleBehavior) |
| 136 { | 137 { |
| 137 if (offset > length()) { | 138 if (offset > length()) { |
| 138 es.throwDOMException(IndexSizeError); | 139 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute(
"deleteData", "CharacterData", "The offset " + String::number(offset) + " is gre
ater than the node's length (" + String::number(length()) + ").")); |
| 139 return; | 140 return; |
| 140 } | 141 } |
| 141 | 142 |
| 142 unsigned realCount; | 143 unsigned realCount; |
| 143 if (offset + count > length()) | 144 if (offset + count > length()) |
| 144 realCount = length() - offset; | 145 realCount = length() - offset; |
| 145 else | 146 else |
| 146 realCount = count; | 147 realCount = count; |
| 147 | 148 |
| 148 String newStr = m_data; | 149 String newStr = m_data; |
| 149 newStr.remove(offset, realCount); | 150 newStr.remove(offset, realCount); |
| 150 | 151 |
| 151 setDataAndUpdate(newStr, offset, count, 0, recalcStyleBehavior); | 152 setDataAndUpdate(newStr, offset, count, 0, recalcStyleBehavior); |
| 152 | 153 |
| 153 document().didRemoveText(this, offset, realCount); | 154 document().didRemoveText(this, offset, realCount); |
| 154 } | 155 } |
| 155 | 156 |
| 156 void CharacterData::replaceData(unsigned offset, unsigned count, const String& d
ata, ExceptionState& es) | 157 void CharacterData::replaceData(unsigned offset, unsigned count, const String& d
ata, ExceptionState& es) |
| 157 { | 158 { |
| 158 if (offset > length()) { | 159 if (offset > length()) { |
| 159 es.throwDOMException(IndexSizeError); | 160 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute(
"replaceData", "CharacterData", "The offset " + String::number(offset) + " is gr
eater than the node's length (" + String::number(length()) + ").")); |
| 160 return; | 161 return; |
| 161 } | 162 } |
| 162 | 163 |
| 163 unsigned realCount; | 164 unsigned realCount; |
| 164 if (offset + count > length()) | 165 if (offset + count > length()) |
| 165 realCount = length() - offset; | 166 realCount = length() - offset; |
| 166 else | 167 else |
| 167 realCount = count; | 168 realCount = count; |
| 168 | 169 |
| 169 String newStr = m_data; | 170 String newStr = m_data; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 { | 232 { |
| 232 return static_cast<int>(length()); | 233 return static_cast<int>(length()); |
| 233 } | 234 } |
| 234 | 235 |
| 235 bool CharacterData::offsetInCharacters() const | 236 bool CharacterData::offsetInCharacters() const |
| 236 { | 237 { |
| 237 return true; | 238 return true; |
| 238 } | 239 } |
| 239 | 240 |
| 240 } // namespace WebCore | 241 } // namespace WebCore |
| OLD | NEW |