When deleting editable content, typing style should be reset when moving into another node.
https://bugs.webkit.org/show_bug.cgi?id=120726

Reviewed by Ryosuke Niwa.

Source/WebCore:

When moving from one text node to the other, while deleting characters,
the deleted text node's style was being applied to any new characters
added into the existing text node.

Typing Style in the frame selection maintains the editing style for the
deleted text node, so that if new characters are inserted at the position
of the deleted text node, it's style can be applied to them.

However, when moving into another text node, we should reset or clear the
typing style maintained by the frame selection. This ensures that any new
content inserted within the existing node does not take on any uncleared
style of the deleted node.

Test: editing/deleting/maintain-style-after-delete.html

* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::saveTypingStyleState):
Calling clearTypingStyle() on frame selection whenever deletion occurs
within the same text node. Thus any existing typing styleh held by the
frame selection shall be cleared.

LayoutTests:

* editing/deleting/maintain-style-after-delete-expected.txt: Added.
* editing/deleting/maintain-style-after-delete.html: Added.
Testcase added for verifying that style of the text node being deleted
is maintained.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155425 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/editing/DeleteSelectionCommand.cpp b/Source/WebCore/editing/DeleteSelectionCommand.cpp
index 1e6e770..da24be2 100644
--- a/Source/WebCore/editing/DeleteSelectionCommand.cpp
+++ b/Source/WebCore/editing/DeleteSelectionCommand.cpp
@@ -281,8 +281,12 @@
     // typing style at the start of the selection, nor is there a reason to 
     // compute the style at the start of the selection after deletion (see the 
     // early return in calculateTypingStyleAfterDelete).
-    if (m_upstreamStart.deprecatedNode() == m_downstreamEnd.deprecatedNode() && m_upstreamStart.deprecatedNode()->isTextNode())
+    // However, if typing style was previously set from another text node at the previous
+    // position (now deleted), we need to clear that style as well.
+    if (m_upstreamStart.deprecatedNode() == m_downstreamEnd.deprecatedNode() && m_upstreamStart.deprecatedNode()->isTextNode()) {
+        frame().selection().clearTypingStyle();
         return;
+    }
 
     // Figure out the typing style in effect before the delete is done.
     m_typingStyle = EditingStyle::create(m_selectionToDelete.start());