| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 size_t length, | 129 size_t length, |
| 130 TextDirection direction, | 130 TextDirection direction, |
| 131 bool& isAfterExpansion, | 131 bool& isAfterExpansion, |
| 132 const TextJustify textJustify) { | 132 const TextJustify textJustify) { |
| 133 unsigned count = 0; | 133 unsigned count = 0; |
| 134 if (textJustify == TextJustifyDistribute) { | 134 if (textJustify == TextJustifyDistribute) { |
| 135 isAfterExpansion = true; | 135 isAfterExpansion = true; |
| 136 return length; | 136 return length; |
| 137 } | 137 } |
| 138 | 138 |
| 139 if (direction == TextDirection::Ltr) { | 139 if (direction == TextDirection::kLtr) { |
| 140 for (size_t i = 0; i < length; ++i) { | 140 for (size_t i = 0; i < length; ++i) { |
| 141 if (treatAsSpace(characters[i])) { | 141 if (treatAsSpace(characters[i])) { |
| 142 count++; | 142 count++; |
| 143 isAfterExpansion = true; | 143 isAfterExpansion = true; |
| 144 } else { | 144 } else { |
| 145 isAfterExpansion = false; | 145 isAfterExpansion = false; |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 } else { | 148 } else { |
| 149 for (size_t i = length; i > 0; --i) { | 149 for (size_t i = length; i > 0; --i) { |
| 150 if (treatAsSpace(characters[i - 1])) { | 150 if (treatAsSpace(characters[i - 1])) { |
| 151 count++; | 151 count++; |
| 152 isAfterExpansion = true; | 152 isAfterExpansion = true; |
| 153 } else { | 153 } else { |
| 154 isAfterExpansion = false; | 154 isAfterExpansion = false; |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 return count; | 159 return count; |
| 160 } | 160 } |
| 161 | 161 |
| 162 unsigned Character::expansionOpportunityCount(const UChar* characters, | 162 unsigned Character::expansionOpportunityCount(const UChar* characters, |
| 163 size_t length, | 163 size_t length, |
| 164 TextDirection direction, | 164 TextDirection direction, |
| 165 bool& isAfterExpansion, | 165 bool& isAfterExpansion, |
| 166 const TextJustify textJustify) { | 166 const TextJustify textJustify) { |
| 167 unsigned count = 0; | 167 unsigned count = 0; |
| 168 if (direction == TextDirection::Ltr) { | 168 if (direction == TextDirection::kLtr) { |
| 169 for (size_t i = 0; i < length; ++i) { | 169 for (size_t i = 0; i < length; ++i) { |
| 170 UChar32 character = characters[i]; | 170 UChar32 character = characters[i]; |
| 171 if (treatAsSpace(character)) { | 171 if (treatAsSpace(character)) { |
| 172 count++; | 172 count++; |
| 173 isAfterExpansion = true; | 173 isAfterExpansion = true; |
| 174 continue; | 174 continue; |
| 175 } | 175 } |
| 176 if (U16_IS_LEAD(character) && i + 1 < length && | 176 if (U16_IS_LEAD(character) && i + 1 < length && |
| 177 U16_IS_TRAIL(characters[i + 1])) { | 177 U16_IS_TRAIL(characters[i + 1])) { |
| 178 character = U16_GET_SUPPLEMENTARY(character, characters[i + 1]); | 178 character = U16_GET_SUPPLEMENTARY(character, characters[i + 1]); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 254 } |
| 255 | 255 |
| 256 bool Character::isCommonOrInheritedScript(UChar32 character) { | 256 bool Character::isCommonOrInheritedScript(UChar32 character) { |
| 257 ICUError status; | 257 ICUError status; |
| 258 UScriptCode script = uscript_getScript(character, &status); | 258 UScriptCode script = uscript_getScript(character, &status); |
| 259 return U_SUCCESS(status) && | 259 return U_SUCCESS(status) && |
| 260 (script == USCRIPT_COMMON || script == USCRIPT_INHERITED); | 260 (script == USCRIPT_COMMON || script == USCRIPT_INHERITED); |
| 261 } | 261 } |
| 262 | 262 |
| 263 } // namespace blink | 263 } // namespace blink |
| OLD | NEW |