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

Side by Side Diff: content/common/dwrite_text_analysis_source_win.cc

Issue 1846433005: Implement direct write fallback proxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Style fixes Created 4 years, 8 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
OLDNEW
(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 #include "base/logging.h"
8
9 namespace content {
10
11 TextAnalysisSource::~TextAnalysisSource() = default;
12
13 HRESULT TextAnalysisSource::GetLocaleName(UINT32 text_position,
14 UINT32* text_length,
15 const WCHAR** locale_name) {
16 if (text_position >= text_.length() || !text_length || !locale_name)
17 return E_INVALIDARG;
18 *text_length = text_.length() - text_position;
19 *locale_name = locale_name_.c_str();
20 return S_OK;
21 }
22
23 HRESULT TextAnalysisSource::GetNumberSubstitution(
24 UINT32 text_position,
25 UINT32* text_length,
26 IDWriteNumberSubstitution** number_substitution) {
27 if (text_position >= text_.length() || !text_length || !number_substitution)
28 return E_INVALIDARG;
29 *text_length = text_.length() - text_position;
30 number_substitution_.CopyTo(number_substitution);
31 return S_OK;
32 }
33
34 DWRITE_READING_DIRECTION TextAnalysisSource::GetParagraphReadingDirection() {
35 return reading_direction_;
36 }
37
38 HRESULT TextAnalysisSource::GetTextAtPosition(UINT32 text_position,
39 const WCHAR** text_string,
40 UINT32* text_length) {
41 if (!text_length || !text_string)
42 return E_INVALIDARG;
43 if (text_position >= text_.length()) {
44 *text_string = nullptr;
45 *text_length = 0;
46 return S_OK;
47 }
48 *text_string = text_.c_str() + text_position;
49 *text_length = text_.length() - text_position;
50 return S_OK;
51 }
52
53 HRESULT TextAnalysisSource::GetTextBeforePosition(UINT32 text_position,
54 const WCHAR** text_string,
55 UINT32* text_length) {
56 if (!text_length || !text_string)
57 return E_INVALIDARG;
58 if (text_position < 1 || text_position > text_.length()) {
59 *text_string = nullptr;
60 *text_length = 0;
61 return S_OK;
62 }
63 *text_string = text_.c_str();
64 *text_length = text_position;
65 return S_OK;
66 }
67
68 HRESULT TextAnalysisSource::RuntimeClassInitialize(
69 const base::string16& text,
70 const base::string16& locale_name,
71 IDWriteNumberSubstitution* number_substitution,
72 DWRITE_READING_DIRECTION reading_direction) {
73 DCHECK(number_substitution);
74 text_ = text;
75 locale_name_ = locale_name;
76 number_substitution_ = number_substitution;
77 reading_direction_ = reading_direction;
78 return S_OK;
79 }
80
81 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698