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

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

Issue 1196213002: Remove duplicate measure hyphen string method (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Making hyphenWidth as inline and removing static nature Created 5 years, 6 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 | « Source/core/layout/LayoutText.cpp ('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) 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. All r ight reserved. 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved.
4 * Copyright (C) 2010 Google Inc. All rights reserved. 4 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * Copyright (C) 2013 Adobe Systems Incorporated. 5 * Copyright (C) 2013 Adobe Systems Incorporated.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 489
490 inline float firstPositiveWidth(const WordMeasurements& wordMeasurements) 490 inline float firstPositiveWidth(const WordMeasurements& wordMeasurements)
491 { 491 {
492 for (size_t i = 0; i < wordMeasurements.size(); ++i) { 492 for (size_t i = 0; i < wordMeasurements.size(); ++i) {
493 if (wordMeasurements[i].width > 0) 493 if (wordMeasurements[i].width > 0)
494 return wordMeasurements[i].width; 494 return wordMeasurements[i].width;
495 } 495 }
496 return 0; 496 return 0;
497 } 497 }
498 498
499 inline float measureHyphenWidth(LayoutText* layoutText, const Font& font, TextDi rection textDirection)
500 {
501 const ComputedStyle& style = layoutText->styleRef();
502 return font.width(constructTextRun(layoutText, font,
503 style.hyphenString().string(), style, style.direction()));
504 }
505
506 ALWAYS_INLINE TextDirection textDirectionFromUnicode(WTF::Unicode::Direction dir ection) 499 ALWAYS_INLINE TextDirection textDirectionFromUnicode(WTF::Unicode::Direction dir ection)
507 { 500 {
508 return direction == WTF::Unicode::RightToLeft 501 return direction == WTF::Unicode::RightToLeft
509 || direction == WTF::Unicode::RightToLeftArabic ? RTL : LTR; 502 || direction == WTF::Unicode::RightToLeftArabic ? RTL : LTR;
510 } 503 }
511 504
512 ALWAYS_INLINE float textWidth(LayoutText* text, unsigned from, unsigned len, con st Font& font, float xPos, bool collapseWhiteSpace, HashSet<const SimpleFontData *>* fallbackFonts = nullptr, FloatRect* glyphBounds = nullptr) 505 ALWAYS_INLINE float textWidth(LayoutText* text, unsigned from, unsigned len, con st Font& font, float xPos, bool collapseWhiteSpace, HashSet<const SimpleFontData *>* fallbackFonts = nullptr, FloatRect* glyphBounds = nullptr)
513 { 506 {
514 if ((!from && len == text->textLength()) || text->style()->hasTextCombine()) 507 if ((!from && len == text->textLength()) || text->style()->hasTextCombine())
515 return text->width(from, len, font, xPos, text->style()->direction(), fa llbackFonts, glyphBounds); 508 return text->width(from, len, font, xPos, text->style()->direction(), fa llbackFonts, glyphBounds);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 for (; m_current.offset() < layoutText->textLength(); m_current.fastIncremen tInTextNode()) { 580 for (; m_current.offset() < layoutText->textLength(); m_current.fastIncremen tInTextNode()) {
588 bool previousCharacterIsSpace = m_currentCharacterIsSpace; 581 bool previousCharacterIsSpace = m_currentCharacterIsSpace;
589 bool previousCharacterShouldCollapseIfPreWap = m_currentCharacterShouldC ollapseIfPreWap; 582 bool previousCharacterShouldCollapseIfPreWap = m_currentCharacterShouldC ollapseIfPreWap;
590 UChar c = m_current.current(); 583 UChar c = m_current.current();
591 m_currentCharacterShouldCollapseIfPreWap = m_currentCharacterIsSpace = c == spaceCharacter || c == tabulationCharacter || (!m_preservesNewline && (c == newlineCharacter)); 584 m_currentCharacterShouldCollapseIfPreWap = m_currentCharacterIsSpace = c == spaceCharacter || c == tabulationCharacter || (!m_preservesNewline && (c == newlineCharacter));
592 585
593 if (!m_collapseWhiteSpace || !m_currentCharacterIsSpace) 586 if (!m_collapseWhiteSpace || !m_currentCharacterIsSpace)
594 m_lineInfo.setEmpty(false, m_block, &m_width); 587 m_lineInfo.setEmpty(false, m_block, &m_width);
595 588
596 if (c == softHyphenCharacter && m_autoWrap && !hyphenWidth) { 589 if (c == softHyphenCharacter && m_autoWrap && !hyphenWidth) {
597 hyphenWidth = measureHyphenWidth(layoutText, font, textDirectionFrom Unicode(m_resolver.position().direction())); 590 hyphenWidth = layoutText->hyphenWidth(font, textDirectionFromUnicode (m_resolver.position().direction()));
598 m_width.addUncommittedWidth(hyphenWidth); 591 m_width.addUncommittedWidth(hyphenWidth);
599 } 592 }
600 593
601 bool applyWordSpacing = false; 594 bool applyWordSpacing = false;
602 595
603 if (breakWords && !midWordBreak) { 596 if (breakWords && !midWordBreak) {
604 wrapW += charWidth; 597 wrapW += charWidth;
605 bool midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && m_current .offset() + 1 < layoutText->textLength() && U16_IS_TRAIL((*layoutText)[m_current .offset() + 1]); 598 bool midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && m_current .offset() + 1 < layoutText->textLength() && U16_IS_TRAIL((*layoutText)[m_current .offset() + 1]);
606 charWidth = textWidth(layoutText, m_current.offset(), midWordBreakIs BeforeSurrogatePair ? 2 : 1, font, m_width.committedWidth() + wrapW, m_collapseW hiteSpace); 599 charWidth = textWidth(layoutText, m_current.offset(), midWordBreakIs BeforeSurrogatePair ? 2 : 1, font, m_width.committedWidth() + wrapW, m_collapseW hiteSpace);
607 midWordBreak = m_width.committedWidth() + wrapW + charWidth > m_widt h.availableWidth(); 600 midWordBreak = m_width.committedWidth() + wrapW + charWidth > m_widt h.availableWidth();
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 891
899 if (style.textIndentType() == TextIndentHanging) 892 if (style.textIndentType() == TextIndentHanging)
900 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In dentText; 893 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In dentText;
901 894
902 return shouldIndentText; 895 return shouldIndentText;
903 } 896 }
904 897
905 } 898 }
906 899
907 #endif // BreakingContextInlineHeaders_h 900 #endif // BreakingContextInlineHeaders_h
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutText.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698