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

Side by Side Diff: third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h

Issue 2865923002: Move LocaleForLineBreakIterator() to ComputedStyle (Closed)
Patch Set: Revert ng changes 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
4 * All right reserved. 4 * All right reserved.
5 * Copyright (C) 2010 Google Inc. All rights reserved. 5 * Copyright (C) 2010 Google Inc. All rights reserved.
6 * Copyright (C) 2013 Adobe Systems Incorporated. 6 * Copyright (C) 2013 Adobe Systems Incorporated.
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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 } 737 }
738 738
739 return true; 739 return true;
740 } 740 }
741 741
742 ALWAYS_INLINE int LastBreakablePositionForBreakAll(LineLayoutText text, 742 ALWAYS_INLINE int LastBreakablePositionForBreakAll(LineLayoutText text,
743 const ComputedStyle& style, 743 const ComputedStyle& style,
744 int start, 744 int start,
745 int end) { 745 int end) {
746 LazyLineBreakIterator line_break_iterator(text.GetText(), 746 LazyLineBreakIterator line_break_iterator(text.GetText(),
747 LocaleForLineBreakIterator(style)); 747 style.LocaleForLineBreakIterator());
748 int last_breakable_position = 0, next_breakable_position = -1; 748 int last_breakable_position = 0, next_breakable_position = -1;
749 for (int i = start;; i = next_breakable_position + 1) { 749 for (int i = start;; i = next_breakable_position + 1) {
750 line_break_iterator.IsBreakable(i, next_breakable_position, 750 line_break_iterator.IsBreakable(i, next_breakable_position,
751 LineBreakType::kBreakAll); 751 LineBreakType::kBreakAll);
752 if (next_breakable_position == end) 752 if (next_breakable_position == end)
753 return end; 753 return end;
754 if (next_breakable_position < 0 || next_breakable_position > end) 754 if (next_breakable_position < 0 || next_breakable_position > end)
755 return last_breakable_position; 755 return last_breakable_position;
756 last_breakable_position = next_breakable_position; 756 last_breakable_position = next_breakable_position;
757 } 757 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 ALWAYS_INLINE bool BreakingContext::RewindToFirstMidWordBreak( 797 ALWAYS_INLINE bool BreakingContext::RewindToFirstMidWordBreak(
798 LineLayoutText text, 798 LineLayoutText text,
799 const ComputedStyle& style, 799 const ComputedStyle& style,
800 const Font& font, 800 const Font& font,
801 bool break_all, 801 bool break_all,
802 WordMeasurement& word_measurement) { 802 WordMeasurement& word_measurement) {
803 int start = word_measurement.start_offset; 803 int start = word_measurement.start_offset;
804 int end = CanMidWordBreakBefore(text) ? start : start + 1; 804 int end = CanMidWordBreakBefore(text) ? start : start + 1;
805 if (break_all) { 805 if (break_all) {
806 LazyLineBreakIterator line_break_iterator( 806 LazyLineBreakIterator line_break_iterator(
807 text.GetText(), LocaleForLineBreakIterator(style)); 807 text.GetText(), style.LocaleForLineBreakIterator());
808 int next_breakable = -1; 808 int next_breakable = -1;
809 line_break_iterator.IsBreakable(end, next_breakable, 809 line_break_iterator.IsBreakable(end, next_breakable,
810 LineBreakType::kBreakAll); 810 LineBreakType::kBreakAll);
811 if (next_breakable < 0) 811 if (next_breakable < 0)
812 return false; 812 return false;
813 end = next_breakable; 813 end = next_breakable;
814 } 814 }
815 if (end >= word_measurement.end_offset) 815 if (end >= word_measurement.end_offset)
816 return false; 816 return false;
817 817
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 if (layout_text.IsWordBreak()) { 989 if (layout_text.IsWordBreak()) {
990 width_.Commit(); 990 width_.Commit();
991 line_break_.MoveToStartOf(current_.GetLineLayoutItem()); 991 line_break_.MoveToStartOf(current_.GetLineLayoutItem());
992 DCHECK_EQ(current_.Offset(), layout_text.TextLength()); 992 DCHECK_EQ(current_.Offset(), layout_text.TextLength());
993 } 993 }
994 994
995 if (layout_text_info_.text_ != layout_text) { 995 if (layout_text_info_.text_ != layout_text) {
996 layout_text_info_.text_ = layout_text; 996 layout_text_info_.text_ = layout_text;
997 layout_text_info_.font_ = &font; 997 layout_text_info_.font_ = &font;
998 layout_text_info_.line_break_iterator_.ResetStringAndReleaseIterator( 998 layout_text_info_.line_break_iterator_.ResetStringAndReleaseIterator(
999 layout_text.GetText(), LocaleForLineBreakIterator(style)); 999 layout_text.GetText(), style.LocaleForLineBreakIterator());
1000 } else if (layout_text_info_.font_ != &font) { 1000 } else if (layout_text_info_.font_ != &font) {
1001 layout_text_info_.font_ = &font; 1001 layout_text_info_.font_ = &font;
1002 } 1002 }
1003 1003
1004 // Non-zero only when kerning is enabled, in which case we measure 1004 // Non-zero only when kerning is enabled, in which case we measure
1005 // words with their trailing space, then subtract its width. 1005 // words with their trailing space, then subtract its width.
1006 float word_trailing_space_width = 1006 float word_trailing_space_width =
1007 (font.GetFontDescription().GetTypesettingFeatures() & kKerning) 1007 (font.GetFontDescription().GetTypesettingFeatures() & kKerning)
1008 ? font.Width(ConstructTextRun(font, &kSpaceCharacter, 1, style, 1008 ? font.Width(ConstructTextRun(font, &kSpaceCharacter, 1, style,
1009 style.Direction())) + 1009 style.Direction())) +
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 1566
1567 if (style.GetTextIndentType() == kTextIndentHanging) 1567 if (style.GetTextIndentType() == kTextIndentHanging)
1568 indent_text = indent_text == kIndentText ? kDoNotIndentText : kIndentText; 1568 indent_text = indent_text == kIndentText ? kDoNotIndentText : kIndentText;
1569 1569
1570 return indent_text; 1570 return indent_text;
1571 } 1571 }
1572 1572
1573 } // namespace blink 1573 } // namespace blink
1574 1574
1575 #endif // BreakingContextInlineHeaders_h 1575 #endif // BreakingContextInlineHeaders_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutText.cpp ('k') | third_party/WebKit/Source/core/style/ComputedStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698