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 int i = 0; | |
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(); |
728 for (int i = start; i < start + len; i++) { | 729 RenderStyle * renderStyle = style(); |
730 for (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 break; | |
730 if (c <= space) { | 736 if (c <= space) { |
731 if (c == space || c == newlineCharacter) { | 737 if (c == space || c == newlineCharacter) { |
732 w += monospaceCharacterWidth; | 738 w += monospaceCharacterWidth; |
733 isSpace = true; | 739 isSpace = true; |
734 } else if (c == characterTabulation) { | 740 } else if (c == characterTabulation) { |
735 if (style()->collapseWhiteSpace()) { | 741 if (renderStyle->collapseWhiteSpace()) { |
736 w += monospaceCharacterWidth; | 742 w += monospaceCharacterWidth; |
737 isSpace = true; | 743 isSpace = true; |
738 } else { | 744 } else { |
739 w += f.tabWidth(style()->tabSize(), xPos + w); | 745 w += f.tabWidth(renderStyle->tabSize(), xPos + w); |
740 isSpace = false; | 746 isSpace = false; |
741 } | 747 } |
742 } else | 748 } else |
743 isSpace = false; | 749 isSpace = false; |
744 } else { | 750 } else { |
745 w += monospaceCharacterWidth; | 751 w += monospaceCharacterWidth; |
746 isSpace = false; | 752 isSpace = false; |
747 } | 753 } |
748 if (isSpace && i > start) | 754 if (isSpace && i > start) |
749 w += f.fontDescription().wordSpacing(); | 755 w += f.fontDescription().wordSpacing(); |
750 } | 756 } |
751 return w; | 757 if (i == start + len) |
eae
2014/09/24 11:35:39
Instead of reusing i like this why not add a new b
h.joshi
2014/09/24 20:25:58
Okey, done.
| |
758 return w; | |
752 } | 759 } |
753 | 760 |
754 TextRun run = constructTextRun(const_cast<RenderText*>(this), f, this, start , len, style(), textDirection); | 761 TextRun run = constructTextRun(const_cast<RenderText*>(this), f, this, start , len, style(), textDirection); |
755 run.setCharactersLength(textLength() - start); | 762 run.setCharactersLength(textLength() - start); |
756 ASSERT(run.charactersLength() >= run.length()); | 763 ASSERT(run.charactersLength() >= run.length()); |
757 | 764 |
758 run.setCharacterScanForCodePath(!canUseSimpleFontCodePath()); | 765 run.setCharacterScanForCodePath(!canUseSimpleFontCodePath()); |
759 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize()); | 766 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize()); |
760 run.setXPos(xPos); | 767 run.setXPos(xPos); |
761 FontCachePurgePreventer fontCachePurgePreventer; | 768 FontCachePurgePreventer fontCachePurgePreventer; |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1892 } | 1899 } |
1893 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); | 1900 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); |
1894 } | 1901 } |
1895 | 1902 |
1896 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() | 1903 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() |
1897 { | 1904 { |
1898 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); | 1905 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); |
1899 } | 1906 } |
1900 | 1907 |
1901 } // namespace blink | 1908 } // namespace blink |
OLD | NEW |