Changeset 129175 in webkit
- Timestamp:
- Sep 20, 2012 4:16:16 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r129171 r129175 1 2012-09-20 Kenichi Ishibashi <bashi@chromium.org> 2 3 [Chromium] Improve glyph selection of HarfBuzzShaper 4 https://bugs.webkit.org/show_bug.cgi?id=97164 5 6 Reviewed by Tony Chang. 7 8 Added a test for complex text selection. 9 10 * fast/text/international/hebrew-selection-expected.html: Added. 11 * fast/text/international/hebrew-selection.html: Added. 12 1 13 2012-09-20 Dirk Pranke <dpranke@chromium.org> 2 14 -
trunk/LayoutTests/platform/chromium/TestExpectations
r129171 r129175 3559 3559 webkit.org/b/97179 http/tests/css/link-css-disabled-value-with-slow-loading-sheet.html [ Failure Pass ] 3560 3560 3561 3561 # The test should pass after harfbuzz transition. 3562 webkit.org/b/97164 [ Linux ] fast/text/international/hebrew-selection.html [ Failure ] 3563 -
trunk/Source/WebCore/ChangeLog
r129174 r129175 1 2012-09-20 Kenichi Ishibashi <bashi@chromium.org> 2 3 [Chromium] Improve glyph selection of HarfBuzzShaper 4 https://bugs.webkit.org/show_bug.cgi?id=97164 5 6 Reviewed by Tony Chang. 7 8 Take into account clusters for selection. 9 10 Test: fast/text/international/hebrew-selection.html 11 12 * platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp: 13 (WebCore::HarfBuzzShaper::HarfBuzzRun::applyShapeResult): Removed m_logClusters. 14 m_logCluster is no longer used. 15 (WebCore::HarfBuzzShaper::HarfBuzzRun::characterIndexForXPosition): 16 - If targetX is in the left side of the first cluster, return the leftmost character index. 17 - If targetX is in the right side of the last cluster, return the rightmost character index. 18 - If targetX is between the right side of the cluster N and the left side of the cluster N+1, then: 19 - return N+1 for LTR. 20 - return N for RTL. 21 (WebCore::HarfBuzzShaper::HarfBuzzRun::xPositionForOffset): 22 Find the cluster of index in question, then: 23 - return the left side boundary of the cluster for LTR. 24 - return the right side boundary of the cluster for RTL. 25 * platform/graphics/harfbuzz/ng/HarfBuzzShaper.h: 26 (HarfBuzzRun): 27 1 28 2012-09-20 Tony Chang <tony@chromium.org> 2 29 -
trunk/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp
r129074 r129175 87 87 m_advances.resize(m_numGlyphs); 88 88 m_glyphToCharacterIndexes.resize(m_numGlyphs); 89 m_logClusters.resize(m_numCharacters);90 89 m_offsets.resize(m_numGlyphs); 91 90 … … 93 92 for (unsigned i = 0; i < m_numGlyphs; ++i) 94 93 m_glyphToCharacterIndexes[i] = infos[i].cluster; 95 96 // Fill logical clusters97 unsigned index = 0;98 while (index < m_numGlyphs) {99 unsigned nextIndex = index + 1;100 while (nextIndex < m_numGlyphs && infos[index].cluster == infos[nextIndex].cluster)101 ++nextIndex;102 if (rtl()) {103 int nextCluster = nextIndex < m_numGlyphs ? infos[nextIndex].cluster : -1;104 for (int j = infos[index].cluster; j > nextCluster; --j)105 m_logClusters[j] = index;106 } else {107 unsigned nextCluster = nextIndex < m_numGlyphs ? infos[nextIndex].cluster : m_numCharacters;108 for (unsigned j = infos[index].cluster; j < nextCluster; ++j)109 m_logClusters[j] = index;110 }111 index = nextIndex;112 }113 94 } 114 95 … … 124 105 ASSERT(targetX <= m_width); 125 106 float currentX = 0; 126 float prevAdvance = 0; 127 for (unsigned i = 0; i < m_numGlyphs; ++i) { 128 float currentAdvance = m_advances[i] / 2.0; 107 float currentAdvance = m_advances[0]; 108 unsigned glyphIndex = 0; 109 110 // Sum up advances that belong to a character. 111 while (glyphIndex < m_numGlyphs - 1 && m_glyphToCharacterIndexes[glyphIndex] == m_glyphToCharacterIndexes[glyphIndex + 1]) 112 currentAdvance += m_advances[++glyphIndex]; 113 currentAdvance = currentAdvance / 2.0; 114 if (targetX <= currentAdvance) 115 return rtl() ? m_numCharacters : 0; 116 117 ++glyphIndex; 118 while (glyphIndex < m_numGlyphs) { 119 unsigned prevCharacterIndex = m_glyphToCharacterIndexes[glyphIndex - 1]; 120 float prevAdvance = currentAdvance; 121 currentAdvance = m_advances[glyphIndex]; 122 while (glyphIndex < m_numGlyphs - 1 && m_glyphToCharacterIndexes[glyphIndex] == m_glyphToCharacterIndexes[glyphIndex + 1]) 123 currentAdvance += m_advances[++glyphIndex]; 124 currentAdvance = currentAdvance / 2.0; 129 125 float nextX = currentX + prevAdvance + currentAdvance; 130 126 if (currentX <= targetX && targetX <= nextX) 131 return m_glyphToCharacterIndexes[i] + (rtl() ? 1 : 0);127 return rtl() ? prevCharacterIndex : m_glyphToCharacterIndexes[glyphIndex]; 132 128 currentX = nextX; 133 129 prevAdvance = currentAdvance; 130 ++glyphIndex; 134 131 } 135 132 … … 140 137 { 141 138 ASSERT(offset < m_numCharacters); 142 unsigned glyphIndex = m_logClusters[offset]; 143 ASSERT(glyphIndex <= m_numGlyphs); 139 unsigned glyphIndex = 0; 144 140 float position = 0; 145 for (unsigned i = 0; i < glyphIndex; ++i) 146 position += m_advances[i]; 147 if (rtl()) 141 if (rtl()) { 142 while (glyphIndex < m_numGlyphs && m_glyphToCharacterIndexes[glyphIndex] > offset) { 143 position += m_advances[glyphIndex]; 144 ++glyphIndex; 145 } 146 // For RTL, we need to return the right side boundary of the character. 147 // Add advance of glyphs which are part of the character. 148 while (glyphIndex < m_numGlyphs - 1 && m_glyphToCharacterIndexes[glyphIndex] == m_glyphToCharacterIndexes[glyphIndex + 1]) { 149 position += m_advances[glyphIndex]; 150 ++glyphIndex; 151 } 148 152 position += m_advances[glyphIndex]; 153 } else { 154 while (glyphIndex < m_numGlyphs && m_glyphToCharacterIndexes[glyphIndex] < offset) { 155 position += m_advances[glyphIndex]; 156 ++glyphIndex; 157 } 158 } 149 159 return position; 150 160 } … … 158 168 int nextPosition = position; 159 169 U16_NEXT(source, nextPosition, length, character); 160 // Don't normalize tabs as they are not treated as spaces for word-end 170 // Don't normalize tabs as they are not treated as spaces for word-end. 161 171 if (Font::treatAsSpace(character) && character != '\t') 162 172 character = ' '; -
trunk/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.h
r129074 r129175 95 95 Vector<uint16_t, 256> m_glyphs; 96 96 Vector<float, 256> m_advances; 97 Vector<uint16_t, 256> m_logClusters;98 97 Vector<uint16_t, 256> m_glyphToCharacterIndexes; 99 98 Vector<FloatPoint, 256> m_offsets;
Note: See TracChangeset
for help on using the changeset viewer.