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

Unified Diff: third_party/WebKit/Source/platform/fonts/Font.cpp

Issue 2888643004: [LayoutNG] Implement LayoutBR/preserved newlines and tabs (Closed)
Patch Set: Rebase Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/Font.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/fonts/Font.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/Font.cpp b/third_party/WebKit/Source/platform/fonts/Font.cpp
index d9722fa695f34fc21f9fe76583d9d9042620959b..d784d10f529aac34ca6a2e11466cf46d6dca317c 100644
--- a/third_party/WebKit/Source/platform/fonts/Font.cpp
+++ b/third_party/WebKit/Source/platform/fonts/Font.cpp
@@ -497,6 +497,26 @@ Vector<CharacterRange> Font::IndividualCharacterRanges(
return ranges;
}
+LayoutUnit Font::TabWidth(const TabSize& tab_size, LayoutUnit position) const {
+ const SimpleFontData* font_data = PrimaryFont();
+ if (!font_data)
+ return LayoutUnit::FromFloatCeil(GetFontDescription().LetterSpacing());
+ float base_tab_width = tab_size.GetPixelSize(font_data->SpaceWidth());
+ if (!base_tab_width)
+ return LayoutUnit::FromFloatCeil(GetFontDescription().LetterSpacing());
+
+ LayoutUnit distance_to_tab_stop = LayoutUnit::FromFloatFloor(
+ base_tab_width - fmodf(position, base_tab_width));
+
+ // Let the minimum width be the half of the space width so that it's always
+ // recognizable. if the distance to the next tab stop is less than that,
+ // advance an additional tab stop.
+ if (distance_to_tab_stop < font_data->SpaceWidth() / 2)
+ distance_to_tab_stop += base_tab_width;
+
+ return distance_to_tab_stop;
+}
+
bool Font::LoadingCustomFonts() const {
return font_fallback_list_ && font_fallback_list_->LoadingCustomFonts();
}
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/Font.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698