Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: third_party/WebKit/Source/core/dom/CharacterData.cpp

Issue 1950473002: Invalidate the previous caret location when editing text nodes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 29 matching lines...) Expand all
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 RawPtr<CharacterData> protect(this); 49 RawPtr<CharacterData> protect(this);
50 document().dataWillChange(*this);
50 51
51 unsigned oldLength = length(); 52 unsigned oldLength = length();
52 53
53 setDataAndUpdate(nonNullData, 0, oldLength, nonNullData.length(), UpdateFrom NonParser); 54 setDataAndUpdate(nonNullData, 0, oldLength, nonNullData.length(), UpdateFrom NonParser);
54 document().didRemoveText(this, 0, oldLength); 55 document().didRemoveText(this, 0, oldLength);
55 } 56 }
56 57
57 String CharacterData::substringData(unsigned offset, unsigned count, ExceptionSt ate& exceptionState) 58 String CharacterData::substringData(unsigned offset, unsigned count, ExceptionSt ate& exceptionState)
58 { 59 {
59 if (offset > length()) { 60 if (offset > length()) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return m_data.containsOnlyWhitespace(); 155 return m_data.containsOnlyWhitespace();
155 } 156 }
156 157
157 void CharacterData::setNodeValue(const String& nodeValue) 158 void CharacterData::setNodeValue(const String& nodeValue)
158 { 159 {
159 setData(nodeValue); 160 setData(nodeValue);
160 } 161 }
161 162
162 void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfRep lacedData, unsigned oldLength, unsigned newLength, UpdateSource source, RecalcSt yleBehavior recalcStyleBehavior) 163 void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfRep lacedData, unsigned oldLength, unsigned newLength, UpdateSource source, RecalcSt yleBehavior recalcStyleBehavior)
163 { 164 {
165 if (source != UpdateFromParser)
166 document().dataWillChange(*this);
167
164 String oldData = m_data; 168 String oldData = m_data;
165 m_data = newData; 169 m_data = newData;
166 170
167 DCHECK(!layoutObject() || isTextNode()); 171 DCHECK(!layoutObject() || isTextNode());
168 if (isTextNode()) 172 if (isTextNode())
169 toText(this)->updateTextLayoutObject(offsetOfReplacedData, oldLength, re calcStyleBehavior); 173 toText(this)->updateTextLayoutObject(offsetOfReplacedData, oldLength, re calcStyleBehavior);
170 174
171 if (source != UpdateFromParser) { 175 if (source != UpdateFromParser) {
172 if (getNodeType() == PROCESSING_INSTRUCTION_NODE) 176 if (getNodeType() == PROCESSING_INSTRUCTION_NODE)
173 toProcessingInstruction(this)->didAttributeChanged(); 177 toProcessingInstruction(this)->didAttributeChanged();
(...skipping 26 matching lines...) Expand all
200 } 204 }
201 InspectorInstrumentation::characterDataModified(this); 205 InspectorInstrumentation::characterDataModified(this);
202 } 206 }
203 207
204 int CharacterData::maxCharacterOffset() const 208 int CharacterData::maxCharacterOffset() const
205 { 209 {
206 return static_cast<int>(length()); 210 return static_cast<int>(length());
207 } 211 }
208 212
209 } // namespace blink 213 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698