Index: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp |
diff --git a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp |
index c58696bac7e974335f45eabb99581b0597a04278..121728246567904da1391df4f4bf1152337097ea 100644 |
--- a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp |
+++ b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp |
@@ -799,18 +799,27 @@ static void removeHeadContents(ReplacementFragment& fragment) |
static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const Position& insertionPos) |
{ |
Node* topNode = fragment.firstChild(); |
+ if (!isHTMLSpanElement(topNode)) |
+ return false; |
// Handling the case where we are doing Paste as Quotation or pasting into quoted content is more complicated (see handleStyleSpans) |
// and doesn't receive the optimization. |
if (isMailPasteAsQuotationHTMLBlockQuoteElement(topNode) || enclosingNodeOfType(firstPositionInOrBeforeNode(topNode), isMailHTMLBlockquoteElement, CanCrossEditingBoundary)) |
return false; |
+ // Remove style spans to follow the styles of list item when |fragment| becomes a list item. |
+ // See bug http://crbug.com/335955. |
+ HTMLSpanElement* wrappingStyleSpan = toHTMLSpanElement(topNode); |
+ if (isListItem(enclosingBlock(insertionPos.anchorNode()))) { |
+ fragment.removeNodePreservingChildren(wrappingStyleSpan); |
+ return true; |
+ } |
+ |
// Either there are no style spans in the fragment or a WebKit client has added content to the fragment |
// before inserting it. Look for and handle style spans after insertion. |
if (!isLegacyAppleHTMLSpanElement(topNode)) |
return false; |
- HTMLSpanElement* wrappingStyleSpan = toHTMLSpanElement(topNode); |
EditingStyle* styleAtInsertionPos = EditingStyle::create(insertionPos.parentAnchoredEquivalent()); |
String styleText = styleAtInsertionPos->style()->asText(); |