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

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

Issue 2615813003: Migrate WTF::Vector::append() to ::push_back() [part 14 of N] (Closed)
Patch Set: rebase, small fix in FontSettings.h Created 3 years, 11 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 "platform/fonts/Font.h" 7 #include "platform/fonts/Font.h"
8 #include "wtf/text/StringView.h" 8 #include "wtf/text/StringView.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 Vector<size_t, 8> Hyphenation::hyphenLocations(const StringView& text) const { 12 Vector<size_t, 8> Hyphenation::hyphenLocations(const StringView& text) const {
13 Vector<size_t, 8> hyphenLocations; 13 Vector<size_t, 8> hyphenLocations;
14 size_t hyphenLocation = text.length(); 14 size_t hyphenLocation = text.length();
15 if (hyphenLocation <= minimumSuffixLength) 15 if (hyphenLocation <= minimumSuffixLength)
16 return hyphenLocations; 16 return hyphenLocations;
17 hyphenLocation -= minimumSuffixLength; 17 hyphenLocation -= minimumSuffixLength;
18 18
19 while ((hyphenLocation = lastHyphenLocation(text, hyphenLocation)) >= 19 while ((hyphenLocation = lastHyphenLocation(text, hyphenLocation)) >=
20 minimumPrefixLength) 20 minimumPrefixLength)
21 hyphenLocations.append(hyphenLocation); 21 hyphenLocations.push_back(hyphenLocation);
22 22
23 return hyphenLocations; 23 return hyphenLocations;
24 } 24 }
25 25
26 int Hyphenation::minimumPrefixWidth(const Font& font) { 26 int Hyphenation::minimumPrefixWidth(const Font& font) {
27 // If the maximum width available for the prefix before the hyphen is small, 27 // If the maximum width available for the prefix before the hyphen is small,
28 // then it is very unlikely that an hyphenation opportunity exists, so do not 28 // then it is very unlikely that an hyphenation opportunity exists, so do not
29 // bother to look for it. These are heuristic numbers for performance added 29 // bother to look for it. These are heuristic numbers for performance added
30 // in http://wkb.ug/45606 30 // in http://wkb.ug/45606
31 const int minimumPrefixWidthNumerator = 5; 31 const int minimumPrefixWidthNumerator = 5;
32 const int minimumPrefixWidthDenominator = 4; 32 const int minimumPrefixWidthDenominator = 4;
33 return font.getFontDescription().computedPixelSize() * 33 return font.getFontDescription().computedPixelSize() *
34 minimumPrefixWidthNumerator / minimumPrefixWidthDenominator; 34 minimumPrefixWidthNumerator / minimumPrefixWidthDenominator;
35 } 35 }
36 36
37 } // namespace blink 37 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/text/DateTimeFormatTest.cpp ('k') | third_party/WebKit/Source/platform/text/LocaleICU.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698