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

Side by Side Diff: sky/engine/core/dom/CharacterData.cpp

Issue 922893002: Merge the Sky Engine changes from the SkyDart branch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « sky/engine/core/dom/Attr.h ('k') | sky/engine/core/dom/ChildNode.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 *
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 "sky/engine/config.h" 22 #include "sky/engine/config.h"
23 #include "sky/engine/core/dom/CharacterData.h" 23 #include "sky/engine/core/dom/CharacterData.h"
24 24
25 #include "sky/engine/bindings/core/v8/ExceptionState.h" 25 #include "sky/engine/bindings2/exception_state.h"
26 #include "sky/engine/core/dom/Document.h" 26 #include "sky/engine/core/dom/Document.h"
27 #include "sky/engine/core/dom/ExceptionCode.h" 27 #include "sky/engine/core/dom/ExceptionCode.h"
28 #include "sky/engine/core/dom/MutationObserverInterestGroup.h" 28 #include "sky/engine/core/dom/MutationObserverInterestGroup.h"
29 #include "sky/engine/core/dom/MutationRecord.h" 29 #include "sky/engine/core/dom/MutationRecord.h"
30 #include "sky/engine/core/dom/Text.h" 30 #include "sky/engine/core/dom/Text.h"
31 #include "sky/engine/core/editing/FrameSelection.h" 31 #include "sky/engine/core/editing/FrameSelection.h"
32 #include "sky/engine/core/frame/LocalFrame.h" 32 #include "sky/engine/core/frame/LocalFrame.h"
33 #include "sky/engine/wtf/CheckedArithmetic.h" 33 #include "sky/engine/wtf/CheckedArithmetic.h"
34 34
35 namespace blink { 35 namespace blink {
(...skipping 13 matching lines...) Expand all
49 49
50 unsigned oldLength = length(); 50 unsigned oldLength = length();
51 51
52 setDataAndUpdate(nonNullData, 0, oldLength, nonNullData.length()); 52 setDataAndUpdate(nonNullData, 0, oldLength, nonNullData.length());
53 document().didRemoveText(this, 0, oldLength); 53 document().didRemoveText(this, 0, oldLength);
54 } 54 }
55 55
56 String CharacterData::substringData(unsigned offset, unsigned count, ExceptionSt ate& exceptionState) 56 String CharacterData::substringData(unsigned offset, unsigned count, ExceptionSt ate& exceptionState)
57 { 57 {
58 if (offset > length()) { 58 if (offset > length()) {
59 exceptionState.throwDOMException(IndexSizeError, "The offset " + String: :number(offset) + " is greater than the node's length (" + String::number(length ()) + ")."); 59 exceptionState.ThrowDOMException(IndexSizeError, "The offset " + String: :number(offset) + " is greater than the node's length (" + String::number(length ()) + ").");
60 return String(); 60 return String();
61 } 61 }
62 62
63 return m_data.substring(offset, count); 63 return m_data.substring(offset, count);
64 } 64 }
65 65
66 void CharacterData::parserAppendData(const String& string) 66 void CharacterData::parserAppendData(const String& string)
67 { 67 {
68 unsigned oldLength = m_data.length(); 68 unsigned oldLength = m_data.length();
69 m_data = m_data + string; 69 m_data = m_data + string;
(...skipping 13 matching lines...) Expand all
83 String newStr = m_data + data; 83 String newStr = m_data + data;
84 84
85 setDataAndUpdate(newStr, m_data.length(), 0, data.length()); 85 setDataAndUpdate(newStr, m_data.length(), 0, data.length());
86 86
87 // FIXME: Should we call textInserted here? 87 // FIXME: Should we call textInserted here?
88 } 88 }
89 89
90 void CharacterData::insertData(unsigned offset, const String& data, ExceptionSta te& exceptionState, RecalcStyleBehavior recalcStyleBehavior) 90 void CharacterData::insertData(unsigned offset, const String& data, ExceptionSta te& exceptionState, RecalcStyleBehavior recalcStyleBehavior)
91 { 91 {
92 if (offset > length()) { 92 if (offset > length()) {
93 exceptionState.throwDOMException(IndexSizeError, "The offset " + String: :number(offset) + " is greater than the node's length (" + String::number(length ()) + ")."); 93 exceptionState.ThrowDOMException(IndexSizeError, "The offset " + String: :number(offset) + " is greater than the node's length (" + String::number(length ()) + ").");
94 return; 94 return;
95 } 95 }
96 96
97 String newStr = m_data; 97 String newStr = m_data;
98 newStr.insert(data, offset); 98 newStr.insert(data, offset);
99 99
100 setDataAndUpdate(newStr, offset, 0, data.length(), recalcStyleBehavior); 100 setDataAndUpdate(newStr, offset, 0, data.length(), recalcStyleBehavior);
101 101
102 document().didInsertText(this, offset, data.length()); 102 document().didInsertText(this, offset, data.length());
103 } 103 }
104 104
105 static bool validateOffsetCount(unsigned offset, unsigned count, unsigned length , unsigned& realCount, ExceptionState& exceptionState) 105 static bool validateOffsetCount(unsigned offset, unsigned count, unsigned length , unsigned& realCount, ExceptionState& exceptionState)
106 { 106 {
107 if (offset > length) { 107 if (offset > length) {
108 exceptionState.throwDOMException(IndexSizeError, "The offset " + String: :number(offset) + " is greater than the node's length (" + String::number(length ) + ")."); 108 exceptionState.ThrowDOMException(IndexSizeError, "The offset " + String: :number(offset) + " is greater than the node's length (" + String::number(length ) + ").");
109 return false; 109 return false;
110 } 110 }
111 111
112 Checked<unsigned, RecordOverflow> offsetCount = offset; 112 Checked<unsigned, RecordOverflow> offsetCount = offset;
113 offsetCount += count; 113 offsetCount += count;
114 114
115 if (offsetCount.hasOverflowed() || offset + count > length) 115 if (offsetCount.hasOverflowed() || offset + count > length)
116 realCount = length - offset; 116 realCount = length - offset;
117 else 117 else
118 realCount = count; 118 realCount = count;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 { 186 {
187 return static_cast<int>(length()); 187 return static_cast<int>(length());
188 } 188 }
189 189
190 bool CharacterData::offsetInCharacters() const 190 bool CharacterData::offsetInCharacters() const
191 { 191 {
192 return true; 192 return true;
193 } 193 }
194 194
195 } // namespace blink 195 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/dom/Attr.h ('k') | sky/engine/core/dom/ChildNode.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698