| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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& exceptionState
) |
| 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 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToExecute("splitText", "Text", "The offset " + String::number(offset) + " is l
arger than the Text node's length.")); |
| 106 return 0; | 106 return 0; |
| 107 } | 107 } |
| 108 | 108 |
| 109 EventQueueScope scope; | 109 EventQueueScope scope; |
| 110 String oldStr = data(); | 110 String oldStr = data(); |
| 111 RefPtr<Text> newText = cloneWithData(oldStr.substring(offset)); | 111 RefPtr<Text> newText = cloneWithData(oldStr.substring(offset)); |
| 112 setDataWithoutUpdate(oldStr.substring(0, offset)); | 112 setDataWithoutUpdate(oldStr.substring(0, offset)); |
| 113 | 113 |
| 114 didModifyData(oldStr); | 114 didModifyData(oldStr); |
| 115 | 115 |
| 116 if (parentNode()) | 116 if (parentNode()) |
| 117 parentNode()->insertBefore(newText.get(), nextSibling(), es); | 117 parentNode()->insertBefore(newText.get(), nextSibling(), exceptionState)
; |
| 118 if (es.hadException()) | 118 if (exceptionState.hadException()) |
| 119 return 0; | 119 return 0; |
| 120 | 120 |
| 121 if (renderer()) | 121 if (renderer()) |
| 122 toRenderText(renderer())->setTextWithOffset(dataImpl(), 0, oldStr.length
()); | 122 toRenderText(renderer())->setTextWithOffset(dataImpl(), 0, oldStr.length
()); |
| 123 | 123 |
| 124 if (parentNode()) | 124 if (parentNode()) |
| 125 document().didSplitTextNode(this); | 125 document().didSplitTextNode(this); |
| 126 | 126 |
| 127 return newText.release(); | 127 return newText.release(); |
| 128 } | 128 } |
| (...skipping 239 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 |