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

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: Add a missing SUCCEEDED call 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
« no previous file with comments | « content/common/dwrite_text_analysis_source_win.h ('k') | content/content_child.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 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 TextAnalysisSource::~TextAnalysisSource() = default;
13
14 HRESULT TextAnalysisSource::GetLocaleName(UINT32 text_position,
15 UINT32* text_length,
16 const WCHAR** locale_name) {
17 if (text_position >= text_.length() || !text_length || !locale_name)
18 return E_INVALIDARG;
19 *text_length = text_.length() - text_position;
20 *locale_name = locale_name_.c_str();
21 return S_OK;
22 }
23
24 HRESULT TextAnalysisSource::GetNumberSubstitution(
25 UINT32 text_position,
26 UINT32* text_length,
27 IDWriteNumberSubstitution** number_substitution) {
28 if (text_position >= text_.length() || !text_length || !number_substitution)
29 return E_INVALIDARG;
30 *text_length = text_.length() - text_position;
31 number_substitution_.CopyTo(number_substitution);
32 return S_OK;
33 }
34
35 DWRITE_READING_DIRECTION TextAnalysisSource::GetParagraphReadingDirection() {
36 return reading_direction_;
37 }
38
39 HRESULT TextAnalysisSource::GetTextAtPosition(UINT32 text_position,
40 const WCHAR** text_string,
41 UINT32* text_length) {
42 if (!text_length || !text_string)
43 return E_INVALIDARG;
44 if (text_position >= text_.length()) {
45 *text_string = nullptr;
46 *text_length = 0;
47 return S_OK;
48 }
49 *text_string = text_.c_str() + text_position;
50 *text_length = text_.length() - text_position;
51 return S_OK;
52 }
53
54 HRESULT TextAnalysisSource::GetTextBeforePosition(UINT32 text_position,
55 const WCHAR** text_string,
56 UINT32* text_length) {
57 if (!text_length || !text_string)
58 return E_INVALIDARG;
59 if (text_position < 1 || text_position > text_.length()) {
60 *text_string = nullptr;
61 *text_length = 0;
62 return S_OK;
63 }
64 *text_string = text_.c_str();
65 *text_length = text_position;
66 return S_OK;
67 }
68
69 HRESULT TextAnalysisSource::RuntimeClassInitialize(
70 const base::string16& text,
71 const base::string16& locale_name,
72 IDWriteNumberSubstitution* number_substitution,
73 DWRITE_READING_DIRECTION reading_direction) {
74 DCHECK(number_substitution);
75 text_ = text;
76 locale_name_ = locale_name;
77 number_substitution_ = number_substitution;
78 reading_direction_ = reading_direction;
79 return S_OK;
80 }
81
82 } // namespace content
OLDNEW
« no previous file with comments | « content/common/dwrite_text_analysis_source_win.h ('k') | content/content_child.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698