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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.cpp

Issue 2807913002: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/fonts (Closed)
Patch Set: rebase Created 3 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
1 /* 1 /*
2 * Copyright (c) 2012 Google Inc. All rights reserved. 2 * Copyright (c) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 template <typename T> 65 template <typename T>
66 class HarfBuzzScopedPtr { 66 class HarfBuzzScopedPtr {
67 STACK_ALLOCATED(); 67 STACK_ALLOCATED();
68 WTF_MAKE_NONCOPYABLE(HarfBuzzScopedPtr); 68 WTF_MAKE_NONCOPYABLE(HarfBuzzScopedPtr);
69 69
70 public: 70 public:
71 typedef void (*DestroyFunction)(T*); 71 typedef void (*DestroyFunction)(T*);
72 72
73 HarfBuzzScopedPtr(T* ptr, DestroyFunction destroy) 73 HarfBuzzScopedPtr(T* ptr, DestroyFunction destroy)
74 : ptr_(ptr), destroy_(destroy) { 74 : ptr_(ptr), destroy_(destroy) {
75 ASSERT(destroy_); 75 DCHECK(destroy_);
76 } 76 }
77 ~HarfBuzzScopedPtr() { 77 ~HarfBuzzScopedPtr() {
78 if (ptr_) 78 if (ptr_)
79 (*destroy_)(ptr_); 79 (*destroy_)(ptr_);
80 } 80 }
81 81
82 T* Get() { return ptr_; } 82 T* Get() { return ptr_; }
83 void Set(T* ptr) { ptr_ = ptr; } 83 void Set(T* ptr) { ptr_ = ptr; }
84 84
85 private: 85 private:
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 252
253 if (current_cluster_result == kShaped && !is_last_resort) { 253 if (current_cluster_result == kShaped && !is_last_resort) {
254 // Now it's clear that we need to continue processing. 254 // Now it's clear that we need to continue processing.
255 if (!font_cycle_queued) { 255 if (!font_cycle_queued) {
256 range_data->holes_queue.push_back( 256 range_data->holes_queue.push_back(
257 HolesQueueItem(kHolesQueueNextFont, 0, 0)); 257 HolesQueueItem(kHolesQueueNextFont, 0, 0));
258 font_cycle_queued = true; 258 font_cycle_queued = true;
259 } 259 }
260 260
261 // Here we need to put character positions. 261 // Here we need to put character positions.
262 ASSERT(num_characters); 262 DCHECK(num_characters);
263 range_data->holes_queue.push_back( 263 range_data->holes_queue.push_back(
264 HolesQueueItem(kHolesQueueRange, start_index, num_characters)); 264 HolesQueueItem(kHolesQueueRange, start_index, num_characters));
265 } 265 }
266 266
267 // If numCharacters is 0, that means we hit a NotDef before shaping the 267 // If numCharacters is 0, that means we hit a NotDef before shaping the
268 // whole grapheme. We do not append it here. For the next glyph we 268 // whole grapheme. We do not append it here. For the next glyph we
269 // encounter, atChange will be true, and the characters corresponding to 269 // encounter, atChange will be true, and the characters corresponding to
270 // the grapheme will be added to the TODO queue again, attempting to 270 // the grapheme will be added to the TODO queue again, attempting to
271 // shape the whole grapheme with the next font. 271 // shape the whole grapheme with the next font.
272 // When we're getting here with the last resort font, we have no other 272 // When we're getting here with the last resort font, we have no other
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return false; 308 return false;
309 309
310 hint.Clear(); 310 hint.Clear();
311 311
312 size_t num_chars_added = 0; 312 size_t num_chars_added = 0;
313 for (auto it = holes_queue.begin(); it != holes_queue.end(); ++it) { 313 for (auto it = holes_queue.begin(); it != holes_queue.end(); ++it) {
314 if (it->action_ == kHolesQueueNextFont) 314 if (it->action_ == kHolesQueueNextFont)
315 break; 315 break;
316 316
317 UChar32 hint_char; 317 UChar32 hint_char;
318 RELEASE_ASSERT(it->start_index_ + it->num_characters_ <= text_length_); 318 CHECK_LE((it->start_index_ + it->num_characters_), text_length_);
319 UTF16TextIterator iterator(text_ + it->start_index_, it->num_characters_); 319 UTF16TextIterator iterator(text_ + it->start_index_, it->num_characters_);
320 while (iterator.Consume(hint_char)) { 320 while (iterator.Consume(hint_char)) {
321 hint.push_back(hint_char); 321 hint.push_back(hint_char);
322 num_chars_added++; 322 num_chars_added++;
323 iterator.Advance(); 323 iterator.Advance();
324 } 324 }
325 } 325 }
326 return num_chars_added > 0; 326 return num_chars_added > 0;
327 } 327 }
328 328
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 } 713 }
714 return result.Release(); 714 return result.Release();
715 } 715 }
716 716
717 PassRefPtr<ShapeResult> HarfBuzzShaper::Shape(const Font* font, 717 PassRefPtr<ShapeResult> HarfBuzzShaper::Shape(const Font* font,
718 TextDirection direction) const { 718 TextDirection direction) const {
719 return Shape(font, direction, 0, text_length_); 719 return Shape(font, direction, 0, text_length_);
720 } 720 }
721 721
722 } // namespace blink 722 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698