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 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 int nextBreakable = -1; | 929 int nextBreakable = -1; |
930 int lastWordBoundary = 0; | 930 int lastWordBoundary = 0; |
931 float cachedWordTrailingSpaceWidth[2] = { 0, 0 }; // LTR, RTL | 931 float cachedWordTrailingSpaceWidth[2] = { 0, 0 }; // LTR, RTL |
932 | 932 |
933 int firstGlyphLeftOverflow = -1; | 933 int firstGlyphLeftOverflow = -1; |
934 | 934 |
935 bool breakAll = (styleToUse->wordBreak() == BreakAllWordBreak || styleToUse-
>wordBreak() == BreakWordBreak) && styleToUse->autoWrap(); | 935 bool breakAll = (styleToUse->wordBreak() == BreakAllWordBreak || styleToUse-
>wordBreak() == BreakWordBreak) && styleToUse->autoWrap(); |
936 | 936 |
937 TextRun textRun(text()); | 937 TextRun textRun(text()); |
938 BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver; | 938 BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver; |
939 BidiStatus status(LTR, false); | |
940 status.last = status.lastStrong = WTF::Unicode::OtherNeutral; | |
941 bidiResolver.setStatus(status); | |
942 bidiResolver.setPositionIgnoringNestedIsolates(TextRunIterator(&textRun, 0))
; | |
943 bool hardLineBreak = false; | |
944 bool reorderRuns = false; | |
945 bidiResolver.createBidiRunsForLine(TextRunIterator(&textRun, textRun.length(
)), NoVisualOverride, hardLineBreak, reorderRuns); | |
946 | 939 |
947 BidiRunList<BidiCharacterRun>& bidiRuns = bidiResolver.runs(); | 940 BidiCharacterRun* run; |
948 BidiCharacterRun* run = bidiRuns.firstRun(); | 941 TextDirection textDirection = styleToUse->direction(); |
| 942 if (isOverride(styleToUse->unicodeBidi())) { |
| 943 run = 0; |
| 944 } else { |
| 945 BidiStatus status(LTR, false); |
| 946 status.last = status.lastStrong = WTF::Unicode::OtherNeutral; |
| 947 bidiResolver.setStatus(status); |
| 948 bidiResolver.setPositionIgnoringNestedIsolates(TextRunIterator(&textRun,
0)); |
| 949 bool hardLineBreak = false; |
| 950 bool reorderRuns = false; |
| 951 bidiResolver.createBidiRunsForLine(TextRunIterator(&textRun, textRun.len
gth()), NoVisualOverride, hardLineBreak, reorderRuns); |
| 952 BidiRunList<BidiCharacterRun>& bidiRuns = bidiResolver.runs(); |
| 953 run = bidiRuns.firstRun(); |
| 954 } |
| 955 |
949 for (int i = 0; i < len; i++) { | 956 for (int i = 0; i < len; i++) { |
950 UChar c = uncheckedCharacterAt(i); | 957 UChar c = uncheckedCharacterAt(i); |
951 | 958 |
952 // Treat adjacent runs with the same resolved directionality | 959 if (run) { |
953 // (TextDirection as opposed to WTF::Unicode::Direction) as belonging | 960 // Treat adjacent runs with the same resolved directionality |
954 // to the same run to avoid breaking unnecessarily. | 961 // (TextDirection as opposed to WTF::Unicode::Direction) as belongin
g |
955 while (i > run->stop() || (run->next() && run->next()->direction() == ru
n->direction())) | 962 // to the same run to avoid breaking unnecessarily. |
956 run = run->next(); | 963 while (i > run->stop() || (run->next() && run->next()->direction() =
= run->direction())) |
| 964 run = run->next(); |
957 | 965 |
958 ASSERT(run); | 966 ASSERT(run); |
959 ASSERT(i <= run->stop()); | 967 ASSERT(i <= run->stop()); |
960 TextDirection textDirection = run->direction(); | 968 textDirection = run->direction(); |
| 969 } |
961 | 970 |
962 bool previousCharacterIsSpace = isSpace; | 971 bool previousCharacterIsSpace = isSpace; |
963 bool isNewline = false; | 972 bool isNewline = false; |
964 if (c == '\n') { | 973 if (c == '\n') { |
965 if (styleToUse->preserveNewline()) { | 974 if (styleToUse->preserveNewline()) { |
966 m_hasBreak = true; | 975 m_hasBreak = true; |
967 isNewline = true; | 976 isNewline = true; |
968 isSpace = false; | 977 isSpace = false; |
969 } else | 978 } else |
970 isSpace = true; | 979 isSpace = true; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 c = uncheckedCharacterAt(j); | 1023 c = uncheckedCharacterAt(j); |
1015 if (isBreakable(breakIterator, j, nextBreakable) && characterAt(j -
1) != softHyphen) | 1024 if (isBreakable(breakIterator, j, nextBreakable) && characterAt(j -
1) != softHyphen) |
1016 break; | 1025 break; |
1017 if (breakAll) { | 1026 if (breakAll) { |
1018 betweenWords = false; | 1027 betweenWords = false; |
1019 break; | 1028 break; |
1020 } | 1029 } |
1021 } | 1030 } |
1022 | 1031 |
1023 // Terminate word boundary at bidi run boundary. | 1032 // Terminate word boundary at bidi run boundary. |
1024 j = min(j, run->stop() + 1); | 1033 if (run) |
| 1034 j = min(j, run->stop() + 1); |
1025 int wordLen = j - i; | 1035 int wordLen = j - i; |
1026 if (wordLen) { | 1036 if (wordLen) { |
1027 bool isSpace = (j < len) && c == ' '; | 1037 bool isSpace = (j < len) && c == ' '; |
1028 | 1038 |
1029 // Non-zero only when kerning is enabled, in which case we measure w
ords with their trailing | 1039 // Non-zero only when kerning is enabled, in which case we measure w
ords with their trailing |
1030 // space, then subtract its width. | 1040 // space, then subtract its width. |
1031 float wordTrailingSpaceWidth = 0; | 1041 float wordTrailingSpaceWidth = 0; |
1032 if (isSpace && (f.fontDescription().typesettingFeatures() & Kerning)
) { | 1042 if (isSpace && (f.fontDescription().typesettingFeatures() & Kerning)
) { |
1033 ASSERT(textDirection >=0 && textDirection <= 1); | 1043 ASSERT(textDirection >=0 && textDirection <= 1); |
1034 if (!cachedWordTrailingSpaceWidth[textDirection]) | 1044 if (!cachedWordTrailingSpaceWidth[textDirection]) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 run.setXPos(leadWidth + currMaxWidth); | 1120 run.setXPos(leadWidth + currMaxWidth); |
1111 | 1121 |
1112 currMaxWidth += f.width(run); | 1122 currMaxWidth += f.width(run); |
1113 glyphOverflow.right = 0; | 1123 glyphOverflow.right = 0; |
1114 needsWordSpacing = isSpace && !previousCharacterIsSpace && i ==
len - 1; | 1124 needsWordSpacing = isSpace && !previousCharacterIsSpace && i ==
len - 1; |
1115 } | 1125 } |
1116 ASSERT(lastWordBoundary == i); | 1126 ASSERT(lastWordBoundary == i); |
1117 lastWordBoundary++; | 1127 lastWordBoundary++; |
1118 } | 1128 } |
1119 } | 1129 } |
1120 bidiRuns.deleteRuns(); | 1130 if (run) |
| 1131 bidiResolver.runs().deleteRuns(); |
1121 | 1132 |
1122 if (firstGlyphLeftOverflow > 0) | 1133 if (firstGlyphLeftOverflow > 0) |
1123 glyphOverflow.left = firstGlyphLeftOverflow; | 1134 glyphOverflow.left = firstGlyphLeftOverflow; |
1124 | 1135 |
1125 if ((needsWordSpacing && len > 1) || (ignoringSpaces && !firstWord)) | 1136 if ((needsWordSpacing && len > 1) || (ignoringSpaces && !firstWord)) |
1126 currMaxWidth += wordSpacing; | 1137 currMaxWidth += wordSpacing; |
1127 | 1138 |
1128 m_minWidth = max(currMinWidth, m_minWidth); | 1139 m_minWidth = max(currMinWidth, m_minWidth); |
1129 m_maxWidth = max(currMaxWidth, m_maxWidth); | 1140 m_maxWidth = max(currMaxWidth, m_maxWidth); |
1130 | 1141 |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1873 } | 1884 } |
1874 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); | 1885 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); |
1875 } | 1886 } |
1876 | 1887 |
1877 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() | 1888 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() |
1878 { | 1889 { |
1879 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); | 1890 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); |
1880 } | 1891 } |
1881 | 1892 |
1882 } // namespace WebCore | 1893 } // namespace WebCore |
OLD | NEW |