OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #define INITGUID // required for GUID_PROP_INPUTSCOPE | 5 #define INITGUID // required for GUID_PROP_INPUTSCOPE |
6 #include "ui/base/ime/win/tsf_text_store.h" | 6 #include "ui/base/ime/win/tsf_text_store.h" |
7 | 7 |
8 #include <InputScope.h> | 8 #include <InputScope.h> |
9 #include <OleCtl.h> | 9 #include <OleCtl.h> |
10 | 10 |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 selection_.set_end(new_end_pos); | 427 selection_.set_end(new_end_pos); |
428 return S_OK; | 428 return S_OK; |
429 } | 429 } |
430 | 430 |
431 STDMETHODIMP TSFTextStore::QueryInsert( | 431 STDMETHODIMP TSFTextStore::QueryInsert( |
432 LONG acp_test_start, | 432 LONG acp_test_start, |
433 LONG acp_test_end, | 433 LONG acp_test_end, |
434 ULONG text_size, | 434 ULONG text_size, |
435 LONG* acp_result_start, | 435 LONG* acp_result_start, |
436 LONG* acp_result_end) { | 436 LONG* acp_result_end) { |
437 if (!acp_result_start || !acp_result_end) | 437 if (!acp_result_start || !acp_result_end || acp_test_start > acp_test_end) |
438 return E_INVALIDARG; | 438 return E_INVALIDARG; |
439 if (!((static_cast<LONG>(committed_size_) <= acp_test_start) && | 439 const LONG committed_size = static_cast<LONG>(committed_size_); |
440 (acp_test_start <= acp_test_end) && | 440 const LONG buffer_size = static_cast<LONG>(string_buffer_.size()); |
441 (acp_test_end <= static_cast<LONG>(string_buffer_.size())))) { | 441 *acp_result_start = std::min(std::max(committed_size, acp_test_start), |
442 return E_INVALIDARG; | 442 buffer_size); |
443 } | 443 *acp_result_end = std::min(std::max(committed_size, acp_test_end), |
444 *acp_result_start = acp_test_start; | 444 buffer_size); |
445 *acp_result_end = acp_test_end; | |
446 return S_OK; | 445 return S_OK; |
447 } | 446 } |
448 | 447 |
449 STDMETHODIMP TSFTextStore::QueryInsertEmbedded(const GUID* service, | 448 STDMETHODIMP TSFTextStore::QueryInsertEmbedded(const GUID* service, |
450 const FORMATETC* format, | 449 const FORMATETC* format, |
451 BOOL* insertable) { | 450 BOOL* insertable) { |
452 if (!format) | 451 if (!format) |
453 return E_INVALIDARG; | 452 return E_INVALIDARG; |
454 // We don't support any embedded objects. | 453 // We don't support any embedded objects. |
455 if (insertable) | 454 if (insertable) |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 | 914 |
916 bool TSFTextStore::HasReadLock() const { | 915 bool TSFTextStore::HasReadLock() const { |
917 return (current_lock_type_ & TS_LF_READ) == TS_LF_READ; | 916 return (current_lock_type_ & TS_LF_READ) == TS_LF_READ; |
918 } | 917 } |
919 | 918 |
920 bool TSFTextStore::HasReadWriteLock() const { | 919 bool TSFTextStore::HasReadWriteLock() const { |
921 return (current_lock_type_ & TS_LF_READWRITE) == TS_LF_READWRITE; | 920 return (current_lock_type_ & TS_LF_READWRITE) == TS_LF_READWRITE; |
922 } | 921 } |
923 | 922 |
924 } // namespace ui | 923 } // namespace ui |
OLD | NEW |