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

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: Addressed feedback. Created 6 years, 6 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
« Source/core/dom/Range.cpp ('K') | « Source/core/editing/markup.h ('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 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 { 968 {
969 RefPtr<Node> nextChild; 969 RefPtr<Node> nextChild;
970 for (RefPtr<Node> child = element->firstChild(); child; child = nextChild) { 970 for (RefPtr<Node> child = element->firstChild(); child; child = nextChild) {
971 nextChild = child->nextSibling(); 971 nextChild = child->nextSibling();
972 element->removeChild(child.get()); 972 element->removeChild(child.get());
973 fragment->insertBefore(child, element); 973 fragment->insertBefore(child, element);
974 } 974 }
975 fragment->removeChild(element); 975 fragment->removeChild(element);
976 } 976 }
977 977
978 PassRefPtrWillBeRawPtr<DocumentFragment> createContextualFragment(const String& markup, HTMLElement* element, ParserContentPolicy parserContentPolicy, Exception State& exceptionState) 978 PassRefPtrWillBeRawPtr<DocumentFragment> createContextualFragment(const String& markup, Element* element, ParserContentPolicy parserContentPolicy, ExceptionStat e& exceptionState)
979 { 979 {
980 ASSERT(element); 980 ASSERT(element);
981 if (element->ieForbidsInsertHTML() || element->hasLocalName(colTag) || eleme nt->hasLocalName(colgroupTag) || element->hasLocalName(framesetTag) 981 if (element->isHTMLElement()) {
982 || element->hasLocalName(headTag) || element->hasLocalName(styleTag) || element->hasLocalName(titleTag)) { 982 HTMLElement* htmlElement = toHTMLElement(element);
983 exceptionState.throwDOMException(NotSupportedError, "The range's contain er is '" + element->localName() + "', which is not supported."); 983 if (htmlElement->ieForbidsInsertHTML() || htmlElement->hasLocalName(colT ag) || htmlElement->hasLocalName(colgroupTag) || htmlElement->hasLocalName(frame setTag)
eseidel 2014/06/02 16:51:28 I probably would have pulled this into a little he
pwnall-personal 2014/06/03 00:09:01 Done. Thank you!
984 return nullptr; 984 || htmlElement->hasLocalName(headTag) || htmlElement->hasLocalName(s tyleTag) || htmlElement->hasLocalName(titleTag)) {
985 exceptionState.throwDOMException(NotSupportedError, "The range's con tainer is '" + htmlElement->localName() + "', which is not supported.");
986 return nullptr;
987 }
985 } 988 }
986 989
987 RefPtrWillBeRawPtr<DocumentFragment> fragment = createFragmentForInnerOuterH TML(markup, element, parserContentPolicy, "createContextualFragment", exceptionS tate); 990 RefPtrWillBeRawPtr<DocumentFragment> fragment = createFragmentForInnerOuterH TML(markup, element, parserContentPolicy, "createContextualFragment", exceptionS tate);
988 if (!fragment) 991 if (!fragment)
989 return nullptr; 992 return nullptr;
990 993
991 // We need to pop <html> and <body> elements and remove <head> to 994 // We need to pop <html> and <body> elements and remove <head> to
992 // accommodate folks passing complete HTML documents to make the 995 // accommodate folks passing complete HTML documents to make the
993 // child of an element. 996 // child of an element.
994 997
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 return; 1079 return;
1077 1080
1078 RefPtrWillBeRawPtr<Text> textNode = toText(node.get()); 1081 RefPtrWillBeRawPtr<Text> textNode = toText(node.get());
1079 RefPtrWillBeRawPtr<Text> textNext = toText(next); 1082 RefPtrWillBeRawPtr<Text> textNext = toText(next);
1080 textNode->appendData(textNext->data()); 1083 textNode->appendData(textNext->data());
1081 if (textNext->parentNode()) // Might have been removed by mutation event. 1084 if (textNext->parentNode()) // Might have been removed by mutation event.
1082 textNext->remove(exceptionState); 1085 textNext->remove(exceptionState);
1083 } 1086 }
1084 1087
1085 } 1088 }
OLDNEW
« Source/core/dom/Range.cpp ('K') | « Source/core/editing/markup.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698