| 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 | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All |
| 5 * rights reserved. | 5 * rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 #include "core/dom/CharacterData.h" | 23 #include "core/dom/CharacterData.h" |
| 24 | 24 |
| 25 #include "bindings/core/v8/ExceptionState.h" | 25 #include "bindings/core/v8/ExceptionState.h" |
| 26 #include "core/dom/Document.h" | 26 #include "core/dom/Document.h" |
| 27 #include "core/dom/ExceptionCode.h" | 27 #include "core/dom/ExceptionCode.h" |
| 28 #include "core/dom/MutationObserverInterestGroup.h" | 28 #include "core/dom/MutationObserverInterestGroup.h" |
| 29 #include "core/dom/MutationRecord.h" | 29 #include "core/dom/MutationRecord.h" |
| 30 #include "core/dom/ProcessingInstruction.h" | 30 #include "core/dom/ProcessingInstruction.h" |
| 31 #include "core/dom/Text.h" | 31 #include "core/dom/Text.h" |
| 32 #include "core/editing/FrameSelection.h" | |
| 33 #include "core/events/MutationEvent.h" | 32 #include "core/events/MutationEvent.h" |
| 34 #include "core/inspector/InspectorInstrumentation.h" | 33 #include "core/inspector/InspectorInstrumentation.h" |
| 35 #include "wtf/CheckedNumeric.h" | 34 #include "wtf/CheckedNumeric.h" |
| 36 | 35 |
| 37 namespace blink { | 36 namespace blink { |
| 38 | 37 |
| 39 void CharacterData::atomize() { | 38 void CharacterData::atomize() { |
| 40 m_data = AtomicString(m_data); | 39 m_data = AtomicString(m_data); |
| 41 } | 40 } |
| 42 | 41 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 168 |
| 170 void CharacterData::setNodeValue(const String& nodeValue) { | 169 void CharacterData::setNodeValue(const String& nodeValue) { |
| 171 setData(nodeValue); | 170 setData(nodeValue); |
| 172 } | 171 } |
| 173 | 172 |
| 174 void CharacterData::setDataAndUpdate(const String& newData, | 173 void CharacterData::setDataAndUpdate(const String& newData, |
| 175 unsigned offsetOfReplacedData, | 174 unsigned offsetOfReplacedData, |
| 176 unsigned oldLength, | 175 unsigned oldLength, |
| 177 unsigned newLength, | 176 unsigned newLength, |
| 178 UpdateSource source) { | 177 UpdateSource source) { |
| 179 if (source != UpdateFromParser) | |
| 180 document().dataWillChange(*this); | |
| 181 | |
| 182 String oldData = m_data; | 178 String oldData = m_data; |
| 183 m_data = newData; | 179 m_data = newData; |
| 184 | 180 |
| 185 DCHECK(!layoutObject() || isTextNode()); | 181 document().incDOMTreeVersion(); |
| 186 if (isTextNode()) | |
| 187 toText(this)->updateTextLayoutObject(offsetOfReplacedData, oldLength); | |
| 188 | |
| 189 if (source != UpdateFromParser) { | 182 if (source != UpdateFromParser) { |
| 190 if (getNodeType() == kProcessingInstructionNode) | 183 if (getNodeType() == kProcessingInstructionNode) |
| 191 toProcessingInstruction(this)->didAttributeChanged(); | 184 toProcessingInstruction(this)->didAttributeChanged(); |
| 192 | 185 |
| 193 document().notifyUpdateCharacterData(this, offsetOfReplacedData, oldLength, | 186 document().notifyUpdateCharacterData(this, offsetOfReplacedData, oldLength, |
| 194 newLength); | 187 newLength); |
| 195 | |
| 196 if (document().frame()) | |
| 197 document().frame()->selection().didUpdateCharacterData( | |
| 198 this, offsetOfReplacedData, oldLength, newLength); | |
| 199 } | 188 } |
| 200 | 189 |
| 201 document().incDOMTreeVersion(); | 190 DCHECK(!layoutObject() || isTextNode()); |
| 191 if (isTextNode()) |
| 192 toText(this)->updateTextLayoutObject(offsetOfReplacedData, oldLength); |
| 193 |
| 202 didModifyData(oldData, source); | 194 didModifyData(oldData, source); |
| 203 } | 195 } |
| 204 | 196 |
| 205 void CharacterData::didModifyData(const String& oldData, UpdateSource source) { | 197 void CharacterData::didModifyData(const String& oldData, UpdateSource source) { |
| 206 if (MutationObserverInterestGroup* mutationRecipients = | 198 if (MutationObserverInterestGroup* mutationRecipients = |
| 207 MutationObserverInterestGroup::createForCharacterDataMutation(*this)) | 199 MutationObserverInterestGroup::createForCharacterDataMutation(*this)) |
| 208 mutationRecipients->enqueueMutationRecord( | 200 mutationRecipients->enqueueMutationRecord( |
| 209 MutationRecord::createCharacterData(this, oldData)); | 201 MutationRecord::createCharacterData(this, oldData)); |
| 210 | 202 |
| 211 if (parentNode()) { | 203 if (parentNode()) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 226 dispatchSubtreeModifiedEvent(); | 218 dispatchSubtreeModifiedEvent(); |
| 227 } | 219 } |
| 228 InspectorInstrumentation::characterDataModified(this); | 220 InspectorInstrumentation::characterDataModified(this); |
| 229 } | 221 } |
| 230 | 222 |
| 231 int CharacterData::maxCharacterOffset() const { | 223 int CharacterData::maxCharacterOffset() const { |
| 232 return static_cast<int>(length()); | 224 return static_cast<int>(length()); |
| 233 } | 225 } |
| 234 | 226 |
| 235 } // namespace blink | 227 } // namespace blink |
| OLD | NEW |