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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 return true; | 685 return true; |
686 } | 686 } |
687 } | 687 } |
688 } | 688 } |
689 return false; | 689 return false; |
690 } | 690 } |
691 | 691 |
692 static void trimFragment(DocumentFragment* fragment, Node* nodeBeforeContext, No
de* nodeAfterContext) | 692 static void trimFragment(DocumentFragment* fragment, Node* nodeBeforeContext, No
de* nodeAfterContext) |
693 { | 693 { |
694 ExceptionCode ec = 0; | 694 ExceptionCode ec = 0; |
695 Node* next; | 695 RefPtr<Node> next; |
696 for (RefPtr<Node> node = fragment->firstChild(); node; node = next) { | 696 for (RefPtr<Node> node = fragment->firstChild(); node; node = next) { |
697 if (nodeBeforeContext->isDescendantOf(node.get())) { | 697 if (nodeBeforeContext->isDescendantOf(node.get())) { |
698 next = node->traverseNextNode(); | 698 next = node->traverseNextNode(); |
699 continue; | 699 continue; |
700 } | 700 } |
701 next = node->traverseNextSibling(); | 701 next = node->traverseNextSibling(); |
702 ASSERT(!node->contains(nodeAfterContext)); | 702 ASSERT(!node->contains(nodeAfterContext)); |
703 node->parentNode()->removeChild(node.get(), ec); | 703 node->parentNode()->removeChild(node.get(), ec); |
704 if (nodeBeforeContext == node) | 704 if (nodeBeforeContext == node) |
705 break; | 705 break; |
706 } | 706 } |
707 | 707 |
708 ASSERT(nodeAfterContext->parentNode()); | 708 ASSERT(nodeAfterContext->parentNode()); |
709 for (Node* node = nodeAfterContext; node; node = next) { | 709 for (RefPtr<Node> node = nodeAfterContext; node; node = next) { |
710 next = node->traverseNextSibling(); | 710 next = node->traverseNextSibling(); |
711 node->parentNode()->removeChild(node, ec); | 711 node->parentNode()->removeChild(node.get(), ec); |
712 ASSERT(!ec); | 712 ASSERT(!ec); |
713 } | 713 } |
714 } | 714 } |
715 | 715 |
716 PassRefPtr<DocumentFragment> createFragmentFromMarkupWithContext(Document* docum
ent, const String& markup, unsigned fragmentStart, unsigned fragmentEnd, | 716 PassRefPtr<DocumentFragment> createFragmentFromMarkupWithContext(Document* docum
ent, const String& markup, unsigned fragmentStart, unsigned fragmentEnd, |
717 const String& baseURL, FragmentScriptingPermission scriptingPermission) | 717 const String& baseURL, FragmentScriptingPermission scriptingPermission) |
718 { | 718 { |
719 // FIXME: Need to handle the case where the markup already contains these ma
rkers. | 719 // FIXME: Need to handle the case where the markup already contains these ma
rkers. |
720 | 720 |
721 StringBuilder taggedMarkup; | 721 StringBuilder taggedMarkup; |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 StringBuilder markup; | 985 StringBuilder markup; |
986 markup.append("<a href=\""); | 986 markup.append("<a href=\""); |
987 markup.append(url.string()); | 987 markup.append(url.string()); |
988 markup.append("\">"); | 988 markup.append("\">"); |
989 appendCharactersReplacingEntities(markup, title.characters(), title.length()
, EntityMaskInPCDATA); | 989 appendCharactersReplacingEntities(markup, title.characters(), title.length()
, EntityMaskInPCDATA); |
990 markup.append("</a>"); | 990 markup.append("</a>"); |
991 return markup.toString(); | 991 return markup.toString(); |
992 } | 992 } |
993 | 993 |
994 } | 994 } |
OLD | NEW |