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

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

Issue 9008054: Merge 102392 - Line breaks are lost when pasted into textarea text starting with a blank line set... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/912/
Patch Set: Created 8 years, 11 months 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 | « LayoutTests/editing/input/paste-linebreak-into-initially-hidden-textarea-expected.txt ('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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 } 911 }
911 912
912 // Break string into paragraphs. Extra line breaks turn into empty paragraph s. 913 // Break string into paragraphs. Extra line breaks turn into empty paragraph s.
913 Node* blockNode = enclosingBlock(context->firstNode()); 914 Node* blockNode = enclosingBlock(context->firstNode());
914 Element* block = static_cast<Element*>(blockNode); 915 Element* block = static_cast<Element*>(blockNode);
915 bool useClonesOfEnclosingBlock = blockNode 916 bool useClonesOfEnclosingBlock = blockNode
916 && blockNode->isElementNode() 917 && blockNode->isElementNode()
917 && !block->hasTagName(bodyTag) 918 && !block->hasTagName(bodyTag)
918 && !block->hasTagName(htmlTag) 919 && !block->hasTagName(htmlTag)
919 && block != editableRootForPosition(context->startPosition()); 920 && block != editableRootForPosition(context->startPosition());
920 921 bool useLineBreak = enclosingTextFormControl(context->startPosition());
922
921 Vector<String> list; 923 Vector<String> list;
922 string.split('\n', true, list); // true gets us empty strings in the list 924 string.split('\n', true, list); // true gets us empty strings in the list
923 size_t numLines = list.size(); 925 size_t numLines = list.size();
924 for (size_t i = 0; i < numLines; ++i) { 926 for (size_t i = 0; i < numLines; ++i) {
925 const String& s = list[i]; 927 const String& s = list[i];
926 928
927 RefPtr<Element> element; 929 RefPtr<Element> element;
928 if (s.isEmpty() && i + 1 == numLines) { 930 if (s.isEmpty() && i + 1 == numLines) {
929 // For last line, use the "magic BR" rather than a P. 931 // For last line, use the "magic BR" rather than a P.
930 element = createBreakElement(document); 932 element = createBreakElement(document);
931 element->setAttribute(classAttr, AppleInterchangeNewline); 933 element->setAttribute(classAttr, AppleInterchangeNewline);
934 } else if (useLineBreak) {
935 element = createBreakElement(document);
936 fillContainerFromString(fragment.get(), s);
932 } else { 937 } else {
933 if (useClonesOfEnclosingBlock) 938 if (useClonesOfEnclosingBlock)
934 element = block->cloneElementWithoutChildren(); 939 element = block->cloneElementWithoutChildren();
935 else 940 else
936 element = createDefaultParagraphElement(document); 941 element = createDefaultParagraphElement(document);
937 fillContainerFromString(element.get(), s); 942 fillContainerFromString(element.get(), s);
938 } 943 }
939 fragment->appendChild(element.release(), ec); 944 fragment->appendChild(element.release(), ec);
940 ASSERT(!ec); 945 ASSERT(!ec);
941 } 946 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 StringBuilder markup; 1022 StringBuilder markup;
1018 markup.append("<a href=\""); 1023 markup.append("<a href=\"");
1019 markup.append(url.string()); 1024 markup.append(url.string());
1020 markup.append("\">"); 1025 markup.append("\">");
1021 appendCharactersReplacingEntities(markup, title.characters(), title.length() , EntityMaskInPCDATA); 1026 appendCharactersReplacingEntities(markup, title.characters(), title.length() , EntityMaskInPCDATA);
1022 markup.append("</a>"); 1027 markup.append("</a>");
1023 return markup.toString(); 1028 return markup.toString();
1024 } 1029 }
1025 1030
1026 } 1031 }
OLDNEW
« no previous file with comments | « LayoutTests/editing/input/paste-linebreak-into-initially-hidden-textarea-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698