OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. | 4 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. |
5 * Copyright (C) 2011 Igalia S.L. | 5 * Copyright (C) 2011 Igalia S.L. |
6 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 6 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 static void trimFragment(DocumentFragment* fragment, | 353 static void trimFragment(DocumentFragment* fragment, |
354 Comment* nodeBeforeContext, | 354 Comment* nodeBeforeContext, |
355 Comment* nodeAfterContext) { | 355 Comment* nodeAfterContext) { |
356 Node* next = nullptr; | 356 Node* next = nullptr; |
357 for (Node* node = fragment->firstChild(); node; node = next) { | 357 for (Node* node = fragment->firstChild(); node; node = next) { |
358 if (nodeBeforeContext->isDescendantOf(node)) { | 358 if (nodeBeforeContext->isDescendantOf(node)) { |
359 next = NodeTraversal::next(*node); | 359 next = NodeTraversal::next(*node); |
360 continue; | 360 continue; |
361 } | 361 } |
362 next = NodeTraversal::nextSkippingChildren(*node); | 362 next = NodeTraversal::nextSkippingChildren(*node); |
363 DCHECK(!node->contains(nodeAfterContext)) << node << " " | 363 DCHECK(!node->contains(nodeAfterContext)) |
364 << nodeAfterContext; | 364 << node << " " << nodeAfterContext; |
365 node->parentNode()->removeChild(node, ASSERT_NO_EXCEPTION); | 365 node->parentNode()->removeChild(node, ASSERT_NO_EXCEPTION); |
366 if (nodeBeforeContext == node) | 366 if (nodeBeforeContext == node) |
367 break; | 367 break; |
368 } | 368 } |
369 | 369 |
370 DCHECK(nodeAfterContext->parentNode()) << nodeAfterContext; | 370 DCHECK(nodeAfterContext->parentNode()) << nodeAfterContext; |
371 for (Node* node = nodeAfterContext; node; node = next) { | 371 for (Node* node = nodeAfterContext; node; node = next) { |
372 next = NodeTraversal::nextSkippingChildren(*node); | 372 next = NodeTraversal::nextSkippingChildren(*node); |
373 node->parentNode()->removeChild(node, ASSERT_NO_EXCEPTION); | 373 node->parentNode()->removeChild(node, ASSERT_NO_EXCEPTION); |
374 } | 374 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 return !htmlElement.ieForbidsInsertHTML(); | 663 return !htmlElement.ieForbidsInsertHTML(); |
664 } | 664 } |
665 | 665 |
666 DocumentFragment* createContextualFragment( | 666 DocumentFragment* createContextualFragment( |
667 const String& markup, | 667 const String& markup, |
668 Element* element, | 668 Element* element, |
669 ParserContentPolicy parserContentPolicy, | 669 ParserContentPolicy parserContentPolicy, |
670 ExceptionState& exceptionState) { | 670 ExceptionState& exceptionState) { |
671 DCHECK(element); | 671 DCHECK(element); |
672 if (!isSupportedContainer(element)) { | 672 if (!isSupportedContainer(element)) { |
673 exceptionState.throwDOMException( | 673 exceptionState.throwDOMException(NotSupportedError, |
674 NotSupportedError, "The range's container is '" + element->localName() + | 674 "The range's container is '" + |
675 "', which is not supported."); | 675 element->localName() + |
| 676 "', which is not supported."); |
676 return nullptr; | 677 return nullptr; |
677 } | 678 } |
678 | 679 |
679 DocumentFragment* fragment = createFragmentForInnerOuterHTML( | 680 DocumentFragment* fragment = createFragmentForInnerOuterHTML( |
680 markup, element, parserContentPolicy, "createContextualFragment", | 681 markup, element, parserContentPolicy, "createContextualFragment", |
681 exceptionState); | 682 exceptionState); |
682 if (!fragment) | 683 if (!fragment) |
683 return nullptr; | 684 return nullptr; |
684 | 685 |
685 // We need to pop <html> and <body> elements and remove <head> to | 686 // We need to pop <html> and <body> elements and remove <head> to |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 textNode->appendData(textNext->data()); | 776 textNode->appendData(textNext->data()); |
776 if (textNext->parentNode()) // Might have been removed by mutation event. | 777 if (textNext->parentNode()) // Might have been removed by mutation event. |
777 textNext->remove(exceptionState); | 778 textNext->remove(exceptionState); |
778 } | 779 } |
779 | 780 |
780 template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingStrategy>; | 781 template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingStrategy>; |
781 template class CORE_TEMPLATE_EXPORT | 782 template class CORE_TEMPLATE_EXPORT |
782 CreateMarkupAlgorithm<EditingInFlatTreeStrategy>; | 783 CreateMarkupAlgorithm<EditingInFlatTreeStrategy>; |
783 | 784 |
784 } // namespace blink | 785 } // namespace blink |
OLD | NEW |