| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 return NodeTraversal::nextPostOrder(*this); | 103 return NodeTraversal::nextPostOrder(*this); |
| 104 } | 104 } |
| 105 | 105 |
| 106 PassRefPtr<Text> Text::splitText(unsigned offset, ExceptionState& exceptionState
) | 106 PassRefPtr<Text> Text::splitText(unsigned offset, ExceptionState& exceptionState
) |
| 107 { | 107 { |
| 108 // IndexSizeError: Raised if the specified offset is negative or greater tha
n | 108 // IndexSizeError: Raised if the specified offset is negative or greater tha
n |
| 109 // the number of 16-bit units in data. | 109 // the number of 16-bit units in data. |
| 110 if (offset > length()) { | 110 if (offset > length()) { |
| 111 exceptionState.throwDOMException(IndexSizeError, "The offset " + String:
:number(offset) + " is larger than the Text node's length."); | 111 exceptionState.throwDOMException(IndexSizeError, "The offset " + String:
:number(offset) + " is larger than the Text node's length."); |
| 112 return 0; | 112 return nullptr; |
| 113 } | 113 } |
| 114 | 114 |
| 115 EventQueueScope scope; | 115 EventQueueScope scope; |
| 116 String oldStr = data(); | 116 String oldStr = data(); |
| 117 RefPtr<Text> newText = cloneWithData(oldStr.substring(offset)); | 117 RefPtr<Text> newText = cloneWithData(oldStr.substring(offset)); |
| 118 setDataWithoutUpdate(oldStr.substring(0, offset)); | 118 setDataWithoutUpdate(oldStr.substring(0, offset)); |
| 119 | 119 |
| 120 didModifyData(oldStr); | 120 didModifyData(oldStr); |
| 121 | 121 |
| 122 if (parentNode()) | 122 if (parentNode()) |
| 123 parentNode()->insertBefore(newText.get(), nextSibling(), exceptionState)
; | 123 parentNode()->insertBefore(newText.get(), nextSibling(), exceptionState)
; |
| 124 if (exceptionState.hadException()) | 124 if (exceptionState.hadException()) |
| 125 return 0; | 125 return nullptr; |
| 126 | 126 |
| 127 if (renderer()) | 127 if (renderer()) |
| 128 toRenderText(renderer())->setTextWithOffset(dataImpl(), 0, oldStr.length
()); | 128 toRenderText(renderer())->setTextWithOffset(dataImpl(), 0, oldStr.length
()); |
| 129 | 129 |
| 130 if (parentNode()) | 130 if (parentNode()) |
| 131 document().didSplitTextNode(this); | 131 document().didSplitTextNode(this); |
| 132 | 132 |
| 133 return newText.release(); | 133 return newText.release(); |
| 134 } | 134 } |
| 135 | 135 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 for (RefPtr<Node> n = nextSibling(); n && n != onePastEndText && n->isTe
xtNode() && n->parentNode() == parent;) { | 211 for (RefPtr<Node> n = nextSibling(); n && n != onePastEndText && n->isTe
xtNode() && n->parentNode() == parent;) { |
| 212 RefPtr<Node> nodeToRemove(n.release()); | 212 RefPtr<Node> nodeToRemove(n.release()); |
| 213 n = nodeToRemove->nextSibling(); | 213 n = nodeToRemove->nextSibling(); |
| 214 parent->removeChild(nodeToRemove.get(), IGNORE_EXCEPTION); | 214 parent->removeChild(nodeToRemove.get(), IGNORE_EXCEPTION); |
| 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); |
| 221 return 0; | 221 return nullptr; |
| 222 } | 222 } |
| 223 | 223 |
| 224 setData(newText); | 224 setData(newText); |
| 225 return protectedThis.release(); | 225 return protectedThis.release(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 String Text::nodeName() const | 228 String Text::nodeName() const |
| 229 { | 229 { |
| 230 return "#text"; | 230 return "#text"; |
| 231 } | 231 } |
| (...skipping 136 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 |