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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 next = NodeTraversal::next(*node); 792 next = NodeTraversal::next(*node);
793 } 793 }
794 } 794 }
795 } 795 }
796 796
797 // Remove style spans before insertion if they are unnecessary. It's faster bec ause we'll 797 // Remove style spans before insertion if they are unnecessary. It's faster bec ause we'll
798 // avoid doing a layout. 798 // avoid doing a layout.
799 static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const Position& insertionPos) 799 static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const Position& insertionPos)
800 { 800 {
801 Node* topNode = fragment.firstChild(); 801 Node* topNode = fragment.firstChild();
802 if (!isHTMLSpanElement(topNode))
803 return false;
802 804
803 // Handling the case where we are doing Paste as Quotation or pasting into q uoted content is more complicated (see handleStyleSpans) 805 // Handling the case where we are doing Paste as Quotation or pasting into q uoted content is more complicated (see handleStyleSpans)
804 // and doesn't receive the optimization. 806 // and doesn't receive the optimization.
805 if (isMailPasteAsQuotationHTMLBlockQuoteElement(topNode) || enclosingNodeOfT ype(firstPositionInOrBeforeNode(topNode), isMailHTMLBlockquoteElement, CanCrossE ditingBoundary)) 807 if (isMailPasteAsQuotationHTMLBlockQuoteElement(topNode) || enclosingNodeOfT ype(firstPositionInOrBeforeNode(topNode), isMailHTMLBlockquoteElement, CanCrossE ditingBoundary))
806 return false; 808 return false;
807 809
810 // Remove style spans to follow the styles of list item when |fragment| beco mes a list item.
811 // See bug http://crbug.com/335955.
812 HTMLSpanElement* wrappingStyleSpan = toHTMLSpanElement(topNode);
813 if (isListItem(enclosingBlock(insertionPos.anchorNode()))) {
814 fragment.removeNodePreservingChildren(wrappingStyleSpan);
815 return true;
816 }
817
808 // Either there are no style spans in the fragment or a WebKit client has ad ded content to the fragment 818 // Either there are no style spans in the fragment or a WebKit client has ad ded content to the fragment
809 // before inserting it. Look for and handle style spans after insertion. 819 // before inserting it. Look for and handle style spans after insertion.
810 if (!isLegacyAppleHTMLSpanElement(topNode)) 820 if (!isLegacyAppleHTMLSpanElement(topNode))
811 return false; 821 return false;
812 822
813 HTMLSpanElement* wrappingStyleSpan = toHTMLSpanElement(topNode);
814 EditingStyle* styleAtInsertionPos = EditingStyle::create(insertionPos.parent AnchoredEquivalent()); 823 EditingStyle* styleAtInsertionPos = EditingStyle::create(insertionPos.parent AnchoredEquivalent());
815 String styleText = styleAtInsertionPos->style()->asText(); 824 String styleText = styleAtInsertionPos->style()->asText();
816 825
817 // FIXME: This string comparison is a naive way of comparing two styles. 826 // FIXME: This string comparison is a naive way of comparing two styles.
818 // We should be taking the diff and check that the diff is empty. 827 // We should be taking the diff and check that the diff is empty.
819 if (styleText != wrappingStyleSpan->getAttribute(styleAttr)) 828 if (styleText != wrappingStyleSpan->getAttribute(styleAttr))
820 return false; 829 return false;
821 830
822 fragment.removeNodePreservingChildren(wrappingStyleSpan); 831 fragment.removeNodePreservingChildren(wrappingStyleSpan);
823 return true; 832 return true;
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 visitor->trace(m_startOfInsertedContent); 1729 visitor->trace(m_startOfInsertedContent);
1721 visitor->trace(m_endOfInsertedContent); 1730 visitor->trace(m_endOfInsertedContent);
1722 visitor->trace(m_insertionStyle); 1731 visitor->trace(m_insertionStyle);
1723 visitor->trace(m_documentFragment); 1732 visitor->trace(m_documentFragment);
1724 visitor->trace(m_startOfInsertedRange); 1733 visitor->trace(m_startOfInsertedRange);
1725 visitor->trace(m_endOfInsertedRange); 1734 visitor->trace(m_endOfInsertedRange);
1726 CompositeEditCommand::trace(visitor); 1735 CompositeEditCommand::trace(visitor);
1727 } 1736 }
1728 1737
1729 } // namespace blink 1738 } // namespace blink
OLDNEW
« 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