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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/Font.h

Issue 2331783002: Fix tab is invisible when the next stop is close (Closed)
Patch Set: Cleanup Created 4 years, 3 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 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) 2008 Holger Hans Peter Freyther 6 * Copyright (C) 2008 Holger Hans Peter Freyther
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 return m_fontFallbackList ? m_fontFallbackList->getFontSelector() : 0; 187 return m_fontFallbackList ? m_fontFallbackList->getFontSelector() : 0;
188 } 188 }
189 189
190 inline float Font::tabWidth(const SimpleFontData& fontData, const TabSize& tabSi ze, float position) const 190 inline float Font::tabWidth(const SimpleFontData& fontData, const TabSize& tabSi ze, float position) const
191 { 191 {
192 float baseTabWidth = tabSize.getPixelSize(fontData.spaceWidth()); 192 float baseTabWidth = tabSize.getPixelSize(fontData.spaceWidth());
193 if (!baseTabWidth) 193 if (!baseTabWidth)
194 return getFontDescription().letterSpacing(); 194 return getFontDescription().letterSpacing();
195 float distanceToTabStop = baseTabWidth - fmodf(position, baseTabWidth); 195 float distanceToTabStop = baseTabWidth - fmodf(position, baseTabWidth);
196 196
197 // The smallest allowable tab space is letterSpacing() (but must be at least one layout unit). 197 // Let the minimum width be the half of the space width so that it's always recognizable.
198 // if the distance to the next tab stop is less than that, advance an additi onal tab stop. 198 // if the distance to the next tab stop is less than that, advance an additi onal tab stop.
199 if (distanceToTabStop < std::max(getFontDescription().letterSpacing(), Layou tUnit::epsilon())) 199 if (distanceToTabStop < fontData.spaceWidth() / 2)
200 distanceToTabStop += baseTabWidth; 200 distanceToTabStop += baseTabWidth;
201 201
202 return distanceToTabStop; 202 return distanceToTabStop;
203 } 203 }
204 204
205 } // namespace blink 205 } // namespace blink
206 206
207 #endif 207 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698