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 Apple Inc. All rights
reserved. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 return adoptRef(new Text(document, data, CreateEditingText)); | 53 return adoptRef(new Text(document, data, CreateEditingText)); |
54 } | 54 } |
55 | 55 |
56 PassRefPtr<Node> Text::mergeNextSiblingNodesIfPossible() | 56 PassRefPtr<Node> Text::mergeNextSiblingNodesIfPossible() |
57 { | 57 { |
58 RefPtr<Node> protect(this); | 58 RefPtr<Node> protect(this); |
59 | 59 |
60 // Remove empty text nodes. | 60 // Remove empty text nodes. |
61 if (!length()) { | 61 if (!length()) { |
62 // Care must be taken to get the next node before removing the current n
ode. | 62 // Care must be taken to get the next node before removing the current n
ode. |
63 RefPtr<Node> nextNode(NodeTraversal::nextPostOrder(this)); | 63 RefPtr<Node> nextNode(NodeTraversal::nextPostOrder(*this)); |
64 remove(IGNORE_EXCEPTION); | 64 remove(IGNORE_EXCEPTION); |
65 return nextNode.release(); | 65 return nextNode.release(); |
66 } | 66 } |
67 | 67 |
68 // Merge text nodes. | 68 // Merge text nodes. |
69 while (Node* nextSibling = this->nextSibling()) { | 69 while (Node* nextSibling = this->nextSibling()) { |
70 if (nextSibling->nodeType() != TEXT_NODE) | 70 if (nextSibling->nodeType() != TEXT_NODE) |
71 break; | 71 break; |
72 | 72 |
73 RefPtr<Text> nextText = toText(nextSibling); | 73 RefPtr<Text> nextText = toText(nextSibling); |
(...skipping 13 matching lines...) Expand all Loading... |
87 // Empty nextText for layout update. | 87 // Empty nextText for layout update. |
88 nextText->setDataWithoutUpdate(emptyString()); | 88 nextText->setDataWithoutUpdate(emptyString()); |
89 document().didMergeTextNodes(nextText.get(), offset); | 89 document().didMergeTextNodes(nextText.get(), offset); |
90 // Restore nextText for mutation event. | 90 // Restore nextText for mutation event. |
91 nextText->setDataWithoutUpdate(nextTextData); | 91 nextText->setDataWithoutUpdate(nextTextData); |
92 document().incDOMTreeVersion(); | 92 document().incDOMTreeVersion(); |
93 didModifyData(oldTextData); | 93 didModifyData(oldTextData); |
94 nextText->remove(IGNORE_EXCEPTION); | 94 nextText->remove(IGNORE_EXCEPTION); |
95 } | 95 } |
96 | 96 |
97 return NodeTraversal::nextPostOrder(this); | 97 return NodeTraversal::nextPostOrder(*this); |
98 } | 98 } |
99 | 99 |
100 PassRefPtr<Text> Text::splitText(unsigned offset, ExceptionState& es) | 100 PassRefPtr<Text> Text::splitText(unsigned offset, ExceptionState& es) |
101 { | 101 { |
102 // IndexSizeError: Raised if the specified offset is negative or greater tha
n | 102 // IndexSizeError: Raised if the specified offset is negative or greater tha
n |
103 // the number of 16-bit units in data. | 103 // the number of 16-bit units in data. |
104 if (offset > length()) { | 104 if (offset > length()) { |
105 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute(
"splitText", "Text", "The offset " + String::number(offset) + " is larger than t
he Text node's length.")); | 105 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute(
"splitText", "Text", "The offset " + String::number(offset) + " is larger than t
he Text node's length.")); |
106 return 0; | 106 return 0; |
107 } | 107 } |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 result.appendLiteral("; "); | 368 result.appendLiteral("; "); |
369 result.appendLiteral("value="); | 369 result.appendLiteral("value="); |
370 result.append(s); | 370 result.append(s); |
371 } | 371 } |
372 | 372 |
373 strncpy(buffer, result.toString().utf8().data(), length - 1); | 373 strncpy(buffer, result.toString().utf8().data(), length - 1); |
374 } | 374 } |
375 #endif | 375 #endif |
376 | 376 |
377 } // namespace WebCore | 377 } // namespace WebCore |
OLD | NEW |