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

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

Issue 115693010: Fix Range.createContextualFragment for non-Element contexts. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Handle SVG elements. Created 7 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/core/editing/markup.h ('k') | Source/core/html/HTMLDocument.h » ('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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "core/editing/VisibleSelection.h" 50 #include "core/editing/VisibleSelection.h"
51 #include "core/editing/VisibleUnits.h" 51 #include "core/editing/VisibleUnits.h"
52 #include "core/editing/htmlediting.h" 52 #include "core/editing/htmlediting.h"
53 #include "core/html/HTMLBodyElement.h" 53 #include "core/html/HTMLBodyElement.h"
54 #include "core/html/HTMLElement.h" 54 #include "core/html/HTMLElement.h"
55 #include "core/html/HTMLHtmlElement.h" 55 #include "core/html/HTMLHtmlElement.h"
56 #include "core/html/HTMLTableElement.h" 56 #include "core/html/HTMLTableElement.h"
57 #include "core/html/HTMLTextFormControlElement.h" 57 #include "core/html/HTMLTextFormControlElement.h"
58 #include "core/frame/Frame.h" 58 #include "core/frame/Frame.h"
59 #include "core/rendering/RenderObject.h" 59 #include "core/rendering/RenderObject.h"
60 #include "core/svg/SVGElement.h"
60 #include "platform/weborigin/KURL.h" 61 #include "platform/weborigin/KURL.h"
61 #include "wtf/StdLibExtras.h" 62 #include "wtf/StdLibExtras.h"
62 #include "wtf/text/StringBuilder.h" 63 #include "wtf/text/StringBuilder.h"
63 64
64 using namespace std; 65 using namespace std;
65 66
66 namespace WebCore { 67 namespace WebCore {
67 68
68 using namespace HTMLNames; 69 using namespace HTMLNames;
69 70
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 if (isHTMLHtmlElement(node.get()) || node->hasTagName(headTag) || node-> hasTagName(bodyTag)) { 1019 if (isHTMLHtmlElement(node.get()) || node->hasTagName(headTag) || node-> hasTagName(bodyTag)) {
1019 HTMLElement* element = toHTMLElement(node); 1020 HTMLElement* element = toHTMLElement(node);
1020 if (Node* firstChild = element->firstChild()) 1021 if (Node* firstChild = element->firstChild())
1021 nextNode = firstChild; 1022 nextNode = firstChild;
1022 removeElementPreservingChildren(fragment, element); 1023 removeElementPreservingChildren(fragment, element);
1023 } 1024 }
1024 } 1025 }
1025 return fragment.release(); 1026 return fragment.release();
1026 } 1027 }
1027 1028
1029 PassRefPtr<DocumentFragment> createContextualFragment(const String& markup, SVGE lement* element, ParserContentPolicy parserContentPolicy, ExceptionState& except ionState)
1030 {
1031 ASSERT(element);
1032
1033 RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(markup, element, parserContentPolicy, "createContextualFragment", exceptionState);
1034 if (!fragment)
1035 return 0;
1036 return fragment.release();
1037 }
1038
1028 void replaceChildrenWithFragment(ContainerNode* container, PassRefPtr<DocumentFr agment> fragment, ExceptionState& exceptionState) 1039 void replaceChildrenWithFragment(ContainerNode* container, PassRefPtr<DocumentFr agment> fragment, ExceptionState& exceptionState)
1029 { 1040 {
1030 ASSERT(container); 1041 ASSERT(container);
1031 RefPtr<ContainerNode> containerNode(container); 1042 RefPtr<ContainerNode> containerNode(container);
1032 1043
1033 ChildListMutationScope mutation(*containerNode); 1044 ChildListMutationScope mutation(*containerNode);
1034 1045
1035 if (!fragment->firstChild()) { 1046 if (!fragment->firstChild()) {
1036 containerNode->removeChildren(); 1047 containerNode->removeChildren();
1037 return; 1048 return;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 return; 1093 return;
1083 1094
1084 RefPtr<Text> textNode = toText(node.get()); 1095 RefPtr<Text> textNode = toText(node.get());
1085 RefPtr<Text> textNext = toText(next); 1096 RefPtr<Text> textNext = toText(next);
1086 textNode->appendData(textNext->data()); 1097 textNode->appendData(textNext->data());
1087 if (textNext->parentNode()) // Might have been removed by mutation event. 1098 if (textNext->parentNode()) // Might have been removed by mutation event.
1088 textNext->remove(exceptionState); 1099 textNext->remove(exceptionState);
1089 } 1100 }
1090 1101
1091 } 1102 }
OLDNEW
« no previous file with comments | « Source/core/editing/markup.h ('k') | Source/core/html/HTMLDocument.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698