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

Side by Side Diff: Source/core/rendering/RenderText.cpp

Issue 741803003: Revert of Reland of Different fonts selected for width calculation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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/rendering/RenderBlockLineLayout.cpp ('k') | Source/wtf/unicode/CharacterNames.h » ('j') | 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 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 714
715 ALWAYS_INLINE float RenderText::widthFromCache(const Font& f, int start, int len , float xPos, TextDirection textDirection, HashSet<const SimpleFontData*>* fallb ackFonts, GlyphOverflow* glyphOverflow) const 715 ALWAYS_INLINE float RenderText::widthFromCache(const Font& f, int start, int len , float xPos, TextDirection textDirection, HashSet<const SimpleFontData*>* fallb ackFonts, GlyphOverflow* glyphOverflow) const
716 { 716 {
717 if (style()->hasTextCombine() && isCombineText()) { 717 if (style()->hasTextCombine() && isCombineText()) {
718 const RenderCombineText* combineText = toRenderCombineText(this); 718 const RenderCombineText* combineText = toRenderCombineText(this);
719 if (combineText->isCombined()) 719 if (combineText->isCombined())
720 return combineText->combinedTextWidth(f); 720 return combineText->combinedTextWidth(f);
721 } 721 }
722 722
723 if (f.isFixedPitch() && f.fontDescription().variant() == FontVariantNormal & & m_isAllASCII && (!glyphOverflow || !glyphOverflow->computeBounds)) { 723 if (f.isFixedPitch() && f.fontDescription().variant() == FontVariantNormal & & m_isAllASCII && (!glyphOverflow || !glyphOverflow->computeBounds)) {
724 bool missingGlyph = false;
725 float monospaceCharacterWidth = f.spaceWidth(); 724 float monospaceCharacterWidth = f.spaceWidth();
726 float w = 0; 725 float w = 0;
727 bool isSpace; 726 bool isSpace;
728 ASSERT(m_text); 727 ASSERT(m_text);
729 StringImpl& text = *m_text.impl(); 728 StringImpl& text = *m_text.impl();
730 RenderStyle * renderStyle = style();
731 for (int i = start; i < start + len; i++) { 729 for (int i = start; i < start + len; i++) {
732 char c = text[i]; 730 char c = text[i];
733 // If glyph is not present in primary font then we cannot calculate width based on primary
734 // font property, we need to call "width" method of Font Object.
735 if (!f.primaryFontHasGlyphForCharacter(text[i])) {
736 missingGlyph = true;
737 break;
738 }
739 if (c <= space) { 731 if (c <= space) {
740 if (c == space || c == newlineCharacter) { 732 if (c == space || c == newlineCharacter) {
741 w += monospaceCharacterWidth; 733 w += monospaceCharacterWidth;
742 isSpace = true; 734 isSpace = true;
743 } else if (c == characterTabulation) { 735 } else if (c == characterTabulation) {
744 if (renderStyle->collapseWhiteSpace()) { 736 if (style()->collapseWhiteSpace()) {
745 w += monospaceCharacterWidth; 737 w += monospaceCharacterWidth;
746 isSpace = true; 738 isSpace = true;
747 } else { 739 } else {
748 w += f.tabWidth(renderStyle->tabSize(), xPos + w); 740 w += f.tabWidth(style()->tabSize(), xPos + w);
749 isSpace = false; 741 isSpace = false;
750 } 742 }
751 } else 743 } else
752 isSpace = false; 744 isSpace = false;
753 } else { 745 } else {
754 w += monospaceCharacterWidth; 746 w += monospaceCharacterWidth;
755 isSpace = false; 747 isSpace = false;
756 } 748 }
757 if (isSpace && i > start) 749 if (isSpace && i > start)
758 w += f.fontDescription().wordSpacing(); 750 w += f.fontDescription().wordSpacing();
759 } 751 }
760 if (!missingGlyph) 752 return w;
761 return w;
762 } 753 }
763 754
764 TextRun run = constructTextRun(const_cast<RenderText*>(this), f, this, start , len, style(), textDirection); 755 TextRun run = constructTextRun(const_cast<RenderText*>(this), f, this, start , len, style(), textDirection);
765 run.setCharactersLength(textLength() - start); 756 run.setCharactersLength(textLength() - start);
766 ASSERT(run.charactersLength() >= run.length()); 757 ASSERT(run.charactersLength() >= run.length());
767 758
768 run.setCharacterScanForCodePath(!canUseSimpleFontCodePath()); 759 run.setCharacterScanForCodePath(!canUseSimpleFontCodePath());
769 run.setUseComplexCodePath(!canUseSimpleFontCodePath()); 760 run.setUseComplexCodePath(!canUseSimpleFontCodePath());
770 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize()); 761 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize());
771 run.setXPos(xPos); 762 run.setXPos(xPos);
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 } 1872 }
1882 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); 1873 secureTextTimer->restartWithNewText(lastTypedCharacterOffset);
1883 } 1874 }
1884 1875
1885 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() 1876 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox()
1886 { 1877 {
1887 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); 1878 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox);
1888 } 1879 }
1889 1880
1890 } // namespace blink 1881 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlockLineLayout.cpp ('k') | Source/wtf/unicode/CharacterNames.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698