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

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

Issue 593673003: Different fonts selected for width calculation and actual painting (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@ellipsis_not_present
Patch Set: Rebase patch Created 6 years, 2 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 * (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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 713
714 ALWAYS_INLINE float RenderText::widthFromCache(const Font& f, int start, int len , float xPos, TextDirection textDirection, HashSet<const SimpleFontData*>* fallb ackFonts, GlyphOverflow* glyphOverflow) const 714 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 { 715 {
716 if (style()->hasTextCombine() && isCombineText()) { 716 if (style()->hasTextCombine() && isCombineText()) {
717 const RenderCombineText* combineText = toRenderCombineText(this); 717 const RenderCombineText* combineText = toRenderCombineText(this);
718 if (combineText->isCombined()) 718 if (combineText->isCombined())
719 return combineText->combinedTextWidth(f); 719 return combineText->combinedTextWidth(f);
720 } 720 }
721 721
722 if (f.isFixedPitch() && f.fontDescription().variant() == FontVariantNormal & & m_isAllASCII && (!glyphOverflow || !glyphOverflow->computeBounds)) { 722 if (f.isFixedPitch() && f.fontDescription().variant() == FontVariantNormal & & m_isAllASCII && (!glyphOverflow || !glyphOverflow->computeBounds)) {
723 bool missingGlyph = false;
723 float monospaceCharacterWidth = f.spaceWidth(); 724 float monospaceCharacterWidth = f.spaceWidth();
724 float w = 0; 725 float w = 0;
725 bool isSpace; 726 bool isSpace;
726 ASSERT(m_text); 727 ASSERT(m_text);
727 StringImpl& text = *m_text.impl(); 728 StringImpl& text = *m_text.impl();
729 RenderStyle * renderStyle = style();
728 for (int i = start; i < start + len; i++) { 730 for (int i = start; i < start + len; i++) {
729 char c = text[i]; 731 char c = text[i];
732 // If glyph is not present in primary font then we cannot calculate width based on primary
733 // font property, we need to call "width" method of Font Object.
734 if (!f.primaryFontHasGlyphForCharacter(text[i])) {
735 missingGlyph = true;
736 break;
737 }
730 if (c <= space) { 738 if (c <= space) {
731 if (c == space || c == newlineCharacter) { 739 if (c == space || c == newlineCharacter) {
732 w += monospaceCharacterWidth; 740 w += monospaceCharacterWidth;
733 isSpace = true; 741 isSpace = true;
734 } else if (c == characterTabulation) { 742 } else if (c == characterTabulation) {
735 if (style()->collapseWhiteSpace()) { 743 if (renderStyle->collapseWhiteSpace()) {
736 w += monospaceCharacterWidth; 744 w += monospaceCharacterWidth;
737 isSpace = true; 745 isSpace = true;
738 } else { 746 } else {
739 w += f.tabWidth(style()->tabSize(), xPos + w); 747 w += f.tabWidth(renderStyle->tabSize(), xPos + w);
740 isSpace = false; 748 isSpace = false;
741 } 749 }
742 } else 750 } else
743 isSpace = false; 751 isSpace = false;
744 } else { 752 } else {
745 w += monospaceCharacterWidth; 753 w += monospaceCharacterWidth;
746 isSpace = false; 754 isSpace = false;
747 } 755 }
748 if (isSpace && i > start) 756 if (isSpace && i > start)
749 w += f.fontDescription().wordSpacing(); 757 w += f.fontDescription().wordSpacing();
750 } 758 }
751 return w; 759 if (!missingGlyph)
760 return w;
752 } 761 }
753 762
754 TextRun run = constructTextRun(const_cast<RenderText*>(this), f, this, start , len, style(), textDirection); 763 TextRun run = constructTextRun(const_cast<RenderText*>(this), f, this, start , len, style(), textDirection);
755 run.setCharactersLength(textLength() - start); 764 run.setCharactersLength(textLength() - start);
756 ASSERT(run.charactersLength() >= run.length()); 765 ASSERT(run.charactersLength() >= run.length());
757 766
758 run.setCharacterScanForCodePath(!canUseSimpleFontCodePath()); 767 run.setCharacterScanForCodePath(!canUseSimpleFontCodePath());
759 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize()); 768 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize());
760 run.setXPos(xPos); 769 run.setXPos(xPos);
761 FontCachePurgePreventer fontCachePurgePreventer; 770 FontCachePurgePreventer fontCachePurgePreventer;
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 } 1871 }
1863 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); 1872 secureTextTimer->restartWithNewText(lastTypedCharacterOffset);
1864 } 1873 }
1865 1874
1866 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() 1875 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox()
1867 { 1876 {
1868 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); 1877 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox);
1869 } 1878 }
1870 1879
1871 } // namespace blink 1880 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698