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

Side by Side Diff: third_party/WebKit/Source/platform/text/Hyphenation.cpp

Issue 1994483002: Compute min-content width when hyphenation is enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test Created 4 years, 7 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 // 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
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,
38 size_t minimumPrefixLength, size_t minimumSuffixLength) const
39 {
40 Vector<size_t, 8> hyphenLocations;
41 size_t hyphenLocation = text.length();
42 if (hyphenLocation <= minimumSuffixLength)
43 return hyphenLocations;
44 hyphenLocation -= minimumSuffixLength;
45
46 while ((hyphenLocation = lastHyphenLocation(text, hyphenLocation)) >= minimu mPrefixLength)
47 hyphenLocations.append(hyphenLocation);
48
49 return hyphenLocations;
50 }
51
37 } // namespace blink 52 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698