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

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

Issue 23513013: Have Text constructor take a Document reference in argument (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/SplitTextNodeCommand.cpp ('k') | Source/core/html/BaseButtonInputType.cpp » ('j') | 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 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 RefPtr<DocumentFragment> fragment = outputDoc.createDocumentFragment(); 962 RefPtr<DocumentFragment> fragment = outputDoc.createDocumentFragment();
963 963
964 if (sourceMIMEType == "text/html") { 964 if (sourceMIMEType == "text/html") {
965 // As far as I can tell, there isn't a spec for how transformToFragment is supposed to work. 965 // As far as I can tell, there isn't a spec for how transformToFragment is supposed to work.
966 // Based on the documentation I can find, it looks like we want to start parsing the fragment in the InBody insertion mode. 966 // Based on the documentation I can find, it looks like we want to start parsing the fragment in the InBody insertion mode.
967 // Unfortunately, that's an implementation detail of the parser. 967 // Unfortunately, that's an implementation detail of the parser.
968 // We achieve that effect here by passing in a fake body element as cont ext for the fragment. 968 // We achieve that effect here by passing in a fake body element as cont ext for the fragment.
969 RefPtr<HTMLBodyElement> fakeBody = HTMLBodyElement::create(outputDoc); 969 RefPtr<HTMLBodyElement> fakeBody = HTMLBodyElement::create(outputDoc);
970 fragment->parseHTML(sourceString, fakeBody.get()); 970 fragment->parseHTML(sourceString, fakeBody.get());
971 } else if (sourceMIMEType == "text/plain") { 971 } else if (sourceMIMEType == "text/plain") {
972 fragment->parserAppendChild(Text::create(&outputDoc, sourceString)); 972 fragment->parserAppendChild(Text::create(outputDoc, sourceString));
973 } else { 973 } else {
974 bool successfulParse = fragment->parseXML(sourceString, 0); 974 bool successfulParse = fragment->parseXML(sourceString, 0);
975 if (!successfulParse) 975 if (!successfulParse)
976 return 0; 976 return 0;
977 } 977 }
978 978
979 // FIXME: Do we need to mess with URLs here? 979 // FIXME: Do we need to mess with URLs here?
980 980
981 return fragment.release(); 981 return fragment.release();
982 } 982 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 { 1056 {
1057 RefPtr<ContainerNode> containerNode(container); 1057 RefPtr<ContainerNode> containerNode(container);
1058 1058
1059 ChildListMutationScope mutation(containerNode.get()); 1059 ChildListMutationScope mutation(containerNode.get());
1060 1060
1061 if (containerNode->hasOneTextChild()) { 1061 if (containerNode->hasOneTextChild()) {
1062 toText(containerNode->firstChild())->setData(text); 1062 toText(containerNode->firstChild())->setData(text);
1063 return; 1063 return;
1064 } 1064 }
1065 1065
1066 RefPtr<Text> textNode = Text::create(&containerNode->document(), text); 1066 RefPtr<Text> textNode = Text::create(containerNode->document(), text);
1067 1067
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 }
OLDNEW
« no previous file with comments | « Source/core/editing/SplitTextNodeCommand.cpp ('k') | Source/core/html/BaseButtonInputType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698