Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: Source/WebCore/editing/markup.cpp

Issue 8907027: Line breaks are lost when pasted into textarea text starting with a blank line set while textarea... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/963/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/WebCore/ChangeLog ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "CSSValue.h" 42 #include "CSSValue.h"
43 #include "CSSValueKeywords.h" 43 #include "CSSValueKeywords.h"
44 #include "DeleteButtonController.h" 44 #include "DeleteButtonController.h"
45 #include "DocumentFragment.h" 45 #include "DocumentFragment.h"
46 #include "DocumentType.h" 46 #include "DocumentType.h"
47 #include "Editor.h" 47 #include "Editor.h"
48 #include "Frame.h" 48 #include "Frame.h"
49 #include "HTMLBodyElement.h" 49 #include "HTMLBodyElement.h"
50 #include "HTMLElement.h" 50 #include "HTMLElement.h"
51 #include "HTMLNames.h" 51 #include "HTMLNames.h"
52 #include "HTMLTextFormControlElement.h"
52 #include "KURL.h" 53 #include "KURL.h"
53 #include "MarkupAccumulator.h" 54 #include "MarkupAccumulator.h"
54 #include "Range.h" 55 #include "Range.h"
55 #include "RenderObject.h" 56 #include "RenderObject.h"
56 #include "TextIterator.h" 57 #include "TextIterator.h"
57 #include "VisibleSelection.h" 58 #include "VisibleSelection.h"
58 #include "XMLNSNames.h" 59 #include "XMLNSNames.h"
59 #include "htmlediting.h" 60 #include "htmlediting.h"
60 #include "visible_units.h" 61 #include "visible_units.h"
61 #include <wtf/StdLibExtras.h> 62 #include <wtf/StdLibExtras.h>
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 } 874 }
874 875
875 // Break string into paragraphs. Extra line breaks turn into empty paragraph s. 876 // Break string into paragraphs. Extra line breaks turn into empty paragraph s.
876 Node* blockNode = enclosingBlock(context->firstNode()); 877 Node* blockNode = enclosingBlock(context->firstNode());
877 Element* block = static_cast<Element*>(blockNode); 878 Element* block = static_cast<Element*>(blockNode);
878 bool useClonesOfEnclosingBlock = blockNode 879 bool useClonesOfEnclosingBlock = blockNode
879 && blockNode->isElementNode() 880 && blockNode->isElementNode()
880 && !block->hasTagName(bodyTag) 881 && !block->hasTagName(bodyTag)
881 && !block->hasTagName(htmlTag) 882 && !block->hasTagName(htmlTag)
882 && block != editableRootForPosition(context->startPosition()); 883 && block != editableRootForPosition(context->startPosition());
883 884 bool useLineBreak = enclosingTextFormControl(context->startPosition());
885
884 Vector<String> list; 886 Vector<String> list;
885 string.split('\n', true, list); // true gets us empty strings in the list 887 string.split('\n', true, list); // true gets us empty strings in the list
886 size_t numLines = list.size(); 888 size_t numLines = list.size();
887 for (size_t i = 0; i < numLines; ++i) { 889 for (size_t i = 0; i < numLines; ++i) {
888 const String& s = list[i]; 890 const String& s = list[i];
889 891
890 RefPtr<Element> element; 892 RefPtr<Element> element;
891 if (s.isEmpty() && i + 1 == numLines) { 893 if (s.isEmpty() && i + 1 == numLines) {
892 // For last line, use the "magic BR" rather than a P. 894 // For last line, use the "magic BR" rather than a P.
893 element = createBreakElement(document); 895 element = createBreakElement(document);
894 element->setAttribute(classAttr, AppleInterchangeNewline); 896 element->setAttribute(classAttr, AppleInterchangeNewline);
897 } else if (useLineBreak) {
898 element = createBreakElement(document);
899 fillContainerFromString(fragment.get(), s);
895 } else { 900 } else {
896 if (useClonesOfEnclosingBlock) 901 if (useClonesOfEnclosingBlock)
897 element = block->cloneElementWithoutChildren(); 902 element = block->cloneElementWithoutChildren();
898 else 903 else
899 element = createDefaultParagraphElement(document); 904 element = createDefaultParagraphElement(document);
900 fillContainerFromString(element.get(), s); 905 fillContainerFromString(element.get(), s);
901 } 906 }
902 fragment->appendChild(element.release(), ec); 907 fragment->appendChild(element.release(), ec);
903 ASSERT(!ec); 908 ASSERT(!ec);
904 } 909 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 StringBuilder markup; 985 StringBuilder markup;
981 markup.append("<a href=\""); 986 markup.append("<a href=\"");
982 markup.append(url.string()); 987 markup.append(url.string());
983 markup.append("\">"); 988 markup.append("\">");
984 appendCharactersReplacingEntities(markup, title.characters(), title.length() , EntityMaskInPCDATA); 989 appendCharactersReplacingEntities(markup, title.characters(), title.length() , EntityMaskInPCDATA);
985 markup.append("</a>"); 990 markup.append("</a>");
986 return markup.toString(); 991 return markup.toString();
987 } 992 }
988 993
989 } 994 }
OLDNEW
« no previous file with comments | « Source/WebCore/ChangeLog ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698