Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: third_party/WebKit/Source/core/editing/serializers/Serialization.cpp

Issue 2707973002: Remove blacklist on .innerHTML and .outerHTML (Closed)
Patch Set: Typo fix Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 HTMLElement* element) { 642 HTMLElement* element) {
643 Node* nextChild = nullptr; 643 Node* nextChild = nullptr;
644 for (Node* child = element->firstChild(); child; child = nextChild) { 644 for (Node* child = element->firstChild(); child; child = nextChild) {
645 nextChild = child->nextSibling(); 645 nextChild = child->nextSibling();
646 element->removeChild(child); 646 element->removeChild(child);
647 fragment->insertBefore(child, element); 647 fragment->insertBefore(child, element);
648 } 648 }
649 fragment->removeChild(element); 649 fragment->removeChild(element);
650 } 650 }
651 651
652 static inline bool isSupportedContainer(Element* element) {
653 DCHECK(element);
654 if (!element->isHTMLElement())
655 return true;
656
657 HTMLElement& htmlElement = toHTMLElement(*element);
658 if (htmlElement.hasTagName(colTag) || htmlElement.hasTagName(colgroupTag) ||
659 htmlElement.hasTagName(framesetTag) || htmlElement.hasTagName(headTag) ||
660 htmlElement.hasTagName(styleTag) || htmlElement.hasTagName(titleTag)) {
661 return false;
662 }
663 return !htmlElement.ieForbidsInsertHTML();
664 }
665
666 DocumentFragment* createContextualFragment( 652 DocumentFragment* createContextualFragment(
667 const String& markup, 653 const String& markup,
668 Element* element, 654 Element* element,
669 ParserContentPolicy parserContentPolicy, 655 ParserContentPolicy parserContentPolicy,
670 ExceptionState& exceptionState) { 656 ExceptionState& exceptionState) {
671 DCHECK(element); 657 DCHECK(element);
672 if (!isSupportedContainer(element)) {
673 exceptionState.throwDOMException(
674 NotSupportedError, "The range's container is '" + element->localName() +
675 "', which is not supported.");
676 return nullptr;
677 }
678 658
679 DocumentFragment* fragment = createFragmentForInnerOuterHTML( 659 DocumentFragment* fragment = createFragmentForInnerOuterHTML(
680 markup, element, parserContentPolicy, "createContextualFragment", 660 markup, element, parserContentPolicy, "createContextualFragment",
681 exceptionState); 661 exceptionState);
682 if (!fragment) 662 if (!fragment)
683 return nullptr; 663 return nullptr;
684 664
685 // We need to pop <html> and <body> elements and remove <head> to 665 // We need to pop <html> and <body> elements and remove <head> to
686 // accommodate folks passing complete HTML documents to make the 666 // accommodate folks passing complete HTML documents to make the
687 // child of an element. 667 // child of an element.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 textNode->appendData(textNext->data()); 755 textNode->appendData(textNext->data());
776 if (textNext->parentNode()) // Might have been removed by mutation event. 756 if (textNext->parentNode()) // Might have been removed by mutation event.
777 textNext->remove(exceptionState); 757 textNext->remove(exceptionState);
778 } 758 }
779 759
780 template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingStrategy>; 760 template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingStrategy>;
781 template class CORE_TEMPLATE_EXPORT 761 template class CORE_TEMPLATE_EXPORT
782 CreateMarkupAlgorithm<EditingInFlatTreeStrategy>; 762 CreateMarkupAlgorithm<EditingInFlatTreeStrategy>;
783 763
784 } // namespace blink 764 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698