Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Unified Diff: Source/core/editing/DeleteSelectionCommand.cpp

Issue 18452012: Should not inherit style from control like element during inserting text just after deleting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/editing/inserting/insert-without-inheriting-style-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()));
« no previous file with comments | « LayoutTests/editing/inserting/insert-without-inheriting-style-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698