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 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 taggedMarkup.append(markup.substring(fragmentStart, fragmentEnd - fragmentSt
art)); | 703 taggedMarkup.append(markup.substring(fragmentStart, fragmentEnd - fragmentSt
art)); |
704 MarkupAccumulator::appendComment(taggedMarkup, fragmentMarkerTag); | 704 MarkupAccumulator::appendComment(taggedMarkup, fragmentMarkerTag); |
705 taggedMarkup.append(markup.substring(fragmentEnd)); | 705 taggedMarkup.append(markup.substring(fragmentEnd)); |
706 | 706 |
707 RefPtr<DocumentFragment> taggedFragment = createFragmentFromMarkup(document,
taggedMarkup.toString(), baseURL, parserContentPolicy); | 707 RefPtr<DocumentFragment> taggedFragment = createFragmentFromMarkup(document,
taggedMarkup.toString(), baseURL, parserContentPolicy); |
708 RefPtr<Document> taggedDocument = Document::create(); | 708 RefPtr<Document> taggedDocument = Document::create(); |
709 taggedDocument->setContextFeatures(document.contextFeatures()); | 709 taggedDocument->setContextFeatures(document.contextFeatures()); |
710 | 710 |
711 // FIXME: It's not clear what this code is trying to do. It puts nodes as di
rect children of a | 711 // FIXME: It's not clear what this code is trying to do. It puts nodes as di
rect children of a |
712 // Document that are not normally allowed by using the parser machinery. | 712 // Document that are not normally allowed by using the parser machinery. |
713 taggedDocument->parserTakeAllChildrenFrom(taggedFragment.get()); | 713 taggedDocument->parserTakeAllChildrenFrom(*taggedFragment); |
714 | 714 |
715 RefPtr<Node> nodeBeforeContext; | 715 RefPtr<Node> nodeBeforeContext; |
716 RefPtr<Node> nodeAfterContext; | 716 RefPtr<Node> nodeAfterContext; |
717 if (!findNodesSurroundingContext(taggedDocument.get(), nodeBeforeContext, no
deAfterContext)) | 717 if (!findNodesSurroundingContext(taggedDocument.get(), nodeBeforeContext, no
deAfterContext)) |
718 return 0; | 718 return 0; |
719 | 719 |
720 RefPtr<Range> range = Range::create(*taggedDocument.get(), | 720 RefPtr<Range> range = Range::create(*taggedDocument.get(), |
721 positionAfterNode(nodeBeforeContext.get()).parentAnchoredEquivalent(), | 721 positionAfterNode(nodeBeforeContext.get()).parentAnchoredEquivalent(), |
722 positionBeforeNode(nodeAfterContext.get()).parentAnchoredEquivalent()); | 722 positionBeforeNode(nodeAfterContext.get()).parentAnchoredEquivalent()); |
723 | 723 |
724 Node* commonAncestor = range->commonAncestorContainer(ASSERT_NO_EXCEPTION); | 724 Node* commonAncestor = range->commonAncestorContainer(ASSERT_NO_EXCEPTION); |
725 Node* specialCommonAncestor = ancestorToRetainStructureAndAppearanceWithNoRe
nderer(commonAncestor); | 725 Node* specialCommonAncestor = ancestorToRetainStructureAndAppearanceWithNoRe
nderer(commonAncestor); |
726 | 726 |
727 // When there's a special common ancestor outside of the fragment, we must i
nclude it as well to | 727 // When there's a special common ancestor outside of the fragment, we must i
nclude it as well to |
728 // preserve the structure and appearance of the fragment. For example, if th
e fragment contains | 728 // preserve the structure and appearance of the fragment. For example, if th
e fragment contains |
729 // TD, we need to include the enclosing TABLE tag as well. | 729 // TD, we need to include the enclosing TABLE tag as well. |
730 RefPtr<DocumentFragment> fragment = DocumentFragment::create(document); | 730 RefPtr<DocumentFragment> fragment = DocumentFragment::create(document); |
731 if (specialCommonAncestor) | 731 if (specialCommonAncestor) |
732 fragment->appendChild(specialCommonAncestor); | 732 fragment->appendChild(specialCommonAncestor); |
733 else | 733 else |
734 fragment->parserTakeAllChildrenFrom(toContainerNode(commonAncestor)); | 734 fragment->parserTakeAllChildrenFrom(toContainerNode(*commonAncestor)); |
735 | 735 |
736 trimFragment(fragment.get(), nodeBeforeContext.get(), nodeAfterContext.get()
); | 736 trimFragment(fragment.get(), nodeBeforeContext.get(), nodeAfterContext.get()
); |
737 | 737 |
738 return fragment; | 738 return fragment; |
739 } | 739 } |
740 | 740 |
741 String createMarkup(const Node* node, EChildrenOnly childrenOnly, Vector<Node*>*
nodes, EAbsoluteURLs shouldResolveURLs, Vector<QualifiedName>* tagNamesToSkip) | 741 String createMarkup(const Node* node, EChildrenOnly childrenOnly, Vector<Node*>*
nodes, EAbsoluteURLs shouldResolveURLs, Vector<QualifiedName>* tagNamesToSkip) |
742 { | 742 { |
743 if (!node) | 743 if (!node) |
744 return ""; | 744 return ""; |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 return; | 1083 return; |
1084 | 1084 |
1085 RefPtr<Text> textNode = toText(node.get()); | 1085 RefPtr<Text> textNode = toText(node.get()); |
1086 RefPtr<Text> textNext = toText(next); | 1086 RefPtr<Text> textNext = toText(next); |
1087 textNode->appendData(textNext->data()); | 1087 textNode->appendData(textNext->data()); |
1088 if (textNext->parentNode()) // Might have been removed by mutation event. | 1088 if (textNext->parentNode()) // Might have been removed by mutation event. |
1089 textNext->remove(es); | 1089 textNext->remove(es); |
1090 } | 1090 } |
1091 | 1091 |
1092 } | 1092 } |
OLD | NEW |