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 20 matching lines...) Expand all Loading... |
31 #include "core/frame/FrameView.h" | 31 #include "core/frame/FrameView.h" |
32 #include "core/frame/Settings.h" | 32 #include "core/frame/Settings.h" |
33 #include "core/html/parser/TextResourceDecoder.h" | 33 #include "core/html/parser/TextResourceDecoder.h" |
34 #include "core/rendering/AbstractInlineTextBox.h" | 34 #include "core/rendering/AbstractInlineTextBox.h" |
35 #include "core/rendering/EllipsisBox.h" | 35 #include "core/rendering/EllipsisBox.h" |
36 #include "core/rendering/InlineTextBox.h" | 36 #include "core/rendering/InlineTextBox.h" |
37 #include "core/rendering/RenderBlock.h" | 37 #include "core/rendering/RenderBlock.h" |
38 #include "core/rendering/RenderCombineText.h" | 38 #include "core/rendering/RenderCombineText.h" |
39 #include "core/rendering/RenderLayer.h" | 39 #include "core/rendering/RenderLayer.h" |
40 #include "core/rendering/RenderView.h" | 40 #include "core/rendering/RenderView.h" |
| 41 #include "core/rendering/TextRunConstructor.h" |
41 #include "core/rendering/break_lines.h" | 42 #include "core/rendering/break_lines.h" |
42 #include "platform/fonts/Character.h" | 43 #include "platform/fonts/Character.h" |
43 #include "platform/fonts/FontCache.h" | 44 #include "platform/fonts/FontCache.h" |
44 #include "platform/geometry/FloatQuad.h" | 45 #include "platform/geometry/FloatQuad.h" |
45 #include "platform/text/BidiResolver.h" | 46 #include "platform/text/BidiResolver.h" |
46 #include "platform/text/TextBreakIterator.h" | 47 #include "platform/text/TextBreakIterator.h" |
47 #include "platform/text/TextRunIterator.h" | 48 #include "platform/text/TextRunIterator.h" |
48 #include "wtf/text/StringBuffer.h" | 49 #include "wtf/text/StringBuffer.h" |
49 #include "wtf/text/StringBuilder.h" | 50 #include "wtf/text/StringBuilder.h" |
50 #include "wtf/unicode/CharacterNames.h" | 51 #include "wtf/unicode/CharacterNames.h" |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 } else { | 738 } else { |
738 w += monospaceCharacterWidth; | 739 w += monospaceCharacterWidth; |
739 isSpace = false; | 740 isSpace = false; |
740 } | 741 } |
741 if (isSpace && i > start) | 742 if (isSpace && i > start) |
742 w += f.fontDescription().wordSpacing(); | 743 w += f.fontDescription().wordSpacing(); |
743 } | 744 } |
744 return w; | 745 return w; |
745 } | 746 } |
746 | 747 |
747 TextRun run = RenderBlockFlow::constructTextRun(const_cast<RenderText*>(this
), f, this, start, len, style(), textDirection); | 748 TextRun run = constructTextRun(const_cast<RenderText*>(this), f, this, start
, len, style(), textDirection); |
748 run.setCharactersLength(textLength() - start); | 749 run.setCharactersLength(textLength() - start); |
749 ASSERT(run.charactersLength() >= run.length()); | 750 ASSERT(run.charactersLength() >= run.length()); |
750 | 751 |
751 run.setCharacterScanForCodePath(!canUseSimpleFontCodePath()); | 752 run.setCharacterScanForCodePath(!canUseSimpleFontCodePath()); |
752 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize()); | 753 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize()); |
753 run.setXPos(xPos); | 754 run.setXPos(xPos); |
754 FontCachePurgePreventer fontCachePurgePreventer; | 755 FontCachePurgePreventer fontCachePurgePreventer; |
755 return f.width(run, fallbackFonts, glyphOverflow); | 756 return f.width(run, fallbackFonts, glyphOverflow); |
756 } | 757 } |
757 | 758 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 | 795 |
795 hasBreakableChar = m_hasBreakableChar; | 796 hasBreakableChar = m_hasBreakableChar; |
796 hasBreak = m_hasBreak; | 797 hasBreak = m_hasBreak; |
797 | 798 |
798 ASSERT(m_text); | 799 ASSERT(m_text); |
799 StringImpl& text = *m_text.impl(); | 800 StringImpl& text = *m_text.impl(); |
800 if (text[0] == ' ' || (text[0] == '\n' && !style()->preserveNewline()) || te
xt[0] == '\t') { | 801 if (text[0] == ' ' || (text[0] == '\n' && !style()->preserveNewline()) || te
xt[0] == '\t') { |
801 const Font& font = style()->font(); // FIXME: This ignores first-line. | 802 const Font& font = style()->font(); // FIXME: This ignores first-line. |
802 if (stripFrontSpaces) { | 803 if (stripFrontSpaces) { |
803 const UChar space = ' '; | 804 const UChar space = ' '; |
804 float spaceWidth = font.width(RenderBlockFlow::constructTextRun(this
, font, &space, 1, style(), direction)); | 805 float spaceWidth = font.width(constructTextRun(this, font, &space, 1
, style(), direction)); |
805 maxWidth -= spaceWidth; | 806 maxWidth -= spaceWidth; |
806 } else { | 807 } else { |
807 maxWidth += font.fontDescription().wordSpacing(); | 808 maxWidth += font.fontDescription().wordSpacing(); |
808 } | 809 } |
809 } | 810 } |
810 | 811 |
811 stripFrontSpaces = collapseWhiteSpace && m_hasEndWhiteSpace; | 812 stripFrontSpaces = collapseWhiteSpace && m_hasEndWhiteSpace; |
812 | 813 |
813 if (!style()->autoWrap() || minWidth > maxWidth) | 814 if (!style()->autoWrap() || minWidth > maxWidth) |
814 minWidth = maxWidth; | 815 minWidth = maxWidth; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 HashSet<const SimpleFontData*> fallbackFonts; | 869 HashSet<const SimpleFontData*> fallbackFonts; |
869 GlyphOverflow glyphOverflow; | 870 GlyphOverflow glyphOverflow; |
870 computePreferredLogicalWidths(leadWidth, fallbackFonts, glyphOverflow); | 871 computePreferredLogicalWidths(leadWidth, fallbackFonts, glyphOverflow); |
871 if (fallbackFonts.isEmpty() && !glyphOverflow.left && !glyphOverflow.right &
& !glyphOverflow.top && !glyphOverflow.bottom) | 872 if (fallbackFonts.isEmpty() && !glyphOverflow.left && !glyphOverflow.right &
& !glyphOverflow.top && !glyphOverflow.bottom) |
872 m_knownToHaveNoOverflowAndNoFallbackFonts = true; | 873 m_knownToHaveNoOverflowAndNoFallbackFonts = true; |
873 } | 874 } |
874 | 875 |
875 static inline float hyphenWidth(RenderText* renderer, const Font& font, TextDire
ction direction) | 876 static inline float hyphenWidth(RenderText* renderer, const Font& font, TextDire
ction direction) |
876 { | 877 { |
877 RenderStyle* style = renderer->style(); | 878 RenderStyle* style = renderer->style(); |
878 return font.width(RenderBlockFlow::constructTextRun(renderer, font, style->h
yphenString().string(), style, direction)); | 879 return font.width(constructTextRun(renderer, font, style->hyphenString().str
ing(), style, direction)); |
879 } | 880 } |
880 | 881 |
881 void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
mpleFontData*>& fallbackFonts, GlyphOverflow& glyphOverflow) | 882 void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
mpleFontData*>& fallbackFonts, GlyphOverflow& glyphOverflow) |
882 { | 883 { |
883 ASSERT(m_hasTab || preferredLogicalWidthsDirty() || !m_knownToHaveNoOverflow
AndNoFallbackFonts); | 884 ASSERT(m_hasTab || preferredLogicalWidthsDirty() || !m_knownToHaveNoOverflow
AndNoFallbackFonts); |
884 | 885 |
885 m_minWidth = 0; | 886 m_minWidth = 0; |
886 m_maxWidth = 0; | 887 m_maxWidth = 0; |
887 m_firstLineMinWidth = 0; | 888 m_firstLineMinWidth = 0; |
888 m_lastLineLineMinWidth = 0; | 889 m_lastLineLineMinWidth = 0; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 int wordLen = j - i; | 1019 int wordLen = j - i; |
1019 if (wordLen) { | 1020 if (wordLen) { |
1020 bool isSpace = (j < len) && c == ' '; | 1021 bool isSpace = (j < len) && c == ' '; |
1021 | 1022 |
1022 // Non-zero only when kerning is enabled, in which case we measure w
ords with their trailing | 1023 // Non-zero only when kerning is enabled, in which case we measure w
ords with their trailing |
1023 // space, then subtract its width. | 1024 // space, then subtract its width. |
1024 float wordTrailingSpaceWidth = 0; | 1025 float wordTrailingSpaceWidth = 0; |
1025 if (isSpace && (f.fontDescription().typesettingFeatures() & Kerning)
) { | 1026 if (isSpace && (f.fontDescription().typesettingFeatures() & Kerning)
) { |
1026 ASSERT(textDirection >=0 && textDirection <= 1); | 1027 ASSERT(textDirection >=0 && textDirection <= 1); |
1027 if (!cachedWordTrailingSpaceWidth[textDirection]) | 1028 if (!cachedWordTrailingSpaceWidth[textDirection]) |
1028 cachedWordTrailingSpaceWidth[textDirection] = f.width(Render
BlockFlow::constructTextRun(this, f, &space, 1, styleToUse, textDirection)) + wo
rdSpacing; | 1029 cachedWordTrailingSpaceWidth[textDirection] = f.width(constr
uctTextRun(this, f, &space, 1, styleToUse, textDirection)) + wordSpacing; |
1029 wordTrailingSpaceWidth = cachedWordTrailingSpaceWidth[textDirect
ion]; | 1030 wordTrailingSpaceWidth = cachedWordTrailingSpaceWidth[textDirect
ion]; |
1030 } | 1031 } |
1031 | 1032 |
1032 float w; | 1033 float w; |
1033 if (wordTrailingSpaceWidth && isSpace) | 1034 if (wordTrailingSpaceWidth && isSpace) |
1034 w = widthFromCache(f, i, wordLen + 1, leadWidth + currMaxWidth,
textDirection, &fallbackFonts, &glyphOverflow) - wordTrailingSpaceWidth; | 1035 w = widthFromCache(f, i, wordLen + 1, leadWidth + currMaxWidth,
textDirection, &fallbackFonts, &glyphOverflow) - wordTrailingSpaceWidth; |
1035 else { | 1036 else { |
1036 w = widthFromCache(f, i, wordLen, leadWidth + currMaxWidth, text
Direction, &fallbackFonts, &glyphOverflow); | 1037 w = widthFromCache(f, i, wordLen, leadWidth + currMaxWidth, text
Direction, &fallbackFonts, &glyphOverflow); |
1037 if (c == softHyphen) | 1038 if (c == softHyphen) |
1038 currMinWidth += hyphenWidth(this, f, textDirection); | 1039 currMinWidth += hyphenWidth(this, f, textDirection); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 firstLine = false; | 1090 firstLine = false; |
1090 leadWidth = 0; | 1091 leadWidth = 0; |
1091 if (!styleToUse->autoWrap()) | 1092 if (!styleToUse->autoWrap()) |
1092 m_firstLineMinWidth = currMaxWidth; | 1093 m_firstLineMinWidth = currMaxWidth; |
1093 } | 1094 } |
1094 | 1095 |
1095 if (currMaxWidth > m_maxWidth) | 1096 if (currMaxWidth > m_maxWidth) |
1096 m_maxWidth = currMaxWidth; | 1097 m_maxWidth = currMaxWidth; |
1097 currMaxWidth = 0; | 1098 currMaxWidth = 0; |
1098 } else { | 1099 } else { |
1099 TextRun run = RenderBlockFlow::constructTextRun(this, f, this, i
, 1, styleToUse, textDirection); | 1100 TextRun run = constructTextRun(this, f, this, i, 1, styleToUse,
textDirection); |
1100 run.setCharactersLength(len - i); | 1101 run.setCharactersLength(len - i); |
1101 ASSERT(run.charactersLength() >= run.length()); | 1102 ASSERT(run.charactersLength() >= run.length()); |
1102 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize(
)); | 1103 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize(
)); |
1103 run.setXPos(leadWidth + currMaxWidth); | 1104 run.setXPos(leadWidth + currMaxWidth); |
1104 | 1105 |
1105 currMaxWidth += f.width(run); | 1106 currMaxWidth += f.width(run); |
1106 glyphOverflow.right = 0; | 1107 glyphOverflow.right = 0; |
1107 needsWordSpacing = isSpace && !previousCharacterIsSpace && i ==
len - 1; | 1108 needsWordSpacing = isSpace && !previousCharacterIsSpace && i ==
len - 1; |
1108 } | 1109 } |
1109 ASSERT(lastWordBoundary == i); | 1110 ASSERT(lastWordBoundary == i); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 m_knownToHaveNoOverflowAndNoFallbackFonts = true; | 1498 m_knownToHaveNoOverflowAndNoFallbackFonts = true; |
1498 } | 1499 } |
1499 w = m_maxWidth; | 1500 w = m_maxWidth; |
1500 } else { | 1501 } else { |
1501 w = maxLogicalWidth(); | 1502 w = maxLogicalWidth(); |
1502 } | 1503 } |
1503 } else { | 1504 } else { |
1504 w = widthFromCache(f, from, len, xPos, textDirection, fallbackFonts,
glyphOverflow); | 1505 w = widthFromCache(f, from, len, xPos, textDirection, fallbackFonts,
glyphOverflow); |
1505 } | 1506 } |
1506 } else { | 1507 } else { |
1507 TextRun run = RenderBlockFlow::constructTextRun(const_cast<RenderText*>(
this), f, this, from, len, style(), textDirection); | 1508 TextRun run = constructTextRun(const_cast<RenderText*>(this), f, this, f
rom, len, style(), textDirection); |
1508 run.setCharactersLength(textLength() - from); | 1509 run.setCharactersLength(textLength() - from); |
1509 ASSERT(run.charactersLength() >= run.length()); | 1510 ASSERT(run.charactersLength() >= run.length()); |
1510 | 1511 |
1511 run.setCharacterScanForCodePath(!canUseSimpleFontCodePath()); | 1512 run.setCharacterScanForCodePath(!canUseSimpleFontCodePath()); |
1512 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize()); | 1513 run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize()); |
1513 run.setXPos(xPos); | 1514 run.setXPos(xPos); |
1514 w = f.width(run, fallbackFonts, glyphOverflow); | 1515 w = f.width(run, fallbackFonts, glyphOverflow); |
1515 } | 1516 } |
1516 | 1517 |
1517 return w; | 1518 return w; |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1868 } | 1869 } |
1869 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); | 1870 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); |
1870 } | 1871 } |
1871 | 1872 |
1872 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() | 1873 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() |
1873 { | 1874 { |
1874 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); | 1875 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); |
1875 } | 1876 } |
1876 | 1877 |
1877 } // namespace WebCore | 1878 } // namespace WebCore |
OLD | NEW |