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

Unified Diff: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp

Issue 2072093002: Remove style spans to follow the styles of list item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaseline for fixing test fails Created 4 years, 6 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 | « third_party/WebKit/LayoutTests/fast/text/insert-text-crash-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/text/insert-text-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698