Changeset 125955 in webkit
- Timestamp:
- Aug 17, 2012 5:31:00 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r125951 r125955 1 2012-08-17 Alice Cheng <alice_cheng@apple.com> 2 3 Preserve styling elements in DeleteSelectionCommand 4 <rdar://problem/12040676> 5 https://bugs.webkit.org/show_bug.cgi?id=93643 6 7 Reviewed by Ryosuke Niwa. 8 9 Test if delete selection command does move styling elements to 10 rootEditableElement, when the selection contains some. Also test command's 11 undoness. 12 13 * editing/execCommand/delete-selection-has-style-expected.txt: Added. 14 * editing/execCommand/delete-selection-has-style.html: Added. 15 1 16 2012-08-17 Sukolsak Sakshuwong <sukolsak@google.com> 2 17 -
trunk/Source/WebCore/ChangeLog
r125953 r125955 1 2012-08-17 Alice Cheng <alice_cheng@apple.com> 2 3 Preserve styling elements in DeleteSelectionCommand 4 <rdar://problem/12040676> 5 https://bugs.webkit.org/show_bug.cgi?id=93643 6 7 Reviewed by Ryosuke Niwa. 8 9 Styling elements (<link> and <style>) can appear inside editable content. To 10 prevent accidental deletion, we move styling elements to rootEditableElement in 11 DeleteSelectionCommand undoably. 12 13 Test: editing/execCommand/delete-selection-has-style.html 14 15 * editing/DeleteSelectionCommand.cpp: 16 (WebCore::DeleteSelectionCommand::makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss): Added to preserve styling elements during the command 17 (WebCore::DeleteSelectionCommand::handleGeneralDelete): Modified to preserve styling elements during the command 18 * editing/DeleteSelectionCommand.h: 19 (DeleteSelectionCommand): 20 1 21 2012-08-17 Sheriff Bot <webkit.review.bot@gmail.com> 2 22 -
trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp
r121303 r125955 417 417 } 418 418 419 void DeleteSelectionCommand::makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss() 420 { 421 RefPtr<Range> range = m_selectionToDelete.toNormalizedRange(); 422 RefPtr<Node> node = range->firstNode(); 423 while (node && node != range->pastLastNode()) { 424 RefPtr<Node> nextNode = node->traverseNextNode(); 425 if ((node->hasTagName(styleTag) && !(toElement(node.get())->hasAttribute(scopedAttr))) || node->hasTagName(linkTag)) { 426 nextNode = node->traverseNextSibling(); 427 RefPtr<ContainerNode> rootEditableElement = node->rootEditableElement(); 428 removeNode(node); 429 appendNode(node, rootEditableElement); 430 } 431 node = nextNode; 432 } 433 } 434 419 435 void DeleteSelectionCommand::handleGeneralDelete() 420 436 { … … 424 440 int startOffset = m_upstreamStart.deprecatedEditingOffset(); 425 441 Node* startNode = m_upstreamStart.deprecatedNode(); 442 443 makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss(); 426 444 427 445 // Never remove the start block unless it's a table, in which case we won't merge content in. -
trunk/Source/WebCore/editing/DeleteSelectionCommand.h
r116368 r125955 66 66 void calculateTypingStyleAfterDelete(); 67 67 void clearTransientState(); 68 void makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss(); 68 69 virtual void removeNode(PassRefPtr<Node>); 69 70 virtual void deleteTextFromNode(PassRefPtr<Text>, unsigned, unsigned);
Note: See TracChangeset
for help on using the changeset viewer.