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

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

Issue 2926043002: Rename PlainText::end() to PlainText::End() (Closed)
Patch Set: Created 3 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 | « no previous file | third_party/WebKit/Source/core/editing/InputMethodControllerTest.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) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 .RootEditableElement(); 386 .RootEditableElement();
387 if (!root_editable_element) 387 if (!root_editable_element)
388 return false; 388 return false;
389 PlainTextRange composition_range = 389 PlainTextRange composition_range =
390 PlainTextRange::Create(*root_editable_element, *composition_range_); 390 PlainTextRange::Create(*root_editable_element, *composition_range_);
391 if (composition_range.IsNull()) 391 if (composition_range.IsNull())
392 return false; 392 return false;
393 393
394 Clear(); 394 Clear();
395 395
396 if (!MoveCaret(composition_range.end())) 396 if (!MoveCaret(composition_range.End()))
397 return false; 397 return false;
398 398
399 DispatchCompositionEndEvent(GetFrame(), composing); 399 DispatchCompositionEndEvent(GetFrame(), composing);
400 return true; 400 return true;
401 } 401 }
402 402
403 bool InputMethodController::CommitText( 403 bool InputMethodController::CommitText(
404 const String& text, 404 const String& text,
405 const Vector<CompositionUnderline>& underlines, 405 const Vector<CompositionUnderline>& underlines,
406 int relative_caret_position) { 406 int relative_caret_position) {
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 // 884 //
885 // FIXME: Note that this is not an ideal solution when this function is 885 // FIXME: Note that this is not an ideal solution when this function is
886 // called to implement "backspace". In that case, there should be some call 886 // called to implement "backspace". In that case, there should be some call
887 // that will not delete a full multi-code-point composition but rather 887 // that will not delete a full multi-code-point composition but rather
888 // only the last code-point so that it's possible for a user to correct 888 // only the last code-point so that it's possible for a user to correct
889 // a composition without starting it from the beginning. 889 // a composition without starting it from the beginning.
890 // http://crbug.com/37993 890 // http://crbug.com/37993
891 do { 891 do {
892 if (!SetSelectionOffsets(PlainTextRange( 892 if (!SetSelectionOffsets(PlainTextRange(
893 std::max(static_cast<int>(selection_offsets.Start()) - before, 0), 893 std::max(static_cast<int>(selection_offsets.Start()) - before, 0),
894 selection_offsets.end() + after))) 894 selection_offsets.End() + after)))
895 return; 895 return;
896 if (before == 0) 896 if (before == 0)
897 break; 897 break;
898 ++before; 898 ++before;
899 } while (GetFrame() 899 } while (GetFrame()
900 .Selection() 900 .Selection()
901 .ComputeVisibleSelectionInDOMTreeDeprecated() 901 .ComputeVisibleSelectionInDOMTreeDeprecated()
902 .Start() == GetFrame() 902 .Start() == GetFrame()
903 .Selection() 903 .Selection()
904 .ComputeVisibleSelectionInDOMTreeDeprecated() 904 .ComputeVisibleSelectionInDOMTreeDeprecated()
(...skipping 17 matching lines...) Expand all
922 if (selection_offsets.IsNull()) 922 if (selection_offsets.IsNull())
923 return; 923 return;
924 Element* const root_editable_element = 924 Element* const root_editable_element =
925 GetFrame() 925 GetFrame()
926 .Selection() 926 .Selection()
927 .ComputeVisibleSelectionInDOMTreeDeprecated() 927 .ComputeVisibleSelectionInDOMTreeDeprecated()
928 .RootEditableElement(); 928 .RootEditableElement();
929 if (!root_editable_element) 929 if (!root_editable_element)
930 return; 930 return;
931 int selection_start = static_cast<int>(selection_offsets.Start()); 931 int selection_start = static_cast<int>(selection_offsets.Start());
932 int selection_end = static_cast<int>(selection_offsets.end()); 932 int selection_end = static_cast<int>(selection_offsets.End());
933 933
934 // Select the text to be deleted before SelectionState::kStart. 934 // Select the text to be deleted before SelectionState::kStart.
935 if (before > 0 && selection_start > 0) { 935 if (before > 0 && selection_start > 0) {
936 // In case of exceeding the left boundary. 936 // In case of exceeding the left boundary.
937 const int start = std::max(selection_start - before, 0); 937 const int start = std::max(selection_start - before, 0);
938 938
939 const EphemeralRange& range = 939 const EphemeralRange& range =
940 PlainTextRange(0, start).CreateRange(*root_editable_element); 940 PlainTextRange(0, start).CreateRange(*root_editable_element);
941 if (range.IsNull()) 941 if (range.IsNull())
942 return; 942 return;
(...skipping 16 matching lines...) Expand all
959 if (after > 0) { 959 if (after > 0) {
960 // Adjust the deleted range in case of exceeding the right boundary. 960 // Adjust the deleted range in case of exceeding the right boundary.
961 const PlainTextRange range(0, selection_end + after); 961 const PlainTextRange range(0, selection_end + after);
962 if (range.IsNull()) 962 if (range.IsNull())
963 return; 963 return;
964 const EphemeralRange& valid_range = 964 const EphemeralRange& valid_range =
965 range.CreateRange(*root_editable_element); 965 range.CreateRange(*root_editable_element);
966 if (valid_range.IsNull()) 966 if (valid_range.IsNull())
967 return; 967 return;
968 const int end = 968 const int end =
969 PlainTextRange::Create(*root_editable_element, valid_range).end(); 969 PlainTextRange::Create(*root_editable_element, valid_range).End();
970 const Position& position = valid_range.EndPosition(); 970 const Position& position = valid_range.EndPosition();
971 971
972 // Adjust the end of selection for multi-code text. TODO(yabinh): Adjustment 972 // Adjust the end of selection for multi-code text. TODO(yabinh): Adjustment
973 // should be based on code point instead of grapheme cluster. 973 // should be based on code point instead of grapheme cluster.
974 const size_t diff = ComputeDistanceToRightGraphemeBoundary(position); 974 const size_t diff = ComputeDistanceToRightGraphemeBoundary(position);
975 const int adjusted_end = end + static_cast<int>(diff); 975 const int adjusted_end = end + static_cast<int>(diff);
976 if (!SetSelectionOffsets(PlainTextRange(selection_end, adjusted_end))) 976 if (!SetSelectionOffsets(PlainTextRange(selection_end, adjusted_end)))
977 return; 977 return;
978 TypingCommand::DeleteSelection(GetDocument()); 978 TypingCommand::DeleteSelection(GetDocument());
979 } 979 }
(...skipping 21 matching lines...) Expand all
1001 .Build(); 1001 .Build();
1002 const String& text = PlainText( 1002 const String& text = PlainText(
1003 EphemeralRange::RangeOfContents(*root_editable_element), behavior); 1003 EphemeralRange::RangeOfContents(*root_editable_element), behavior);
1004 1004
1005 // 8-bit characters are Latin-1 characters, so the deletion lengths are 1005 // 8-bit characters are Latin-1 characters, so the deletion lengths are
1006 // trivial. 1006 // trivial.
1007 if (text.Is8Bit()) 1007 if (text.Is8Bit())
1008 return DeleteSurroundingText(before, after); 1008 return DeleteSurroundingText(before, after);
1009 1009
1010 const int selection_start = static_cast<int>(selection_offsets.Start()); 1010 const int selection_start = static_cast<int>(selection_offsets.Start());
1011 const int selection_end = static_cast<int>(selection_offsets.end()); 1011 const int selection_end = static_cast<int>(selection_offsets.End());
1012 1012
1013 const int before_length = 1013 const int before_length =
1014 CalculateBeforeDeletionLengthsInCodePoints(text, before, selection_start); 1014 CalculateBeforeDeletionLengthsInCodePoints(text, before, selection_start);
1015 if (IsInvalidDeletionLength(before_length)) 1015 if (IsInvalidDeletionLength(before_length))
1016 return; 1016 return;
1017 const int after_length = 1017 const int after_length =
1018 CalculateAfterDeletionLengthsInCodePoints(text, after, selection_end); 1018 CalculateAfterDeletionLengthsInCodePoints(text, after, selection_end);
1019 if (IsInvalidDeletionLength(after_length)) 1019 if (IsInvalidDeletionLength(after_length))
1020 return; 1020 return;
1021 1021
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 if (info.value.IsEmpty()) 1062 if (info.value.IsEmpty())
1063 return info; 1063 return info;
1064 1064
1065 EphemeralRange first_range = FirstEphemeralRangeOf( 1065 EphemeralRange first_range = FirstEphemeralRangeOf(
1066 GetFrame().Selection().ComputeVisibleSelectionInDOMTreeDeprecated()); 1066 GetFrame().Selection().ComputeVisibleSelectionInDOMTreeDeprecated());
1067 if (first_range.IsNotNull()) { 1067 if (first_range.IsNotNull()) {
1068 PlainTextRange plain_text_range( 1068 PlainTextRange plain_text_range(
1069 PlainTextRange::Create(*element, first_range)); 1069 PlainTextRange::Create(*element, first_range));
1070 if (plain_text_range.IsNotNull()) { 1070 if (plain_text_range.IsNotNull()) {
1071 info.selection_start = plain_text_range.Start(); 1071 info.selection_start = plain_text_range.Start();
1072 info.selection_end = plain_text_range.end(); 1072 info.selection_end = plain_text_range.End();
1073 } 1073 }
1074 } 1074 }
1075 1075
1076 EphemeralRange range = CompositionEphemeralRange(); 1076 EphemeralRange range = CompositionEphemeralRange();
1077 if (range.IsNotNull()) { 1077 if (range.IsNotNull()) {
1078 PlainTextRange plain_text_range(PlainTextRange::Create(*element, range)); 1078 PlainTextRange plain_text_range(PlainTextRange::Create(*element, range));
1079 if (plain_text_range.IsNotNull()) { 1079 if (plain_text_range.IsNotNull()) {
1080 info.composition_start = plain_text_range.Start(); 1080 info.composition_start = plain_text_range.Start();
1081 info.composition_end = plain_text_range.end(); 1081 info.composition_end = plain_text_range.End();
1082 } 1082 }
1083 } 1083 }
1084 1084
1085 return info; 1085 return info;
1086 } 1086 }
1087 1087
1088 int InputMethodController::TextInputFlags() const { 1088 int InputMethodController::TextInputFlags() const {
1089 Element* element = GetDocument().FocusedElement(); 1089 Element* element = GetDocument().FocusedElement();
1090 if (!element) 1090 if (!element)
1091 return kWebTextInputFlagNone; 1091 return kWebTextInputFlagNone;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 FinishComposingText(kKeepSelection); 1238 FinishComposingText(kKeepSelection);
1239 } 1239 }
1240 1240
1241 DEFINE_TRACE(InputMethodController) { 1241 DEFINE_TRACE(InputMethodController) {
1242 visitor->Trace(frame_); 1242 visitor->Trace(frame_);
1243 visitor->Trace(composition_range_); 1243 visitor->Trace(composition_range_);
1244 SynchronousMutationObserver::Trace(visitor); 1244 SynchronousMutationObserver::Trace(visitor);
1245 } 1245 }
1246 1246
1247 } // namespace blink 1247 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698