| 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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 static void trimFragment(DocumentFragment* fragment, Node* nodeBeforeContext, No
de* nodeAfterContext) | 675 static void trimFragment(DocumentFragment* fragment, Node* nodeBeforeContext, No
de* nodeAfterContext) |
| 676 { | 676 { |
| 677 RefPtr<Node> next; | 677 RefPtr<Node> next; |
| 678 for (RefPtr<Node> node = fragment->firstChild(); node; node = next) { | 678 for (RefPtr<Node> node = fragment->firstChild(); node; node = next) { |
| 679 if (nodeBeforeContext->isDescendantOf(node.get())) { | 679 if (nodeBeforeContext->isDescendantOf(node.get())) { |
| 680 next = NodeTraversal::next(node.get()); | 680 next = NodeTraversal::next(node.get()); |
| 681 continue; | 681 continue; |
| 682 } | 682 } |
| 683 next = NodeTraversal::nextSkippingChildren(node.get()); | 683 next = NodeTraversal::nextSkippingChildren(node.get()); |
| 684 ASSERT(!node->contains(nodeAfterContext)); | 684 ASSERT(!node->contains(nodeAfterContext)); |
| 685 node->parentNode()->removeChild(node.get(), ASSERT_NO_EXCEPTION); | 685 node->parentNode()->removeChild(node.get()); |
| 686 if (nodeBeforeContext == node) | 686 if (nodeBeforeContext == node) |
| 687 break; | 687 break; |
| 688 } | 688 } |
| 689 | 689 |
| 690 ASSERT(nodeAfterContext->parentNode()); | 690 ASSERT(nodeAfterContext->parentNode()); |
| 691 for (RefPtr<Node> node = nodeAfterContext; node; node = next) { | 691 for (RefPtr<Node> node = nodeAfterContext; node; node = next) { |
| 692 next = NodeTraversal::nextSkippingChildren(node.get()); | 692 next = NodeTraversal::nextSkippingChildren(node.get()); |
| 693 node->parentNode()->removeChild(node.get(), ASSERT_NO_EXCEPTION); | 693 node->parentNode()->removeChild(node.get()); |
| 694 } | 694 } |
| 695 } | 695 } |
| 696 | 696 |
| 697 PassRefPtr<DocumentFragment> createFragmentFromMarkupWithContext(Document* docum
ent, const String& markup, unsigned fragmentStart, unsigned fragmentEnd, | 697 PassRefPtr<DocumentFragment> createFragmentFromMarkupWithContext(Document* docum
ent, const String& markup, unsigned fragmentStart, unsigned fragmentEnd, |
| 698 const String& baseURL, ParserContentPolicy parserContentPolicy) | 698 const String& baseURL, ParserContentPolicy parserContentPolicy) |
| 699 { | 699 { |
| 700 // FIXME: Need to handle the case where the markup already contains these ma
rkers. | 700 // FIXME: Need to handle the case where the markup already contains these ma
rkers. |
| 701 | 701 |
| 702 StringBuilder taggedMarkup; | 702 StringBuilder taggedMarkup; |
| 703 taggedMarkup.append(markup.left(fragmentStart)); | 703 taggedMarkup.append(markup.left(fragmentStart)); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 // FIXME: Do we need to mess with URLs here? | 983 // FIXME: Do we need to mess with URLs here? |
| 984 | 984 |
| 985 return fragment.release(); | 985 return fragment.release(); |
| 986 } | 986 } |
| 987 | 987 |
| 988 static inline void removeElementPreservingChildren(PassRefPtr<DocumentFragment>
fragment, HTMLElement* element) | 988 static inline void removeElementPreservingChildren(PassRefPtr<DocumentFragment>
fragment, HTMLElement* element) |
| 989 { | 989 { |
| 990 RefPtr<Node> nextChild; | 990 RefPtr<Node> nextChild; |
| 991 for (RefPtr<Node> child = element->firstChild(); child; child = nextChild) { | 991 for (RefPtr<Node> child = element->firstChild(); child; child = nextChild) { |
| 992 nextChild = child->nextSibling(); | 992 nextChild = child->nextSibling(); |
| 993 element->removeChild(child.get(), ASSERT_NO_EXCEPTION); | 993 element->removeChild(child.get()); |
| 994 fragment->insertBefore(child, element, ASSERT_NO_EXCEPTION); | 994 fragment->insertBefore(child, element, ASSERT_NO_EXCEPTION); |
| 995 } | 995 } |
| 996 fragment->removeChild(element, ASSERT_NO_EXCEPTION); | 996 fragment->removeChild(element); |
| 997 } | 997 } |
| 998 | 998 |
| 999 PassRefPtr<DocumentFragment> createContextualFragment(const String& markup, HTML
Element* element, ParserContentPolicy parserContentPolicy, ExceptionCode& ec) | 999 PassRefPtr<DocumentFragment> createContextualFragment(const String& markup, HTML
Element* element, ParserContentPolicy parserContentPolicy, ExceptionCode& ec) |
| 1000 { | 1000 { |
| 1001 ASSERT(element); | 1001 ASSERT(element); |
| 1002 if (element->ieForbidsInsertHTML()) { | 1002 if (element->ieForbidsInsertHTML()) { |
| 1003 ec = NotSupportedError; | 1003 ec = NotSupportedError; |
| 1004 return 0; | 1004 return 0; |
| 1005 } | 1005 } |
| 1006 | 1006 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 if (hasOneChild(containerNode.get())) { | 1083 if (hasOneChild(containerNode.get())) { |
| 1084 containerNode->replaceChild(textNode.release(), containerNode->firstChil
d(), ec); | 1084 containerNode->replaceChild(textNode.release(), containerNode->firstChil
d(), ec); |
| 1085 return; | 1085 return; |
| 1086 } | 1086 } |
| 1087 | 1087 |
| 1088 containerNode->removeChildren(); | 1088 containerNode->removeChildren(); |
| 1089 containerNode->appendChild(textNode.release(), ec); | 1089 containerNode->appendChild(textNode.release(), ec); |
| 1090 } | 1090 } |
| 1091 | 1091 |
| 1092 } | 1092 } |
| OLD | NEW |