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

Side by Side Diff: Source/core/editing/htmlediting.cpp

Issue 1119663002: Making Unicode character names consistent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase patch Created 5 years, 7 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 | « Source/core/editing/htmlediting.h ('k') | Source/core/editing/iterators/TextIterator.cpp » ('j') | 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) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 bool previousCharacterWasSpace = false; 377 bool previousCharacterWasSpace = false;
378 for (size_t i = 0; i < length; i++) { 378 for (size_t i = 0; i < length; i++) {
379 UChar c = string[i]; 379 UChar c = string[i];
380 if (!isWhitespace(c)) { 380 if (!isWhitespace(c)) {
381 rebalancedString.append(c); 381 rebalancedString.append(c);
382 previousCharacterWasSpace = false; 382 previousCharacterWasSpace = false;
383 continue; 383 continue;
384 } 384 }
385 385
386 if (previousCharacterWasSpace || (!i && startIsStartOfParagraph) || (i + 1 == length && endIsEndOfParagraph)) { 386 if (previousCharacterWasSpace || (!i && startIsStartOfParagraph) || (i + 1 == length && endIsEndOfParagraph)) {
387 rebalancedString.append(noBreakSpace); 387 rebalancedString.append(noBreakSpaceCharacter);
388 previousCharacterWasSpace = false; 388 previousCharacterWasSpace = false;
389 } else { 389 } else {
390 rebalancedString.append(' '); 390 rebalancedString.append(' ');
391 previousCharacterWasSpace = true; 391 previousCharacterWasSpace = true;
392 } 392 }
393 } 393 }
394 394
395 ASSERT(rebalancedString.length() == length); 395 ASSERT(rebalancedString.length() == length);
396 396
397 return rebalancedString.toString(); 397 return rebalancedString.toString();
398 } 398 }
399 399
400 bool isTableStructureNode(const Node *node) 400 bool isTableStructureNode(const Node *node)
401 { 401 {
402 LayoutObject* layoutObject = node->layoutObject(); 402 LayoutObject* layoutObject = node->layoutObject();
403 return (layoutObject && (layoutObject->isTableCell() || layoutObject->isTabl eRow() || layoutObject->isTableSection() || layoutObject->isLayoutTableCol())); 403 return (layoutObject && (layoutObject->isTableCell() || layoutObject->isTabl eRow() || layoutObject->isTableSection() || layoutObject->isLayoutTableCol()));
404 } 404 }
405 405
406 const String& nonBreakingSpaceString() 406 const String& nonBreakingSpaceString()
407 { 407 {
408 DEFINE_STATIC_LOCAL(String, nonBreakingSpaceString, (&noBreakSpace, 1)); 408 DEFINE_STATIC_LOCAL(String, nonBreakingSpaceString, (&noBreakSpaceCharacter, 1));
409 return nonBreakingSpaceString; 409 return nonBreakingSpaceString;
410 } 410 }
411 411
412 // FIXME: need to dump this 412 // FIXME: need to dump this
413 static bool isSpecialHTMLElement(const Node& n) 413 static bool isSpecialHTMLElement(const Node& n)
414 { 414 {
415 if (!n.isHTMLElement()) 415 if (!n.isHTMLElement())
416 return false; 416 return false;
417 417
418 if (n.isLink()) 418 if (n.isLink())
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 if (position.isNull()) 911 if (position.isNull())
912 return Position(); 912 return Position();
913 913
914 if (isHTMLBRElement(*position.upstream().anchorNode())) 914 if (isHTMLBRElement(*position.upstream().anchorNode()))
915 return Position(); 915 return Position();
916 916
917 Position prev = previousCharacterPosition(position, affinity); 917 Position prev = previousCharacterPosition(position, affinity);
918 if (prev != position && inSameContainingBlockFlowElement(prev.anchorNode(), position.anchorNode()) && prev.anchorNode()->isTextNode()) { 918 if (prev != position && inSameContainingBlockFlowElement(prev.anchorNode(), position.anchorNode()) && prev.anchorNode()->isTextNode()) {
919 String string = toText(prev.anchorNode())->data(); 919 String string = toText(prev.anchorNode())->data();
920 UChar previousCharacter = string[prev.deprecatedEditingOffset()]; 920 UChar previousCharacter = string[prev.deprecatedEditingOffset()];
921 bool isSpace = option == ConsiderNonCollapsibleWhitespace ? (isSpaceOrNe wline(previousCharacter) || previousCharacter == noBreakSpace) : isCollapsibleWh itespace(previousCharacter); 921 bool isSpace = option == ConsiderNonCollapsibleWhitespace ? (isSpaceOrNe wline(previousCharacter) || previousCharacter == noBreakSpaceCharacter) : isColl apsibleWhitespace(previousCharacter);
922 if (isSpace && isEditablePosition(prev)) 922 if (isSpace && isEditablePosition(prev))
923 return prev; 923 return prev;
924 } 924 }
925 925
926 return Position(); 926 return Position();
927 } 927 }
928 928
929 // This assumes that it starts in editable content. 929 // This assumes that it starts in editable content.
930 Position trailingWhitespacePosition(const Position& position, EAffinity, Whitesp acePositionOption option) 930 Position trailingWhitespacePosition(const Position& position, EAffinity, Whitesp acePositionOption option)
931 { 931 {
932 ASSERT(isEditablePosition(position, ContentIsEditable, DoNotUpdateStyle)); 932 ASSERT(isEditablePosition(position, ContentIsEditable, DoNotUpdateStyle));
933 if (position.isNull()) 933 if (position.isNull())
934 return Position(); 934 return Position();
935 935
936 VisiblePosition visiblePosition(position); 936 VisiblePosition visiblePosition(position);
937 UChar characterAfterVisiblePosition = visiblePosition.characterAfter(); 937 UChar characterAfterVisiblePosition = visiblePosition.characterAfter();
938 bool isSpace = option == ConsiderNonCollapsibleWhitespace ? (isSpaceOrNewlin e(characterAfterVisiblePosition) || characterAfterVisiblePosition == noBreakSpac e) : isCollapsibleWhitespace(characterAfterVisiblePosition); 938 bool isSpace = option == ConsiderNonCollapsibleWhitespace ? (isSpaceOrNewlin e(characterAfterVisiblePosition) || characterAfterVisiblePosition == noBreakSpac eCharacter) : isCollapsibleWhitespace(characterAfterVisiblePosition);
939 // The space must not be in another paragraph and it must be editable. 939 // The space must not be in another paragraph and it must be editable.
940 if (isSpace && !isEndOfParagraph(visiblePosition) && visiblePosition.next(Ca nnotCrossEditingBoundary).isNotNull()) 940 if (isSpace && !isEndOfParagraph(visiblePosition) && visiblePosition.next(Ca nnotCrossEditingBoundary).isNotNull())
941 return position; 941 return position;
942 return Position(); 942 return Position();
943 } 943 }
944 944
945 unsigned numEnclosingMailBlockquotes(const Position& p) 945 unsigned numEnclosingMailBlockquotes(const Position& p)
946 { 946 {
947 unsigned num = 0; 947 unsigned num = 0;
948 for (Node* n = p.deprecatedNode(); n; n = n->parentNode()) 948 for (Node* n = p.deprecatedNode(); n; n = n->parentNode())
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 // if the selection starts just before a paragraph break, skip over it 1182 // if the selection starts just before a paragraph break, skip over it
1183 if (isEndOfParagraph(visiblePosition)) 1183 if (isEndOfParagraph(visiblePosition))
1184 return visiblePosition.next().deepEquivalent().downstream(); 1184 return visiblePosition.next().deepEquivalent().downstream();
1185 1185
1186 // otherwise, make sure to be at the start of the first selected node, 1186 // otherwise, make sure to be at the start of the first selected node,
1187 // instead of possibly at the end of the last node before the selection 1187 // instead of possibly at the end of the last node before the selection
1188 return visiblePosition.deepEquivalent().downstream(); 1188 return visiblePosition.deepEquivalent().downstream();
1189 } 1189 }
1190 1190
1191 } // namespace blink 1191 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/htmlediting.h ('k') | Source/core/editing/iterators/TextIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698