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

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

Issue 2432083003: Add a nbsp at the the end of the text when the next text has a leading space. (Closed)
Patch Set: 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 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 864
865 String string = text.substring(upstream, length); 865 String string = text.substring(upstream, length);
866 // FIXME: Because of the problem mentioned at the top of this function, we 866 // FIXME: Because of the problem mentioned at the top of this function, we
867 // must also use nbsps at the start/end of the string because this function 867 // must also use nbsps at the start/end of the string because this function
868 // doesn't get all surrounding whitespace, just the whitespace in the 868 // doesn't get all surrounding whitespace, just the whitespace in the
869 // current text node. However, if the next sibling node is a text node 869 // current text node. However, if the next sibling node is a text node
870 // (not empty, see http://crbug.com/632300), we should use a plain space. 870 // (not empty, see http://crbug.com/632300), we should use a plain space.
871 // See http://crbug.com/310149 871 // See http://crbug.com/310149
872 const bool nextSiblingIsTextNode = 872 const bool nextSiblingIsTextNode =
873 textNode->nextSibling() && textNode->nextSibling()->isTextNode() && 873 textNode->nextSibling() && textNode->nextSibling()->isTextNode() &&
874 toText(textNode->nextSibling())->data().length(); 874 toText(textNode->nextSibling())->data().length() &&
875 toText(textNode->nextSibling())->data()[0] != ' ';
875 const bool shouldEmitNBSPbeforeEnd = 876 const bool shouldEmitNBSPbeforeEnd =
876 (isEndOfParagraph(visibleDownstreamPos) || 877 (isEndOfParagraph(visibleDownstreamPos) ||
877 (unsigned)downstream == text.length()) && 878 (unsigned)downstream == text.length()) &&
878 !nextSiblingIsTextNode; 879 !nextSiblingIsTextNode;
879 String rebalancedString = stringWithRebalancedWhitespace( 880 String rebalancedString = stringWithRebalancedWhitespace(
880 string, isStartOfParagraph(visibleUpstreamPos) || !upstream, 881 string, isStartOfParagraph(visibleUpstreamPos) || !upstream,
881 shouldEmitNBSPbeforeEnd); 882 shouldEmitNBSPbeforeEnd);
882 883
883 if (string != rebalancedString) 884 if (string != rebalancedString)
884 replaceTextInNodePreservingMarkers(textNode, upstream, length, 885 replaceTextInNodePreservingMarkers(textNode, upstream, length,
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 return node; 2018 return node;
2018 } 2019 }
2019 2020
2020 DEFINE_TRACE(CompositeEditCommand) { 2021 DEFINE_TRACE(CompositeEditCommand) {
2021 visitor->trace(m_commands); 2022 visitor->trace(m_commands);
2022 visitor->trace(m_composition); 2023 visitor->trace(m_composition);
2023 EditCommand::trace(visitor); 2024 EditCommand::trace(visitor);
2024 } 2025 }
2025 2026
2026 } // namespace blink 2027 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698