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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/Font.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 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, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. 6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved.
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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 CachingWordShaper shaper(*this); 490 CachingWordShaper shaper(*this);
491 auto ranges = shaper.IndividualCharacterRanges(run); 491 auto ranges = shaper.IndividualCharacterRanges(run);
492 // The shaper should return ranges.size == run.length but on some platforms 492 // The shaper should return ranges.size == run.length but on some platforms
493 // (OSX10.9.5) we are seeing cases in the upper end of the unicode range 493 // (OSX10.9.5) we are seeing cases in the upper end of the unicode range
494 // where this is not true (see: crbug.com/620952). To catch these cases on 494 // where this is not true (see: crbug.com/620952). To catch these cases on
495 // more popular platforms, and to protect users, we are using a CHECK here. 495 // more popular platforms, and to protect users, we are using a CHECK here.
496 CHECK_EQ(ranges.size(), run.length()); 496 CHECK_EQ(ranges.size(), run.length());
497 return ranges; 497 return ranges;
498 } 498 }
499 499
500 LayoutUnit Font::TabWidth(const TabSize& tab_size, LayoutUnit position) const {
501 const SimpleFontData* font_data = PrimaryFont();
502 if (!font_data)
503 return LayoutUnit::FromFloatCeil(GetFontDescription().LetterSpacing());
504 float base_tab_width = tab_size.GetPixelSize(font_data->SpaceWidth());
505 if (!base_tab_width)
506 return LayoutUnit::FromFloatCeil(GetFontDescription().LetterSpacing());
507
508 LayoutUnit distance_to_tab_stop = LayoutUnit::FromFloatFloor(
509 base_tab_width - fmodf(position, base_tab_width));
510
511 // Let the minimum width be the half of the space width so that it's always
512 // recognizable. if the distance to the next tab stop is less than that,
513 // advance an additional tab stop.
514 if (distance_to_tab_stop < font_data->SpaceWidth() / 2)
515 distance_to_tab_stop += base_tab_width;
516
517 return distance_to_tab_stop;
518 }
519
500 bool Font::LoadingCustomFonts() const { 520 bool Font::LoadingCustomFonts() const {
501 return font_fallback_list_ && font_fallback_list_->LoadingCustomFonts(); 521 return font_fallback_list_ && font_fallback_list_->LoadingCustomFonts();
502 } 522 }
503 523
504 bool Font::IsFallbackValid() const { 524 bool Font::IsFallbackValid() const {
505 return !font_fallback_list_ || font_fallback_list_->IsValid(); 525 return !font_fallback_list_ || font_fallback_list_->IsValid();
506 } 526 }
507 527
508 } // namespace blink 528 } // namespace blink
OLDNEW
« 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