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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
724 float monospaceCharacterWidth = f.spaceWidth(); | 725 float monospaceCharacterWidth = f.spaceWidth(); |
725 float w = 0; | 726 float w = 0; |
726 bool isSpace; | 727 bool isSpace; |
727 ASSERT(m_text); | 728 ASSERT(m_text); |
728 StringImpl& text = *m_text.impl(); | 729 StringImpl& text = *m_text.impl(); |
| 730 RenderStyle* renderStyle = style(); |
729 for (int i = start; i < start + len; i++) { | 731 for (int i = start; i < start + len; i++) { |
730 char c = text[i]; | 732 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 } |
731 if (c <= space) { | 739 if (c <= space) { |
732 if (c == space || c == newlineCharacter) { | 740 if (c == space || c == newlineCharacter) { |
733 w += monospaceCharacterWidth; | 741 w += monospaceCharacterWidth; |
734 isSpace = true; | 742 isSpace = true; |
735 } else if (c == characterTabulation) { | 743 } else if (c == characterTabulation) { |
736 if (style()->collapseWhiteSpace()) { | 744 if (renderStyle->collapseWhiteSpace()) { |
737 w += monospaceCharacterWidth; | 745 w += monospaceCharacterWidth; |
738 isSpace = true; | 746 isSpace = true; |
739 } else { | 747 } else { |
740 w += f.tabWidth(style()->tabSize(), xPos + w); | 748 w += f.tabWidth(renderStyle->tabSize(), xPos + w); |
741 isSpace = false; | 749 isSpace = false; |
742 } | 750 } |
743 } else | 751 } else |
744 isSpace = false; | 752 isSpace = false; |
745 } else { | 753 } else { |
746 w += monospaceCharacterWidth; | 754 w += monospaceCharacterWidth; |
747 isSpace = false; | 755 isSpace = false; |
748 } | 756 } |
749 if (isSpace && i > start) | 757 if (isSpace && i > start) |
750 w += f.fontDescription().wordSpacing(); | 758 w += f.fontDescription().wordSpacing(); |
751 } | 759 } |
752 return w; | 760 if (!missingGlyph) |
| 761 return w; |
753 } | 762 } |
754 | 763 |
755 TextRun run = constructTextRun(const_cast<RenderText*>(this), f, this, start
, len, style(), textDirection); | 764 TextRun run = constructTextRun(const_cast<RenderText*>(this), f, this, start
, len, style(), textDirection); |
756 run.setCharactersLength(textLength() - start); | 765 run.setCharactersLength(textLength() - start); |
757 ASSERT(run.charactersLength() >= run.length()); | 766 ASSERT(run.charactersLength() >= run.length()); |
758 | 767 |
759 run.setCharacterScanForCodePath(!canUseSimpleFontCodePath()); | 768 run.setCharacterScanForCodePath(!canUseSimpleFontCodePath()); |
760 run.setUseComplexCodePath(!canUseSimpleFontCodePath()); | 769 run.setUseComplexCodePath(!canUseSimpleFontCodePath()); |
761 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize()); | 770 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize()); |
762 run.setXPos(xPos); | 771 run.setXPos(xPos); |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 } | 1881 } |
1873 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); | 1882 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); |
1874 } | 1883 } |
1875 | 1884 |
1876 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() | 1885 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() |
1877 { | 1886 { |
1878 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); | 1887 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); |
1879 } | 1888 } |
1880 | 1889 |
1881 } // namespace blink | 1890 } // namespace blink |
OLD | NEW |