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

Side by Side Diff: win8/metro_driver/ime/text_store.cc

Issue 119733002: Add base:: to string16s in win8/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « win8/metro_driver/ime/text_store.h ('k') | win8/metro_driver/ime/text_store_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "win8/metro_driver/ime/text_store.h" 5 #include "win8/metro_driver/ime/text_store.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/win/scoped_variant.h" 9 #include "base/win/scoped_variant.h"
10 #include "ui/base/win/atl_module.h" 10 #include "ui/base/win/atl_module.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 if (acp_end == -1) 260 if (acp_end == -1)
261 acp_end = string_buffer_size; 261 acp_end = string_buffer_size;
262 if (!((0 <= acp_start) && 262 if (!((0 <= acp_start) &&
263 (acp_start <= acp_end) && 263 (acp_start <= acp_end) &&
264 (acp_end <= string_buffer_size))) { 264 (acp_end <= string_buffer_size))) {
265 return TF_E_INVALIDPOS; 265 return TF_E_INVALIDPOS;
266 } 266 }
267 acp_end = std::min(acp_end, acp_start + static_cast<LONG>(text_buffer_size)); 267 acp_end = std::min(acp_end, acp_start + static_cast<LONG>(text_buffer_size));
268 *text_buffer_copied = acp_end - acp_start; 268 *text_buffer_copied = acp_end - acp_start;
269 269
270 const string16& result = 270 const base::string16& result =
271 string_buffer_.substr(acp_start, *text_buffer_copied); 271 string_buffer_.substr(acp_start, *text_buffer_copied);
272 for (size_t i = 0; i < result.size(); ++i) 272 for (size_t i = 0; i < result.size(); ++i)
273 text_buffer[i] = result[i]; 273 text_buffer[i] = result[i];
274 274
275 if (run_info_buffer_size) { 275 if (run_info_buffer_size) {
276 run_info_buffer[0].uCount = *text_buffer_copied; 276 run_info_buffer[0].uCount = *text_buffer_copied;
277 run_info_buffer[0].type = TS_RT_PLAIN; 277 run_info_buffer[0].type = TS_RT_PLAIN;
278 *run_info_buffer_copied = 1; 278 *run_info_buffer_copied = 1;
279 } 279 }
280 280
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 return S_OK; 407 return S_OK;
408 } 408 }
409 409
410 if (!HasReadWriteLock()) 410 if (!HasReadWriteLock())
411 return TS_E_NOLOCK; 411 return TS_E_NOLOCK;
412 if (!text_buffer) 412 if (!text_buffer)
413 return E_INVALIDARG; 413 return E_INVALIDARG;
414 414
415 DCHECK_LE(start_pos, end_pos); 415 DCHECK_LE(start_pos, end_pos);
416 string_buffer_ = string_buffer_.substr(0, start_pos) + 416 string_buffer_ = string_buffer_.substr(0, start_pos) +
417 string16(text_buffer, text_buffer + text_buffer_size) + 417 base::string16(text_buffer, text_buffer + text_buffer_size) +
418 string_buffer_.substr(end_pos); 418 string_buffer_.substr(end_pos);
419 if (acp_start) 419 if (acp_start)
420 *acp_start = start_pos; 420 *acp_start = start_pos;
421 if (acp_end) 421 if (acp_end)
422 *acp_end = new_end_pos; 422 *acp_end = new_end_pos;
423 if (text_change) { 423 if (text_change) {
424 text_change->acpStart = start_pos; 424 text_change->acpStart = start_pos;
425 text_change->acpOldEnd = end_pos; 425 text_change->acpOldEnd = end_pos;
426 text_change->acpNewEnd = new_end_pos; 426 text_change->acpNewEnd = new_end_pos;
427 } 427 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 current_lock_type_ = 0; 518 current_lock_type_ = 0;
519 } 519 }
520 520
521 if (!edit_flag_) 521 if (!edit_flag_)
522 return S_OK; 522 return S_OK;
523 523
524 // If the text store is edited in OnLockGranted(), we may need to call 524 // If the text store is edited in OnLockGranted(), we may need to call
525 // TextStoreDelegate::ConfirmComposition() or 525 // TextStoreDelegate::ConfirmComposition() or
526 // TextStoreDelegate::SetComposition(). 526 // TextStoreDelegate::SetComposition().
527 const uint32 new_committed_size = committed_size_; 527 const uint32 new_committed_size = committed_size_;
528 const string16& new_committed_string = 528 const base::string16& new_committed_string =
529 string_buffer_.substr(last_committed_size, 529 string_buffer_.substr(last_committed_size,
530 new_committed_size - last_committed_size); 530 new_committed_size - last_committed_size);
531 const string16& composition_string = 531 const base::string16& composition_string =
532 string_buffer_.substr(new_committed_size); 532 string_buffer_.substr(new_committed_size);
533 533
534 // If there is new committed string, calls 534 // If there is new committed string, calls
535 // TextStoreDelegate::ConfirmComposition(). 535 // TextStoreDelegate::ConfirmComposition().
536 if ((!new_committed_string.empty())) 536 if ((!new_committed_string.empty()))
537 delegate_->OnTextCommitted(new_committed_string); 537 delegate_->OnTextCommitted(new_committed_string);
538 538
539 // Calls TextInputClient::SetCompositionText(). 539 // Calls TextInputClient::SetCompositionText().
540 std::vector<metro_viewer::UnderlineInfo> underlines = underlines_; 540 std::vector<metro_viewer::UnderlineInfo> underlines = underlines_;
541 // Adjusts the offset. 541 // Adjusts the offset.
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 if (edit_flag_) 850 if (edit_flag_)
851 return false; 851 return false;
852 852
853 if (string_buffer_.empty()) 853 if (string_buffer_.empty())
854 return true; 854 return true;
855 855
856 // See the comment in TextStore::CancelComposition. 856 // See the comment in TextStore::CancelComposition.
857 // This logic is based on the observation about how to emulate 857 // This logic is based on the observation about how to emulate
858 // ImmNotifyIME(NI_COMPOSITIONSTR, CPS_COMPLETE, 0) by CUAS. 858 // ImmNotifyIME(NI_COMPOSITIONSTR, CPS_COMPLETE, 0) by CUAS.
859 859
860 const string16& composition_text = string_buffer_.substr(committed_size_); 860 const base::string16& composition_text =
861 string_buffer_.substr(committed_size_);
861 if (!composition_text.empty()) 862 if (!composition_text.empty())
862 delegate_->OnTextCommitted(composition_text); 863 delegate_->OnTextCommitted(composition_text);
863 864
864 const uint32 previous_buffer_size = 865 const uint32 previous_buffer_size =
865 static_cast<uint32>(string_buffer_.size()); 866 static_cast<uint32>(string_buffer_.size());
866 string_buffer_.clear(); 867 string_buffer_.clear();
867 committed_size_ = 0; 868 committed_size_ = 0;
868 selection_start_ = 0; 869 selection_start_ = 0;
869 selection_end_ = 0; 870 selection_end_ = 0;
870 if (text_store_acp_sink_mask_ & TS_AS_SEL_CHANGE) 871 if (text_store_acp_sink_mask_ & TS_AS_SEL_CHANGE)
(...skipping 17 matching lines...) Expand all
888 889
889 bool TextStore::HasReadLock() const { 890 bool TextStore::HasReadLock() const {
890 return (current_lock_type_ & TS_LF_READ) == TS_LF_READ; 891 return (current_lock_type_ & TS_LF_READ) == TS_LF_READ;
891 } 892 }
892 893
893 bool TextStore::HasReadWriteLock() const { 894 bool TextStore::HasReadWriteLock() const {
894 return (current_lock_type_ & TS_LF_READWRITE) == TS_LF_READWRITE; 895 return (current_lock_type_ & TS_LF_READWRITE) == TS_LF_READWRITE;
895 } 896 }
896 897
897 } // namespace metro_driver 898 } // namespace metro_driver
OLDNEW
« no previous file with comments | « win8/metro_driver/ime/text_store.h ('k') | win8/metro_driver/ime/text_store_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698