| 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 m_textJustify = run.getTextJustify(); | 38 m_textJustify = run.getTextJustify(); |
| 39 m_isAfterExpansion = !run.allowsLeadingExpansion(); | 39 m_isAfterExpansion = !run.allowsLeadingExpansion(); |
| 40 | 40 |
| 41 bool isAfterExpansion = m_isAfterExpansion; | 41 bool isAfterExpansion = m_isAfterExpansion; |
| 42 m_expansionOpportunityCount = | 42 m_expansionOpportunityCount = |
| 43 Character::expansionOpportunityCount(run, isAfterExpansion); | 43 Character::expansionOpportunityCount(run, isAfterExpansion); |
| 44 if (isAfterExpansion && !run.allowsTrailingExpansion()) { | 44 if (isAfterExpansion && !run.allowsTrailingExpansion()) { |
| 45 ASSERT(m_expansionOpportunityCount > 0); | 45 DCHECK_GT(m_expansionOpportunityCount, 0u); |
| 46 --m_expansionOpportunityCount; | 46 --m_expansionOpportunityCount; |
| 47 } | 47 } |
| 48 | 48 |
| 49 if (m_expansionOpportunityCount) | 49 if (m_expansionOpportunityCount) |
| 50 m_expansionPerOpportunity = m_expansion / m_expansionOpportunityCount; | 50 m_expansionPerOpportunity = m_expansion / m_expansionOpportunityCount; |
| 51 } | 51 } |
| 52 | 52 |
| 53 float ShapeResultSpacing::nextExpansion() { | 53 float ShapeResultSpacing::nextExpansion() { |
| 54 if (!m_expansionOpportunityCount) { | 54 if (!m_expansionOpportunityCount) { |
| 55 ASSERT_NOT_REACHED(); | 55 NOTREACHED(); |
| 56 return 0; | 56 return 0; |
| 57 } | 57 } |
| 58 | 58 |
| 59 m_isAfterExpansion = true; | 59 m_isAfterExpansion = true; |
| 60 | 60 |
| 61 if (!--m_expansionOpportunityCount) { | 61 if (!--m_expansionOpportunityCount) { |
| 62 float remaining = m_expansion; | 62 float remaining = m_expansion; |
| 63 m_expansion = 0; | 63 m_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 += expandBefore; | 123 spacing += expandBefore; |
| 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 |