| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. |
| 4 * Copyright (C) 2011 Igalia S.L. | 4 * Copyright (C) 2011 Igalia S.L. |
| 5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 | 745 |
| 746 static void fillContainerFromString(ContainerNode* paragraph, const String& stri
ng) | 746 static void fillContainerFromString(ContainerNode* paragraph, const String& stri
ng) |
| 747 { | 747 { |
| 748 Document& document = paragraph->document(); | 748 Document& document = paragraph->document(); |
| 749 | 749 |
| 750 if (string.isEmpty()) { | 750 if (string.isEmpty()) { |
| 751 paragraph->appendChild(createBlockPlaceholderElement(document)); | 751 paragraph->appendChild(createBlockPlaceholderElement(document)); |
| 752 return; | 752 return; |
| 753 } | 753 } |
| 754 | 754 |
| 755 ASSERT(string.find('\n') == notFound); | 755 ASSERT(string.find('\n') == kNotFound); |
| 756 | 756 |
| 757 Vector<String> tabList; | 757 Vector<String> tabList; |
| 758 string.split('\t', true, tabList); | 758 string.split('\t', true, tabList); |
| 759 String tabText = emptyString(); | 759 String tabText = emptyString(); |
| 760 bool first = true; | 760 bool first = true; |
| 761 size_t numEntries = tabList.size(); | 761 size_t numEntries = tabList.size(); |
| 762 for (size_t i = 0; i < numEntries; ++i) { | 762 for (size_t i = 0; i < numEntries; ++i) { |
| 763 const String& s = tabList[i]; | 763 const String& s = tabList[i]; |
| 764 | 764 |
| 765 // append the non-tab textual part | 765 // append the non-tab textual part |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 fragment->appendChild(document.createTextNode(string)); | 828 fragment->appendChild(document.createTextNode(string)); |
| 829 if (string.endsWith('\n')) { | 829 if (string.endsWith('\n')) { |
| 830 RefPtr<Element> element = createBreakElement(document); | 830 RefPtr<Element> element = createBreakElement(document); |
| 831 element->setAttribute(classAttr, AppleInterchangeNewline); | 831 element->setAttribute(classAttr, AppleInterchangeNewline); |
| 832 fragment->appendChild(element.release()); | 832 fragment->appendChild(element.release()); |
| 833 } | 833 } |
| 834 return fragment.release(); | 834 return fragment.release(); |
| 835 } | 835 } |
| 836 | 836 |
| 837 // A string with no newlines gets added inline, rather than being put into a
paragraph. | 837 // A string with no newlines gets added inline, rather than being put into a
paragraph. |
| 838 if (string.find('\n') == notFound) { | 838 if (string.find('\n') == kNotFound) { |
| 839 fillContainerFromString(fragment.get(), string); | 839 fillContainerFromString(fragment.get(), string); |
| 840 return fragment.release(); | 840 return fragment.release(); |
| 841 } | 841 } |
| 842 | 842 |
| 843 // Break string into paragraphs. Extra line breaks turn into empty paragraph
s. | 843 // Break string into paragraphs. Extra line breaks turn into empty paragraph
s. |
| 844 Node* blockNode = enclosingBlock(context->firstNode()); | 844 Node* blockNode = enclosingBlock(context->firstNode()); |
| 845 Element* block = toElement(blockNode); | 845 Element* block = toElement(blockNode); |
| 846 bool useClonesOfEnclosingBlock = blockNode | 846 bool useClonesOfEnclosingBlock = blockNode |
| 847 && blockNode->isElementNode() | 847 && blockNode->isElementNode() |
| 848 && !block->hasTagName(bodyTag) | 848 && !block->hasTagName(bodyTag) |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 if (containerNode->hasOneChild()) { | 1068 if (containerNode->hasOneChild()) { |
| 1069 containerNode->replaceChild(textNode.release(), containerNode->firstChil
d(), es); | 1069 containerNode->replaceChild(textNode.release(), containerNode->firstChil
d(), es); |
| 1070 return; | 1070 return; |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 containerNode->removeChildren(); | 1073 containerNode->removeChildren(); |
| 1074 containerNode->appendChild(textNode.release(), es); | 1074 containerNode->appendChild(textNode.release(), es); |
| 1075 } | 1075 } |
| 1076 | 1076 |
| 1077 } | 1077 } |
| OLD | NEW |