OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
31 #include "core/dom/NodeTraversal.h" | 31 #include "core/dom/NodeTraversal.h" |
32 #include "core/dom/Text.h" | 32 #include "core/dom/Text.h" |
33 #include "core/editing/EditingStyle.h" | 33 #include "core/editing/EditingStyle.h" |
34 #include "core/editing/InsertLineBreakCommand.h" | 34 #include "core/editing/InsertLineBreakCommand.h" |
35 #include "core/editing/VisibleUnits.h" | 35 #include "core/editing/VisibleUnits.h" |
36 #include "core/editing/htmlediting.h" | 36 #include "core/editing/htmlediting.h" |
37 #include "core/html/HTMLBRElement.h" | 37 #include "core/html/HTMLBRElement.h" |
38 #include "core/html/HTMLElement.h" | 38 #include "core/html/HTMLElement.h" |
| 39 #include "core/html/HTMLQuoteElement.h" |
39 #include "core/rendering/RenderObject.h" | 40 #include "core/rendering/RenderObject.h" |
40 #include "core/rendering/RenderText.h" | 41 #include "core/rendering/RenderText.h" |
41 | 42 |
42 namespace blink { | 43 namespace blink { |
43 | 44 |
44 using namespace HTMLNames; | 45 using namespace HTMLNames; |
45 | 46 |
46 // When inserting a new line, we want to avoid nesting empty divs if we can. Ot
herwise, when | 47 // When inserting a new line, we want to avoid nesting empty divs if we can. Ot
herwise, when |
47 // pasting, it's easy to have each new line be a div deeper than the previous.
E.g., in the case | 48 // pasting, it's easy to have each new line be a div deeper than the previous.
E.g., in the case |
48 // below, we want to insert at ^ instead of |. | 49 // below, we want to insert at ^ instead of |. |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // represent the paragraph that we're leaving. | 224 // represent the paragraph that we're leaving. |
224 RefPtrWillBeRawPtr<Element> extraBlock = createDefaultParagraphE
lement(document()); | 225 RefPtrWillBeRawPtr<Element> extraBlock = createDefaultParagraphE
lement(document()); |
225 appendNode(extraBlock, startBlock); | 226 appendNode(extraBlock, startBlock); |
226 appendBlockPlaceholder(extraBlock); | 227 appendBlockPlaceholder(extraBlock); |
227 } | 228 } |
228 appendNode(blockToInsert, startBlock); | 229 appendNode(blockToInsert, startBlock); |
229 } else { | 230 } else { |
230 // We can get here if we pasted a copied portion of a blockquote wit
h a newline at the end and are trying to paste it | 231 // We can get here if we pasted a copied portion of a blockquote wit
h a newline at the end and are trying to paste it |
231 // into an unquoted area. We then don't want the newline within the
blockquote or else it will also be quoted. | 232 // into an unquoted area. We then don't want the newline within the
blockquote or else it will also be quoted. |
232 if (m_pasteBlockqutoeIntoUnquotedArea) { | 233 if (m_pasteBlockqutoeIntoUnquotedArea) { |
233 if (Node* highestBlockquote = highestEnclosingNodeOfType(canonic
alPos, &isMailBlockquote)) | 234 if (HTMLQuoteElement* highestBlockquote = toHTMLQuoteElement(hig
hestEnclosingNodeOfType(canonicalPos, &isMailHTMLBlockquoteElement))) |
234 startBlock = toElement(highestBlockquote); | 235 startBlock = highestBlockquote; |
235 } | 236 } |
236 | 237 |
237 if (listChild && listChild != startBlock) { | 238 if (listChild && listChild != startBlock) { |
238 RefPtrWillBeRawPtr<Element> listChildToInsert = listChild->clone
ElementWithoutChildren(); | 239 RefPtrWillBeRawPtr<Element> listChildToInsert = listChild->clone
ElementWithoutChildren(); |
239 appendNode(blockToInsert, listChildToInsert.get()); | 240 appendNode(blockToInsert, listChildToInsert.get()); |
240 insertNodeAfter(listChildToInsert.get(), listChild); | 241 insertNodeAfter(listChildToInsert.get(), listChild); |
241 } else { | 242 } else { |
242 // Most of the time we want to stay at the nesting level of the
startBlock (e.g., when nesting within lists). However, | 243 // Most of the time we want to stay at the nesting level of the
startBlock (e.g., when nesting within lists). However, |
243 // for div nodes, this can result in nested div tags that are ha
rd to break out of. | 244 // for div nodes, this can result in nested div tags that are ha
rd to break out of. |
244 Element* siblingNode = startBlock.get(); | 245 Element* siblingNode = startBlock.get(); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 } | 429 } |
429 | 430 |
430 void InsertParagraphSeparatorCommand::trace(Visitor *visitor) | 431 void InsertParagraphSeparatorCommand::trace(Visitor *visitor) |
431 { | 432 { |
432 visitor->trace(m_style); | 433 visitor->trace(m_style); |
433 CompositeEditCommand::trace(visitor); | 434 CompositeEditCommand::trace(visitor); |
434 } | 435 } |
435 | 436 |
436 | 437 |
437 } // namespace blink | 438 } // namespace blink |
OLD | NEW |