OLD | NEW |
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 Loading... |
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.setUseComplexCodePath(!canUseSimpleFontCodePath()); | 768 run.setUseComplexCodePath(!canUseSimpleFontCodePath()); |
760 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize()); | 769 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize()); |
761 run.setXPos(xPos); | 770 run.setXPos(xPos); |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1863 } | 1872 } |
1864 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); | 1873 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); |
1865 } | 1874 } |
1866 | 1875 |
1867 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() | 1876 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() |
1868 { | 1877 { |
1869 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); | 1878 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); |
1870 } | 1879 } |
1871 | 1880 |
1872 } // namespace blink | 1881 } // namespace blink |
OLD | NEW |