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

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

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 setDataAndUpdate(nonNullData, 0, oldLength, nonNullData.length(), 47 setDataAndUpdate(nonNullData, 0, oldLength, nonNullData.length(),
48 UpdateFromNonParser); 48 UpdateFromNonParser);
49 document().didRemoveText(this, 0, oldLength); 49 document().didRemoveText(this, 0, oldLength);
50 } 50 }
51 51
52 String CharacterData::substringData(unsigned offset, 52 String CharacterData::substringData(unsigned offset,
53 unsigned count, 53 unsigned count,
54 ExceptionState& exceptionState) { 54 ExceptionState& exceptionState) {
55 if (offset > length()) { 55 if (offset > length()) {
56 exceptionState.throwDOMException( 56 exceptionState.throwDOMException(
57 IndexSizeError, "The offset " + String::number(offset) + 57 IndexSizeError,
58 " is greater than the node's length (" + 58 "The offset " + String::number(offset) +
59 String::number(length()) + ")."); 59 " is greater than the node's length (" + String::number(length()) +
60 ").");
60 return String(); 61 return String();
61 } 62 }
62 63
63 return m_data.substring(offset, count); 64 return m_data.substring(offset, count);
64 } 65 }
65 66
66 void CharacterData::parserAppendData(const String& data) { 67 void CharacterData::parserAppendData(const String& data) {
67 String newStr = m_data + data; 68 String newStr = m_data + data;
68 69
69 setDataAndUpdate(newStr, m_data.length(), 0, data.length(), UpdateFromParser); 70 setDataAndUpdate(newStr, m_data.length(), 0, data.length(), UpdateFromParser);
70 } 71 }
71 72
72 void CharacterData::appendData(const String& data) { 73 void CharacterData::appendData(const String& data) {
73 String newStr = m_data + data; 74 String newStr = m_data + data;
74 75
75 setDataAndUpdate(newStr, m_data.length(), 0, data.length(), 76 setDataAndUpdate(newStr, m_data.length(), 0, data.length(),
76 UpdateFromNonParser); 77 UpdateFromNonParser);
77 78
78 // FIXME: Should we call textInserted here? 79 // FIXME: Should we call textInserted here?
79 } 80 }
80 81
81 void CharacterData::insertData(unsigned offset, 82 void CharacterData::insertData(unsigned offset,
82 const String& data, 83 const String& data,
83 ExceptionState& exceptionState) { 84 ExceptionState& exceptionState) {
84 if (offset > length()) { 85 if (offset > length()) {
85 exceptionState.throwDOMException( 86 exceptionState.throwDOMException(
86 IndexSizeError, "The offset " + String::number(offset) + 87 IndexSizeError,
87 " is greater than the node's length (" + 88 "The offset " + String::number(offset) +
88 String::number(length()) + ")."); 89 " is greater than the node's length (" + String::number(length()) +
90 ").");
89 return; 91 return;
90 } 92 }
91 93
92 String newStr = m_data; 94 String newStr = m_data;
93 newStr.insert(data, offset); 95 newStr.insert(data, offset);
94 96
95 setDataAndUpdate(newStr, offset, 0, data.length(), UpdateFromNonParser); 97 setDataAndUpdate(newStr, offset, 0, data.length(), UpdateFromNonParser);
96 98
97 document().didInsertText(this, offset, data.length()); 99 document().didInsertText(this, offset, data.length());
98 } 100 }
99 101
100 static bool validateOffsetCount(unsigned offset, 102 static bool validateOffsetCount(unsigned offset,
101 unsigned count, 103 unsigned count,
102 unsigned length, 104 unsigned length,
103 unsigned& realCount, 105 unsigned& realCount,
104 ExceptionState& exceptionState) { 106 ExceptionState& exceptionState) {
105 if (offset > length) { 107 if (offset > length) {
106 exceptionState.throwDOMException( 108 exceptionState.throwDOMException(
107 IndexSizeError, "The offset " + String::number(offset) + 109 IndexSizeError,
108 " is greater than the node's length (" + 110 "The offset " + String::number(offset) +
109 String::number(length) + ")."); 111 " is greater than the node's length (" + String::number(length) +
112 ").");
110 return false; 113 return false;
111 } 114 }
112 115
113 CheckedNumeric<unsigned> offsetCount = offset; 116 CheckedNumeric<unsigned> offsetCount = offset;
114 offsetCount += count; 117 offsetCount += count;
115 118
116 if (!offsetCount.IsValid() || offset + count > length) 119 if (!offsetCount.IsValid() || offset + count > length)
117 realCount = length - offset; 120 realCount = length - offset;
118 else 121 else
119 realCount = count; 122 realCount = count;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 dispatchSubtreeModifiedEvent(); 219 dispatchSubtreeModifiedEvent();
217 } 220 }
218 InspectorInstrumentation::characterDataModified(this); 221 InspectorInstrumentation::characterDataModified(this);
219 } 222 }
220 223
221 int CharacterData::maxCharacterOffset() const { 224 int CharacterData::maxCharacterOffset() const {
222 return static_cast<int>(length()); 225 return static_cast<int>(length());
223 } 226 }
224 227
225 } // namespace blink 228 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698