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

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

Issue 2615953003: Rename IGNORE_EXCEPTION to IGNORE_EXCEPTION_FOR_TESTING (Closed)
Patch Set: temp Created 3 years, 11 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 Apple Inc. All rights 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
5 * reserved. 5 * 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 Text* Text::createEditingText(Document& document, const String& data) { 52 Text* Text::createEditingText(Document& document, const String& data) {
53 return new Text(document, data, CreateEditingText); 53 return new Text(document, data, CreateEditingText);
54 } 54 }
55 55
56 Node* Text::mergeNextSiblingNodesIfPossible() { 56 Node* Text::mergeNextSiblingNodesIfPossible() {
57 // Remove empty text nodes. 57 // Remove empty text nodes.
58 if (!length()) { 58 if (!length()) {
59 // Care must be taken to get the next node before removing the current node. 59 // Care must be taken to get the next node before removing the current node.
60 Node* nextNode = NodeTraversal::nextPostOrder(*this); 60 Node* nextNode = NodeTraversal::nextPostOrder(*this);
61 remove(IGNORE_EXCEPTION); 61 remove(IGNORE_EXCEPTION_FOR_TESTING);
62 return nextNode; 62 return nextNode;
63 } 63 }
64 64
65 // Merge text nodes. 65 // Merge text nodes.
66 while (Node* nextSibling = this->nextSibling()) { 66 while (Node* nextSibling = this->nextSibling()) {
67 if (nextSibling->getNodeType() != kTextNode) 67 if (nextSibling->getNodeType() != kTextNode)
68 break; 68 break;
69 69
70 Text* nextText = toText(nextSibling); 70 Text* nextText = toText(nextSibling);
71 71
72 // Remove empty text nodes. 72 // Remove empty text nodes.
73 if (!nextText->length()) { 73 if (!nextText->length()) {
74 nextText->remove(IGNORE_EXCEPTION); 74 nextText->remove(IGNORE_EXCEPTION_FOR_TESTING);
75 continue; 75 continue;
76 } 76 }
77 77
78 // Both non-empty text nodes. Merge them. 78 // Both non-empty text nodes. Merge them.
79 unsigned offset = length(); 79 unsigned offset = length();
80 String nextTextData = nextText->data(); 80 String nextTextData = nextText->data();
81 String oldTextData = data(); 81 String oldTextData = data();
82 setDataWithoutUpdate(data() + nextTextData); 82 setDataWithoutUpdate(data() + nextTextData);
83 updateTextLayoutObject(oldTextData.length(), 0); 83 updateTextLayoutObject(oldTextData.length(), 0);
84 84
85 // Empty nextText for layout update. 85 // Empty nextText for layout update.
86 nextText->setDataWithoutUpdate(emptyString()); 86 nextText->setDataWithoutUpdate(emptyString());
87 nextText->updateTextLayoutObject(0, nextTextData.length()); 87 nextText->updateTextLayoutObject(0, nextTextData.length());
88 88
89 document().didMergeTextNodes(*nextText, offset); 89 document().didMergeTextNodes(*nextText, offset);
90 90
91 // Restore nextText for mutation event. 91 // Restore nextText for mutation event.
92 nextText->setDataWithoutUpdate(nextTextData); 92 nextText->setDataWithoutUpdate(nextTextData);
93 nextText->updateTextLayoutObject(0, 0); 93 nextText->updateTextLayoutObject(0, 0);
94 94
95 document().incDOMTreeVersion(); 95 document().incDOMTreeVersion();
96 didModifyData(oldTextData, CharacterData::UpdateFromNonParser); 96 didModifyData(oldTextData, CharacterData::UpdateFromNonParser);
97 nextText->remove(IGNORE_EXCEPTION); 97 nextText->remove(IGNORE_EXCEPTION_FOR_TESTING);
98 } 98 }
99 99
100 return NodeTraversal::nextPostOrder(*this); 100 return NodeTraversal::nextPostOrder(*this);
101 } 101 }
102 102
103 Text* Text::splitText(unsigned offset, ExceptionState& exceptionState) { 103 Text* Text::splitText(unsigned offset, ExceptionState& exceptionState) {
104 // IndexSizeError: Raised if the specified offset is negative or greater than 104 // IndexSizeError: Raised if the specified offset is negative or greater than
105 // the number of 16-bit units in data. 105 // the number of 16-bit units in data.
106 if (offset > length()) { 106 if (offset > length()) {
107 exceptionState.throwDOMException( 107 exceptionState.throwDOMException(
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // last ref 195 // last ref
196 Text* startText = const_cast<Text*>(earliestLogicallyAdjacentTextNode(this)); 196 Text* startText = const_cast<Text*>(earliestLogicallyAdjacentTextNode(this));
197 Text* endText = const_cast<Text*>(latestLogicallyAdjacentTextNode(this)); 197 Text* endText = const_cast<Text*>(latestLogicallyAdjacentTextNode(this));
198 198
199 ContainerNode* parent = parentNode(); // Protect against mutation handlers 199 ContainerNode* parent = parentNode(); // Protect against mutation handlers
200 // moving this node during traversal 200 // moving this node during traversal
201 for (Node* n = startText; 201 for (Node* n = startText;
202 n && n != this && n->isTextNode() && n->parentNode() == parent;) { 202 n && n != this && n->isTextNode() && n->parentNode() == parent;) {
203 Node* nodeToRemove = n; 203 Node* nodeToRemove = n;
204 n = nodeToRemove->nextSibling(); 204 n = nodeToRemove->nextSibling();
205 parent->removeChild(nodeToRemove, IGNORE_EXCEPTION); 205 parent->removeChild(nodeToRemove, IGNORE_EXCEPTION_FOR_TESTING);
206 } 206 }
207 207
208 if (this != endText) { 208 if (this != endText) {
209 Node* onePastEndText = endText->nextSibling(); 209 Node* onePastEndText = endText->nextSibling();
210 for (Node* n = nextSibling(); n && n != onePastEndText && n->isTextNode() && 210 for (Node* n = nextSibling(); n && n != onePastEndText && n->isTextNode() &&
211 n->parentNode() == parent;) { 211 n->parentNode() == parent;) {
212 Node* nodeToRemove = n; 212 Node* nodeToRemove = n;
213 n = nodeToRemove->nextSibling(); 213 n = nodeToRemove->nextSibling();
214 parent->removeChild(nodeToRemove, IGNORE_EXCEPTION); 214 parent->removeChild(nodeToRemove, IGNORE_EXCEPTION_FOR_TESTING);
215 } 215 }
216 } 216 }
217 217
218 if (newText.isEmpty()) { 218 if (newText.isEmpty()) {
219 if (parent && parentNode() == parent) 219 if (parent && parentNode() == parent)
220 parent->removeChild(this, IGNORE_EXCEPTION); 220 parent->removeChild(this, IGNORE_EXCEPTION_FOR_TESTING);
221 return nullptr; 221 return nullptr;
222 } 222 }
223 223
224 setData(newText); 224 setData(newText);
225 return this; 225 return this;
226 } 226 }
227 227
228 String Text::nodeName() const { 228 String Text::nodeName() const {
229 return "#text"; 229 return "#text";
230 } 230 }
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 449
450 Text* Text::cloneWithData(const String& data) { 450 Text* Text::cloneWithData(const String& data) {
451 return create(document(), data); 451 return create(document(), data);
452 } 452 }
453 453
454 DEFINE_TRACE(Text) { 454 DEFINE_TRACE(Text) {
455 CharacterData::trace(visitor); 455 CharacterData::trace(visitor);
456 } 456 }
457 457
458 } // namespace blink 458 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Range.cpp ('k') | third_party/WebKit/Source/core/editing/EphemeralRangeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698