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