| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2005 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #include "sky/engine/core/dom/Document.h" | 28 #include "sky/engine/core/dom/Document.h" |
| 29 #include "sky/engine/core/dom/Element.h" | 29 #include "sky/engine/core/dom/Element.h" |
| 30 #include "sky/engine/core/dom/NodeTraversal.h" | 30 #include "sky/engine/core/dom/NodeTraversal.h" |
| 31 #include "sky/engine/core/dom/Text.h" | 31 #include "sky/engine/core/dom/Text.h" |
| 32 #include "sky/engine/core/editing/EditingBoundary.h" | 32 #include "sky/engine/core/editing/EditingBoundary.h" |
| 33 #include "sky/engine/core/editing/Editor.h" | 33 #include "sky/engine/core/editing/Editor.h" |
| 34 #include "sky/engine/core/editing/VisibleUnits.h" | 34 #include "sky/engine/core/editing/VisibleUnits.h" |
| 35 #include "sky/engine/core/editing/htmlediting.h" | 35 #include "sky/engine/core/editing/htmlediting.h" |
| 36 #include "sky/engine/core/frame/LocalFrame.h" | 36 #include "sky/engine/core/frame/LocalFrame.h" |
| 37 #include "sky/engine/core/html/HTMLStyleElement.h" | |
| 38 #include "sky/engine/core/rendering/RenderText.h" | 37 #include "sky/engine/core/rendering/RenderText.h" |
| 39 | 38 |
| 40 namespace blink { | 39 namespace blink { |
| 41 | 40 |
| 42 DeleteSelectionCommand::DeleteSelectionCommand(Document& document, bool smartDel
ete, bool mergeBlocksAfterDelete, bool expandForSpecialElements, bool sanitizeMa
rkup) | 41 DeleteSelectionCommand::DeleteSelectionCommand(Document& document, bool smartDel
ete, bool mergeBlocksAfterDelete, bool expandForSpecialElements, bool sanitizeMa
rkup) |
| 43 : CompositeEditCommand(document) | 42 : CompositeEditCommand(document) |
| 44 , m_hasSelectionToDelete(false) | 43 , m_hasSelectionToDelete(false) |
| 45 , m_smartDelete(smartDelete) | 44 , m_smartDelete(smartDelete) |
| 46 , m_mergeBlocksAfterDelete(mergeBlocksAfterDelete) | 45 , m_mergeBlocksAfterDelete(mergeBlocksAfterDelete) |
| 47 , m_needPlaceholder(false) | 46 , m_needPlaceholder(false) |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 updatePositionForTextRemoval(node.get(), offset, count, m_endingPosition); | 321 updatePositionForTextRemoval(node.get(), offset, count, m_endingPosition); |
| 323 updatePositionForTextRemoval(node.get(), offset, count, m_leadingWhitespace)
; | 322 updatePositionForTextRemoval(node.get(), offset, count, m_leadingWhitespace)
; |
| 324 updatePositionForTextRemoval(node.get(), offset, count, m_trailingWhitespace
); | 323 updatePositionForTextRemoval(node.get(), offset, count, m_trailingWhitespace
); |
| 325 updatePositionForTextRemoval(node.get(), offset, count, m_downstreamEnd); | 324 updatePositionForTextRemoval(node.get(), offset, count, m_downstreamEnd); |
| 326 | 325 |
| 327 CompositeEditCommand::deleteTextFromNode(node, offset, count); | 326 CompositeEditCommand::deleteTextFromNode(node, offset, count); |
| 328 } | 327 } |
| 329 | 328 |
| 330 void DeleteSelectionCommand::makeStylingElementsDirectChildrenOfEditableRootToPr
eventStyleLoss() | 329 void DeleteSelectionCommand::makeStylingElementsDirectChildrenOfEditableRootToPr
eventStyleLoss() |
| 331 { | 330 { |
| 332 RefPtr<Range> range = m_selectionToDelete.toNormalizedRange(); | |
| 333 RefPtr<Node> node = range->firstNode(); | |
| 334 while (node && node != range->pastLastNode()) { | |
| 335 RefPtr<Node> nextNode = NodeTraversal::next(*node); | |
| 336 if (isHTMLStyleElement(*node)) { | |
| 337 nextNode = NodeTraversal::nextSkippingChildren(*node); | |
| 338 RefPtr<Element> rootEditableElement = node->rootEditableElement(); | |
| 339 if (rootEditableElement.get()) { | |
| 340 removeNode(node); | |
| 341 appendNode(node, rootEditableElement); | |
| 342 } | |
| 343 } | |
| 344 node = nextNode; | |
| 345 } | |
| 346 } | 331 } |
| 347 | 332 |
| 348 void DeleteSelectionCommand::handleGeneralDelete() | 333 void DeleteSelectionCommand::handleGeneralDelete() |
| 349 { | 334 { |
| 350 if (m_upstreamStart.isNull()) | 335 if (m_upstreamStart.isNull()) |
| 351 return; | 336 return; |
| 352 | 337 |
| 353 int startOffset = m_upstreamStart.deprecatedEditingOffset(); | 338 int startOffset = m_upstreamStart.deprecatedEditingOffset(); |
| 354 Node* startNode = m_upstreamStart.deprecatedNode(); | 339 Node* startNode = m_upstreamStart.deprecatedNode(); |
| 355 ASSERT(startNode); | 340 ASSERT(startNode); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 | 651 |
| 667 // Normally deletion doesn't preserve the typing style that was present before i
t. For example, | 652 // Normally deletion doesn't preserve the typing style that was present before i
t. For example, |
| 668 // type a character, Bold, then delete the character and start typing. The Bold
typing style shouldn't | 653 // type a character, Bold, then delete the character and start typing. The Bold
typing style shouldn't |
| 669 // stick around. Deletion should preserve a typing style that *it* sets, howeve
r. | 654 // stick around. Deletion should preserve a typing style that *it* sets, howeve
r. |
| 670 bool DeleteSelectionCommand::preservesTypingStyle() const | 655 bool DeleteSelectionCommand::preservesTypingStyle() const |
| 671 { | 656 { |
| 672 return false; | 657 return false; |
| 673 } | 658 } |
| 674 | 659 |
| 675 } // namespace blink | 660 } // namespace blink |
| OLD | NEW |