Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/common/dwrite_text_analysis_source_win.h" | |
| 6 | |
| 7 namespace content { | |
| 8 | |
| 9 TextAnalysisSource::~TextAnalysisSource() = default; | |
| 10 | |
| 11 HRESULT TextAnalysisSource::GetLocaleName(UINT32 text_position, | |
| 12 UINT32* text_length, | |
| 13 const WCHAR** locale_name) { | |
| 14 if (text_position >= text_.length()) | |
|
ananta
2016/04/12 23:44:39
Please check if the parameters like pointers, etc
Ilya Kulshin
2016/04/13 01:33:29
Done.
| |
| 15 return E_INVALIDARG; | |
| 16 *text_length = text_.length() - text_position; | |
| 17 *locale_name = locale_name_.c_str(); | |
| 18 return S_OK; | |
| 19 } | |
| 20 HRESULT TextAnalysisSource::GetNumberSubstitution( | |
|
ananta
2016/04/12 23:44:39
newline between functions here and below
Ilya Kulshin
2016/04/13 01:33:29
Done.
| |
| 21 UINT32 text_position, | |
| 22 UINT32* text_length, | |
| 23 IDWriteNumberSubstitution** number_substitution) { | |
| 24 if (text_position >= text_.length()) { | |
| 25 *text_length = 0; | |
| 26 return S_OK; | |
| 27 } | |
| 28 *text_length = text_.length() - text_position; | |
| 29 number_substitution_.CopyTo(number_substitution); | |
| 30 return S_OK; | |
| 31 } | |
| 32 DWRITE_READING_DIRECTION TextAnalysisSource::GetParagraphReadingDirection() { | |
| 33 return reading_direction_; | |
| 34 } | |
| 35 HRESULT TextAnalysisSource::GetTextAtPosition(UINT32 text_position, | |
| 36 const WCHAR** text_string, | |
| 37 UINT32* text_length) { | |
| 38 if (text_position >= text_.length()) { | |
| 39 *text_string = nullptr; | |
| 40 *text_length = 0; | |
| 41 return S_OK; | |
| 42 } | |
| 43 *text_string = text_.c_str() + text_position; | |
| 44 *text_length = text_.length() - text_position; | |
| 45 return S_OK; | |
| 46 } | |
| 47 HRESULT TextAnalysisSource::GetTextBeforePosition(UINT32 text_position, | |
| 48 const WCHAR** text_string, | |
| 49 UINT32* text_length) { | |
| 50 if (text_position < 1 || text_position >= text_.length()) { | |
| 51 *text_string = nullptr; | |
| 52 *text_length = 0; | |
| 53 return S_OK; | |
| 54 } | |
| 55 *text_string = text_.c_str(); | |
| 56 *text_length = text_position; | |
| 57 return S_OK; | |
| 58 } | |
| 59 | |
| 60 HRESULT TextAnalysisSource::RuntimeClassInitialize( | |
| 61 const base::string16& text, | |
| 62 const base::string16& locale_name, | |
| 63 IDWriteNumberSubstitution* number_substitution, | |
| 64 DWRITE_READING_DIRECTION reading_direction) { | |
| 65 text_ = text; | |
| 66 locale_name_ = locale_name; | |
| 67 number_substitution_ = number_substitution; | |
| 68 reading_direction_ = reading_direction; | |
| 69 return S_OK; | |
| 70 } | |
| 71 | |
| 72 } // namespace content | |
| OLD | NEW |