OLD | NEW |
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 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 { | 969 { |
970 RefPtrWillBeRawPtr<Node> nextChild = nullptr; | 970 RefPtrWillBeRawPtr<Node> nextChild = nullptr; |
971 for (RefPtrWillBeRawPtr<Node> child = element->firstChild(); child; child =
nextChild) { | 971 for (RefPtrWillBeRawPtr<Node> child = element->firstChild(); child; child =
nextChild) { |
972 nextChild = child->nextSibling(); | 972 nextChild = child->nextSibling(); |
973 element->removeChild(child.get()); | 973 element->removeChild(child.get()); |
974 fragment->insertBefore(child, element); | 974 fragment->insertBefore(child, element); |
975 } | 975 } |
976 fragment->removeChild(element); | 976 fragment->removeChild(element); |
977 } | 977 } |
978 | 978 |
979 PassRefPtrWillBeRawPtr<DocumentFragment> createContextualFragment(const String&
markup, HTMLElement* element, ParserContentPolicy parserContentPolicy, Exception
State& exceptionState) | 979 static inline bool isSupportedContainer(Element* element) |
980 { | 980 { |
981 ASSERT(element); | 981 ASSERT(element); |
982 if (element->ieForbidsInsertHTML() || element->hasLocalName(colTag) || eleme
nt->hasLocalName(colgroupTag) || element->hasLocalName(framesetTag) | 982 if (!element->isHTMLElement()) |
| 983 return true; |
| 984 |
| 985 if (element->hasLocalName(colTag) || element->hasLocalName(colgroupTag) || e
lement->hasLocalName(framesetTag) |
983 || element->hasLocalName(headTag) || element->hasLocalName(styleTag) ||
element->hasLocalName(titleTag)) { | 986 || element->hasLocalName(headTag) || element->hasLocalName(styleTag) ||
element->hasLocalName(titleTag)) { |
| 987 return false; |
| 988 } |
| 989 return !toHTMLElement(element)->ieForbidsInsertHTML(); |
| 990 } |
| 991 |
| 992 PassRefPtrWillBeRawPtr<DocumentFragment> createContextualFragment(const String&
markup, Element* element, ParserContentPolicy parserContentPolicy, ExceptionStat
e& exceptionState) |
| 993 { |
| 994 ASSERT(element); |
| 995 if (!isSupportedContainer(element)) { |
984 exceptionState.throwDOMException(NotSupportedError, "The range's contain
er is '" + element->localName() + "', which is not supported."); | 996 exceptionState.throwDOMException(NotSupportedError, "The range's contain
er is '" + element->localName() + "', which is not supported."); |
985 return nullptr; | 997 return nullptr; |
986 } | 998 } |
987 | 999 |
988 RefPtrWillBeRawPtr<DocumentFragment> fragment = createFragmentForInnerOuterH
TML(markup, element, parserContentPolicy, "createContextualFragment", exceptionS
tate); | 1000 RefPtrWillBeRawPtr<DocumentFragment> fragment = createFragmentForInnerOuterH
TML(markup, element, parserContentPolicy, "createContextualFragment", exceptionS
tate); |
989 if (!fragment) | 1001 if (!fragment) |
990 return nullptr; | 1002 return nullptr; |
991 | 1003 |
992 // We need to pop <html> and <body> elements and remove <head> to | 1004 // We need to pop <html> and <body> elements and remove <head> to |
993 // accommodate folks passing complete HTML documents to make the | 1005 // accommodate folks passing complete HTML documents to make the |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 return; | 1089 return; |
1078 | 1090 |
1079 RefPtrWillBeRawPtr<Text> textNode = toText(node.get()); | 1091 RefPtrWillBeRawPtr<Text> textNode = toText(node.get()); |
1080 RefPtrWillBeRawPtr<Text> textNext = toText(next); | 1092 RefPtrWillBeRawPtr<Text> textNext = toText(next); |
1081 textNode->appendData(textNext->data()); | 1093 textNode->appendData(textNext->data()); |
1082 if (textNext->parentNode()) // Might have been removed by mutation event. | 1094 if (textNext->parentNode()) // Might have been removed by mutation event. |
1083 textNext->remove(exceptionState); | 1095 textNext->remove(exceptionState); |
1084 } | 1096 } |
1085 | 1097 |
1086 } | 1098 } |
OLD | NEW |