OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "platform/fonts/shaping/ShapeResultSpacing.h" | 5 #include "platform/fonts/shaping/ShapeResultSpacing.h" |
6 | 6 |
7 #include "platform/fonts/FontDescription.h" | 7 #include "platform/fonts/FontDescription.h" |
8 #include "platform/text/TextRun.h" | 8 #include "platform/text/TextRun.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 24 matching lines...) Expand all Loading... |
35 return; | 35 return; |
36 | 36 |
37 // Setup for justifications (expansions.) | 37 // Setup for justifications (expansions.) |
38 text_justify_ = run.GetTextJustify(); | 38 text_justify_ = run.GetTextJustify(); |
39 is_after_expansion_ = !run.AllowsLeadingExpansion(); | 39 is_after_expansion_ = !run.AllowsLeadingExpansion(); |
40 | 40 |
41 bool is_after_expansion = is_after_expansion_; | 41 bool is_after_expansion = is_after_expansion_; |
42 expansion_opportunity_count_ = | 42 expansion_opportunity_count_ = |
43 Character::ExpansionOpportunityCount(run, is_after_expansion); | 43 Character::ExpansionOpportunityCount(run, is_after_expansion); |
44 if (is_after_expansion && !run.AllowsTrailingExpansion()) { | 44 if (is_after_expansion && !run.AllowsTrailingExpansion()) { |
45 ASSERT(expansion_opportunity_count_ > 0); | 45 DCHECK_GT(expansion_opportunity_count_, 0u); |
46 --expansion_opportunity_count_; | 46 --expansion_opportunity_count_; |
47 } | 47 } |
48 | 48 |
49 if (expansion_opportunity_count_) | 49 if (expansion_opportunity_count_) |
50 expansion_per_opportunity_ = expansion_ / expansion_opportunity_count_; | 50 expansion_per_opportunity_ = expansion_ / expansion_opportunity_count_; |
51 } | 51 } |
52 | 52 |
53 float ShapeResultSpacing::NextExpansion() { | 53 float ShapeResultSpacing::NextExpansion() { |
54 if (!expansion_opportunity_count_) { | 54 if (!expansion_opportunity_count_) { |
55 ASSERT_NOT_REACHED(); | 55 NOTREACHED(); |
56 return 0; | 56 return 0; |
57 } | 57 } |
58 | 58 |
59 is_after_expansion_ = true; | 59 is_after_expansion_ = true; |
60 | 60 |
61 if (!--expansion_opportunity_count_) { | 61 if (!--expansion_opportunity_count_) { |
62 float remaining = expansion_; | 62 float remaining = expansion_; |
63 expansion_ = 0; | 63 expansion_ = 0; |
64 return remaining; | 64 return remaining; |
65 } | 65 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 spacing += expand_before; | 123 spacing += expand_before; |
124 } | 124 } |
125 if (!HasExpansion()) | 125 if (!HasExpansion()) |
126 return spacing; | 126 return spacing; |
127 } | 127 } |
128 | 128 |
129 return spacing + NextExpansion(); | 129 return spacing + NextExpansion(); |
130 } | 130 } |
131 | 131 |
132 } // namespace blink | 132 } // namespace blink |
OLD | NEW |