Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h" | 5 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 uint32_t index = family_index; | 234 uint32_t index = family_index; |
| 235 // CreateCustomFontCollection ends up calling | 235 // CreateCustomFontCollection ends up calling |
| 236 // DWriteFontCollectionProxy::CreateEnumeratorFromKey. | 236 // DWriteFontCollectionProxy::CreateEnumeratorFromKey. |
| 237 HRESULT hr = factory_->CreateCustomFontCollection( | 237 HRESULT hr = factory_->CreateCustomFontCollection( |
| 238 this /*collectionLoader*/, reinterpret_cast<const void*>(&index), | 238 this /*collectionLoader*/, reinterpret_cast<const void*>(&index), |
| 239 sizeof(index), containing_collection); | 239 sizeof(index), containing_collection); |
| 240 | 240 |
| 241 return SUCCEEDED(hr); | 241 return SUCCEEDED(hr); |
| 242 } | 242 } |
| 243 | 243 |
| 244 bool DWriteFontCollectionProxy::GetFontFamily(UINT32 family_index, | |
| 245 const base::string16& family_name, | |
| 246 IDWriteFontFamily** font_family) { | |
| 247 if (!CreateFamily(family_index)) | |
|
ananta
2016/04/12 23:44:39
Please check for valid parameters here, especially
Ilya Kulshin
2016/04/13 01:33:28
Added a dcheck that font_family is not null and fa
| |
| 248 return false; | |
| 249 | |
| 250 mswr::ComPtr<DWriteFontFamilyProxy>& family = families_[family_index]; | |
| 251 if (!family->IsLoaded() || family->GetName().empty()) | |
| 252 family->SetName(family_name); | |
| 253 | |
| 254 family.CopyTo(font_family); | |
| 255 return true; | |
| 256 } | |
| 257 | |
| 244 bool DWriteFontCollectionProxy::LoadFamilyNames( | 258 bool DWriteFontCollectionProxy::LoadFamilyNames( |
| 245 UINT32 family_index, | 259 UINT32 family_index, |
| 246 IDWriteLocalizedStrings** localized_strings) { | 260 IDWriteLocalizedStrings** localized_strings) { |
| 247 TRACE_EVENT0("dwrite", "FontProxy::LoadFamilyNames"); | 261 TRACE_EVENT0("dwrite", "FontProxy::LoadFamilyNames"); |
| 248 | 262 |
| 249 std::vector<std::pair<base::string16, base::string16>> strings; | 263 std::vector<std::pair<base::string16, base::string16>> strings; |
| 250 if (!GetSender()->Send( | 264 if (!GetSender()->Send( |
| 251 new DWriteFontProxyMsg_GetFamilyNames(family_index, &strings))) { | 265 new DWriteFontProxyMsg_GetFamilyNames(family_index, &strings))) { |
| 252 return false; | 266 return false; |
| 253 } | 267 } |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 | 544 |
| 531 HRESULT FontFileStream::RuntimeClassInitialize( | 545 HRESULT FontFileStream::RuntimeClassInitialize( |
| 532 const base::string16& file_name) { | 546 const base::string16& file_name) { |
| 533 data_.Initialize(base::FilePath(file_name)); | 547 data_.Initialize(base::FilePath(file_name)); |
| 534 if (!data_.IsValid()) | 548 if (!data_.IsValid()) |
| 535 return E_FAIL; | 549 return E_FAIL; |
| 536 return S_OK; | 550 return S_OK; |
| 537 } | 551 } |
| 538 | 552 |
| 539 } // namespace content | 553 } // namespace content |
| OLD | NEW |