Index: Source/core/editing/DeleteSelectionCommand.cpp |
diff --git a/Source/core/editing/DeleteSelectionCommand.cpp b/Source/core/editing/DeleteSelectionCommand.cpp |
index a01bb00bf2e032a4263dba30772596db6beafcec..6d077b574611c2e2539964e3a20f2b21f7013ae0 100644 |
--- a/Source/core/editing/DeleteSelectionCommand.cpp |
+++ b/Source/core/editing/DeleteSelectionCommand.cpp |
@@ -269,6 +269,12 @@ void DeleteSelectionCommand::initializePositionData() |
m_endBlock = enclosingNodeOfType(m_upstreamEnd.parentAnchoredEquivalent(), &isBlock, CanCrossEditingBoundary); |
} |
+// We don't want to inherit style from an element which can't have contents. |
+static bool shouldNotInheritStyleFrom(const Node& node) |
+{ |
+ return !node.canContainRangeEndPoint(); |
+} |
+ |
void DeleteSelectionCommand::saveTypingStyleState() |
{ |
// A common case is deleting characters that are all from the same text node. In |
@@ -281,6 +287,9 @@ void DeleteSelectionCommand::saveTypingStyleState() |
if (m_upstreamStart.deprecatedNode() == m_downstreamEnd.deprecatedNode() && m_upstreamStart.deprecatedNode()->isTextNode()) |
return; |
+ if (shouldNotInheritStyleFrom(*m_selectionToDelete.start().anchorNode())) |
+ return; |
+ |
// Figure out the typing style in effect before the delete is done. |
m_typingStyle = EditingStyle::create(m_selectionToDelete.start()); |
m_typingStyle->removeStyleAddedByNode(enclosingAnchorElement(m_selectionToDelete.start())); |