| 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/text/Hyphenation.h" | 5 #include "platform/text/Hyphenation.h" |
| 6 | 6 |
| 7 #include "wtf/text/StringView.h" | 7 #include "wtf/text/StringView.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 void Hyphenation::setForTesting(const AtomicString& locale, PassRefPtr<Hyphenati
on> hyphenation) | 27 void Hyphenation::setForTesting(const AtomicString& locale, PassRefPtr<Hyphenati
on> hyphenation) |
| 28 { | 28 { |
| 29 getHyphenationMap().set(locale, hyphenation); | 29 getHyphenationMap().set(locale, hyphenation); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void Hyphenation::clearForTesting() | 32 void Hyphenation::clearForTesting() |
| 33 { | 33 { |
| 34 getHyphenationMap().clear(); | 34 getHyphenationMap().clear(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 Vector<size_t, 8> Hyphenation::hyphenLocations(const StringView& text) const |
| 38 { |
| 39 Vector<size_t, 8> hyphenLocations; |
| 40 size_t hyphenLocation = text.length(); |
| 41 if (hyphenLocation <= minimumSuffixLength) |
| 42 return hyphenLocations; |
| 43 hyphenLocation -= minimumSuffixLength; |
| 44 |
| 45 while ((hyphenLocation = lastHyphenLocation(text, hyphenLocation)) >= minimu
mPrefixLength) |
| 46 hyphenLocations.append(hyphenLocation); |
| 47 |
| 48 return hyphenLocations; |
| 49 } |
| 50 |
| 37 } // namespace blink | 51 } // namespace blink |
| OLD | NEW |