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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "core/dom/NodeTraversal.h" | 44 #include "core/dom/NodeTraversal.h" |
45 #include "core/dom/Range.h" | 45 #include "core/dom/Range.h" |
46 #include "core/editing/Editor.h" | 46 #include "core/editing/Editor.h" |
47 #include "core/editing/MarkupAccumulator.h" | 47 #include "core/editing/MarkupAccumulator.h" |
48 #include "core/editing/TextIterator.h" | 48 #include "core/editing/TextIterator.h" |
49 #include "core/editing/VisibleSelection.h" | 49 #include "core/editing/VisibleSelection.h" |
50 #include "core/editing/VisibleUnits.h" | 50 #include "core/editing/VisibleUnits.h" |
51 #include "core/editing/htmlediting.h" | 51 #include "core/editing/htmlediting.h" |
52 #include "core/html/HTMLBodyElement.h" | 52 #include "core/html/HTMLBodyElement.h" |
53 #include "core/html/HTMLElement.h" | 53 #include "core/html/HTMLElement.h" |
| 54 #include "core/html/HTMLHtmlElement.h" |
54 #include "core/html/HTMLTableElement.h" | 55 #include "core/html/HTMLTableElement.h" |
55 #include "core/html/HTMLTextFormControlElement.h" | 56 #include "core/html/HTMLTextFormControlElement.h" |
56 #include "core/page/Frame.h" | 57 #include "core/page/Frame.h" |
57 #include "core/rendering/RenderObject.h" | 58 #include "core/rendering/RenderObject.h" |
58 #include "weborigin/KURL.h" | 59 #include "weborigin/KURL.h" |
59 #include "wtf/StdLibExtras.h" | 60 #include "wtf/StdLibExtras.h" |
60 #include "wtf/text/StringBuilder.h" | 61 #include "wtf/text/StringBuilder.h" |
61 | 62 |
62 using namespace std; | 63 using namespace std; |
63 | 64 |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 fillContainerFromString(fragment.get(), string); | 837 fillContainerFromString(fragment.get(), string); |
837 return fragment.release(); | 838 return fragment.release(); |
838 } | 839 } |
839 | 840 |
840 // Break string into paragraphs. Extra line breaks turn into empty paragraph
s. | 841 // Break string into paragraphs. Extra line breaks turn into empty paragraph
s. |
841 Node* blockNode = enclosingBlock(context->firstNode()); | 842 Node* blockNode = enclosingBlock(context->firstNode()); |
842 Element* block = toElement(blockNode); | 843 Element* block = toElement(blockNode); |
843 bool useClonesOfEnclosingBlock = blockNode | 844 bool useClonesOfEnclosingBlock = blockNode |
844 && blockNode->isElementNode() | 845 && blockNode->isElementNode() |
845 && !block->hasTagName(bodyTag) | 846 && !block->hasTagName(bodyTag) |
846 && !block->hasTagName(htmlTag) | 847 && !isHTMLHtmlElement(block) |
847 && block != editableRootForPosition(context->startPosition()); | 848 && block != editableRootForPosition(context->startPosition()); |
848 bool useLineBreak = enclosingTextFormControl(context->startPosition()); | 849 bool useLineBreak = enclosingTextFormControl(context->startPosition()); |
849 | 850 |
850 Vector<String> list; | 851 Vector<String> list; |
851 string.split('\n', true, list); // true gets us empty strings in the list | 852 string.split('\n', true, list); // true gets us empty strings in the list |
852 size_t numLines = list.size(); | 853 size_t numLines = list.size(); |
853 for (size_t i = 0; i < numLines; ++i) { | 854 for (size_t i = 0; i < numLines; ++i) { |
854 const String& s = list[i]; | 855 const String& s = list[i]; |
855 | 856 |
856 RefPtr<Element> element; | 857 RefPtr<Element> element; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 if (!fragment) | 1016 if (!fragment) |
1016 return 0; | 1017 return 0; |
1017 | 1018 |
1018 // We need to pop <html> and <body> elements and remove <head> to | 1019 // We need to pop <html> and <body> elements and remove <head> to |
1019 // accommodate folks passing complete HTML documents to make the | 1020 // accommodate folks passing complete HTML documents to make the |
1020 // child of an element. | 1021 // child of an element. |
1021 | 1022 |
1022 RefPtr<Node> nextNode; | 1023 RefPtr<Node> nextNode; |
1023 for (RefPtr<Node> node = fragment->firstChild(); node; node = nextNode) { | 1024 for (RefPtr<Node> node = fragment->firstChild(); node; node = nextNode) { |
1024 nextNode = node->nextSibling(); | 1025 nextNode = node->nextSibling(); |
1025 if (node->hasTagName(htmlTag) || node->hasTagName(headTag) || node->hasT
agName(bodyTag)) { | 1026 if (isHTMLHtmlElement(node.get()) || node->hasTagName(headTag) || node->
hasTagName(bodyTag)) { |
1026 HTMLElement* element = toHTMLElement(node.get()); | 1027 HTMLElement* element = toHTMLElement(node.get()); |
1027 if (Node* firstChild = element->firstChild()) | 1028 if (Node* firstChild = element->firstChild()) |
1028 nextNode = firstChild; | 1029 nextNode = firstChild; |
1029 removeElementPreservingChildren(fragment, element); | 1030 removeElementPreservingChildren(fragment, element); |
1030 } | 1031 } |
1031 } | 1032 } |
1032 return fragment.release(); | 1033 return fragment.release(); |
1033 } | 1034 } |
1034 | 1035 |
1035 static inline bool hasOneChild(ContainerNode* node) | 1036 static inline bool hasOneChild(ContainerNode* node) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 if (hasOneChild(containerNode.get())) { | 1085 if (hasOneChild(containerNode.get())) { |
1085 containerNode->replaceChild(textNode.release(), containerNode->firstChil
d(), ec); | 1086 containerNode->replaceChild(textNode.release(), containerNode->firstChil
d(), ec); |
1086 return; | 1087 return; |
1087 } | 1088 } |
1088 | 1089 |
1089 containerNode->removeChildren(); | 1090 containerNode->removeChildren(); |
1090 containerNode->appendChild(textNode.release(), ec); | 1091 containerNode->appendChild(textNode.release(), ec); |
1091 } | 1092 } |
1092 | 1093 |
1093 } | 1094 } |
OLD | NEW |