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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp

Issue 2368903002: Ensure valid VisiblePosition input for character{Before,After} (Closed)
Patch Set: Add DCHECK for the correctness of postponing Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 763
764 if (textNode->length() == 0) 764 if (textNode->length() == 0)
765 return; 765 return;
766 LayoutText* layoutText = textNode->layoutObject(); 766 LayoutText* layoutText = textNode->layoutObject();
767 if (layoutText && !layoutText->style()->collapseWhiteSpace()) 767 if (layoutText && !layoutText->style()->collapseWhiteSpace())
768 return; 768 return;
769 769
770 // Delete collapsed whitespace so that inserting nbsps doesn't uncollapse it . 770 // Delete collapsed whitespace so that inserting nbsps doesn't uncollapse it .
771 Position upstreamPos = mostBackwardCaretPosition(position); 771 Position upstreamPos = mostBackwardCaretPosition(position);
772 deleteInsignificantText(upstreamPos, mostForwardCaretPosition(position)); 772 deleteInsignificantText(upstreamPos, mostForwardCaretPosition(position));
773
774 document().updateStyleAndLayoutIgnorePendingStylesheets();
773 position = mostForwardCaretPosition(upstreamPos); 775 position = mostForwardCaretPosition(upstreamPos);
774 776 VisiblePosition visiblePos = createVisiblePosition(position);
775 VisiblePosition visiblePos = createVisiblePositionDeprecated(position);
776 VisiblePosition previousVisiblePos = previousPositionOf(visiblePos); 777 VisiblePosition previousVisiblePos = previousPositionOf(visiblePos);
777 replaceCollapsibleWhitespaceWithNonBreakingSpaceIfNeeded(previousVisiblePos) ; 778 replaceCollapsibleWhitespaceWithNonBreakingSpaceIfNeeded(previousVisiblePos) ;
778 replaceCollapsibleWhitespaceWithNonBreakingSpaceIfNeeded(visiblePos); 779
780 document().updateStyleAndLayoutIgnorePendingStylesheets();
781 replaceCollapsibleWhitespaceWithNonBreakingSpaceIfNeeded(createVisiblePositi on(position));
779 } 782 }
780 783
781 void CompositeEditCommand::replaceCollapsibleWhitespaceWithNonBreakingSpaceIfNee ded(const VisiblePosition& visiblePosition) 784 void CompositeEditCommand::replaceCollapsibleWhitespaceWithNonBreakingSpaceIfNee ded(const VisiblePosition& visiblePosition)
782 { 785 {
783 if (!isCollapsibleWhitespace(characterAfter(visiblePosition))) 786 if (!isCollapsibleWhitespace(characterAfter(visiblePosition)))
784 return; 787 return;
785 Position pos = mostForwardCaretPosition(visiblePosition.deepEquivalent()); 788 Position pos = mostForwardCaretPosition(visiblePosition.deepEquivalent());
786 if (!pos.computeContainerNode() || !pos.computeContainerNode()->isTextNode() ) 789 if (!pos.computeContainerNode() || !pos.computeContainerNode()->isTextNode() )
787 return; 790 return;
788 replaceTextInNodePreservingMarkers(toText(pos.computeContainerNode()), pos.o ffsetInContainerNode(), 1, nonBreakingSpaceString()); 791 replaceTextInNodePreservingMarkers(toText(pos.computeContainerNode()), pos.o ffsetInContainerNode(), 1, nonBreakingSpaceString());
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 } 1660 }
1658 1661
1659 DEFINE_TRACE(CompositeEditCommand) 1662 DEFINE_TRACE(CompositeEditCommand)
1660 { 1663 {
1661 visitor->trace(m_commands); 1664 visitor->trace(m_commands);
1662 visitor->trace(m_composition); 1665 visitor->trace(m_composition);
1663 EditCommand::trace(visitor); 1666 EditCommand::trace(visitor);
1664 } 1667 }
1665 1668
1666 } // namespace blink 1669 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698