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) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
6 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 6 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 UChar c = 0; | 376 UChar c = 0; |
377 for (unsigned int start = 0; start < length; ) { | 377 for (unsigned int start = 0; start < length; ) { |
378 | 378 |
379 // Find next line break. | 379 // Find next line break. |
380 for (i = start; i < length; i++) { | 380 for (i = start; i < length; i++) { |
381 c = text[i]; | 381 c = text[i]; |
382 if (c == '\r' || c == '\n') | 382 if (c == '\r' || c == '\n') |
383 break; | 383 break; |
384 } | 384 } |
385 | 385 |
386 fragment->appendChild(Text::create(&document(), text.substring(start, i
- start)), es); | 386 fragment->appendChild(Text::create(document(), text.substring(start, i -
start)), es); |
387 if (es.hadException()) | 387 if (es.hadException()) |
388 return 0; | 388 return 0; |
389 | 389 |
390 if (c == '\r' || c == '\n') { | 390 if (c == '\r' || c == '\n') { |
391 fragment->appendChild(HTMLBRElement::create(document()), es); | 391 fragment->appendChild(HTMLBRElement::create(document()), es); |
392 if (es.hadException()) | 392 if (es.hadException()) |
393 return 0; | 393 return 0; |
394 // Make sure \r\n doesn't result in two line breaks. | 394 // Make sure \r\n doesn't result in two line breaks. |
395 if (c == '\r' && i + 1 < length && text[i + 1] == '\n') | 395 if (c == '\r' && i + 1 < length && text[i + 1] == '\n') |
396 i++; | 396 i++; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 } | 470 } |
471 | 471 |
472 RefPtr<Node> prev = previousSibling(); | 472 RefPtr<Node> prev = previousSibling(); |
473 RefPtr<Node> next = nextSibling(); | 473 RefPtr<Node> next = nextSibling(); |
474 RefPtr<Node> newChild; | 474 RefPtr<Node> newChild; |
475 | 475 |
476 // Convert text to fragment with <br> tags instead of linebreaks if needed. | 476 // Convert text to fragment with <br> tags instead of linebreaks if needed. |
477 if (text.contains('\r') || text.contains('\n')) | 477 if (text.contains('\r') || text.contains('\n')) |
478 newChild = textToFragment(text, es); | 478 newChild = textToFragment(text, es); |
479 else | 479 else |
480 newChild = Text::create(&document(), text); | 480 newChild = Text::create(document(), text); |
481 | 481 |
482 if (!this || !parentNode()) | 482 if (!this || !parentNode()) |
483 es.throwDOMException(HierarchyRequestError); | 483 es.throwDOMException(HierarchyRequestError); |
484 if (es.hadException()) | 484 if (es.hadException()) |
485 return; | 485 return; |
486 parent->replaceChild(newChild.release(), this, es); | 486 parent->replaceChild(newChild.release(), this, es); |
487 | 487 |
488 RefPtr<Node> node = next ? next->previousSibling() : 0; | 488 RefPtr<Node> node = next ? next->previousSibling() : 0; |
489 if (!es.hadException() && node && node->isTextNode()) | 489 if (!es.hadException() && node && node->isTextNode()) |
490 mergeWithNextTextNode(node.release(), es); | 490 mergeWithNextTextNode(node.release(), es); |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 #ifndef NDEBUG | 1102 #ifndef NDEBUG |
1103 | 1103 |
1104 // For use in the debugger | 1104 // For use in the debugger |
1105 void dumpInnerHTML(WebCore::HTMLElement*); | 1105 void dumpInnerHTML(WebCore::HTMLElement*); |
1106 | 1106 |
1107 void dumpInnerHTML(WebCore::HTMLElement* element) | 1107 void dumpInnerHTML(WebCore::HTMLElement* element) |
1108 { | 1108 { |
1109 printf("%s\n", element->innerHTML().ascii().data()); | 1109 printf("%s\n", element->innerHTML().ascii().data()); |
1110 } | 1110 } |
1111 #endif | 1111 #endif |
OLD | NEW |