Changeset 50301 in webkit
- Timestamp:
- Oct 29, 2009, 2:25:59 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r50297 r50301 1 2009-10-29 Dan Bernstein <mitz@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 Problem editing or selecting text containing ligatures 6 https://bugs.webkit.org/show_bug.cgi?id=30025 7 8 * platform/mac/fast/text/ligature-subdivision-expected.txt: Added. 9 * platform/mac/fast/text/ligature-subdivision.html: Added. 10 * platform/mac/fast/text/script-tests: Added. 11 * platform/mac/fast/text/script-tests/TEMPLATE.html: Copied from LayoutTests/fast/js/script-tests/TEMPLATE.html. 12 * platform/mac/fast/text/script-tests/ligature-subdivision.js: Added. 13 1 14 2009-10-29 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 15 -
trunk/LayoutTests/platform/mac/fast/text/script-tests/TEMPLATE.html
r50299 r50301 2 2 <html> 3 3 <head> 4 <link rel="stylesheet" href=" resources/js-test-style.css">5 <script src=" resources/js-test-pre.js"></script>4 <link rel="stylesheet" href="../../../../fast/js/resources/js-test-style.css"> 5 <script src="../../../../fast/js/resources/js-test-pre.js"></script> 6 6 </head> 7 7 <body> … … 9 9 <div id="console"></div> 10 10 <script src="YOUR_JS_FILE_HERE"></script> 11 <script src=" resources/js-test-post.js"></script>11 <script src="../../../../fast/js/resources/js-test-post.js"></script> 12 12 </body> 13 13 </html> -
trunk/WebCore/ChangeLog
r50300 r50301 1 2009-10-29 Dan Bernstein <mitz@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 Problem editing or selecting text containing ligatures 6 https://bugs.webkit.org/show_bug.cgi?id=30025 7 8 Test: platform/mac/fast/text/ligature-subdivision.html 9 10 * platform/graphics/mac/ComplexTextController.cpp: 11 (WebCore::ComplexTextController::ComplexTextController): Initialize 12 m_characterInCurrentGlyph. 13 (WebCore::ComplexTextController::offsetForPosition): If the hit glyph spans multiple 14 characters, compute the hit character based on dividing the glyph’s total advance into 15 a number of equal intervals equal to the number of characters and assigning the hit to the 16 character corresponding to the hit interval. 17 (WebCore::ComplexTextController::advance): If the final offset occurs mid-glyph, advance 18 by a fraction of the glyph’s total advance. 19 * platform/graphics/mac/ComplexTextController.h: Added m_characterInCurrentGlyph. 20 1 21 2009-10-29 Brian Weinstein <bweinstein@apple.com> 2 22 -
trunk/WebCore/platform/graphics/mac/ComplexTextController.cpp
r50259 r50301 30 30 #include "TextBreakIterator.h" 31 31 32 using namespace std; 33 32 34 namespace WebCore { 33 35 … … 57 59 , m_currentRun(0) 58 60 , m_glyphInCurrentRun(0) 61 , m_characterInCurrentGlyph(0) 59 62 , m_finalRoundingWidth(0) 60 63 , m_fallbackFonts(fallbackFonts) … … 82 85 int ComplexTextController::offsetForPosition(int h, bool includePartialGlyphs) 83 86 { 84 // FIXME: For positions occurring within a ligature, we should return the closest "ligature caret" or85 // approximate it by dividing the width of the ligature by the number of characters it encompasses.86 // However, Core Text does not expose a low-level API for directly finding87 // out how many characters a ligature encompasses (the "attachment count").88 87 if (h >= m_totalWidth) 89 88 return m_run.ltr() ? m_end : 0; … … 100 99 for (unsigned j = 0; j < complexTextRun.glyphCount(); ++j) { 101 100 CGFloat adjustedAdvance = m_adjustedAdvances[offsetIntoAdjustedGlyphs + j].width; 102 if (x <= adjustedAdvance) { 103 CFIndex hitIndex = complexTextRun.indexAt(j); 101 if (x < adjustedAdvance) { 102 CFIndex hitGlyphStart = complexTextRun.indexAt(j); 103 CFIndex hitGlyphEnd; 104 if (m_run.ltr()) 105 hitGlyphEnd = max<CFIndex>(hitGlyphStart, j + 1 < complexTextRun.glyphCount() ? complexTextRun.indexAt(j + 1) : complexTextRun.stringLength()); 106 else 107 hitGlyphEnd = max<CFIndex>(hitGlyphStart, j > 0 ? complexTextRun.indexAt(j - 1) : complexTextRun.stringLength()); 108 109 // FIXME: Instead of dividing the glyph's advance equially between the characters, this 110 // could use the glyph's "ligature carets". However, there is no Core Text API to get the 111 // ligature carets. 112 CFIndex hitIndex = hitGlyphStart + (hitGlyphEnd - hitGlyphStart) * (m_run.ltr() ? x / adjustedAdvance : 1 - x / adjustedAdvance); 104 113 int stringLength = complexTextRun.stringLength(); 105 114 TextBreakIterator* cursorPositionIterator = cursorMovementIterator(complexTextRun.characters(), stringLength); … … 120 129 clusterEnd = stringLength; 121 130 122 CGFloat clusterWidth = adjustedAdvance;131 CGFloat clusterWidth; 123 132 // FIXME: The search stops at the boundaries of complexTextRun. In theory, it should go on into neighboring ComplexTextRuns 124 133 // derived from the same CTLine. In practice, we do not expect there to be more than one CTRun in a CTLine, as no 125 134 // reordering and on font fallback should occur within a CTLine. 126 135 if (clusterEnd - clusterStart > 1) { 136 clusterWidth = adjustedAdvance; 127 137 int firstGlyphBeforeCluster = j - 1; 128 138 while (firstGlyphBeforeCluster >= 0 && complexTextRun.indexAt(firstGlyphBeforeCluster) >= clusterStart && complexTextRun.indexAt(firstGlyphBeforeCluster) < clusterEnd) { … … 137 147 firstGlyphAfterCluster++; 138 148 } 149 } else { 150 clusterWidth = adjustedAdvance / (hitGlyphEnd - hitGlyphStart); 151 x -= clusterWidth * (m_run.ltr() ? hitIndex - hitGlyphStart : hitGlyphEnd - hitIndex - 1); 139 152 } 140 153 if (x <= clusterWidth / 2) … … 253 266 void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer) 254 267 { 255 // FIXME: For offsets falling inside a ligature, we should advance only as far as the appropriate "ligature caret"256 // or divide the width of the ligature by the number of offsets it encompasses and make an advance proportional257 // to the offsets into the ligature. However, Core Text does not expose a low-level API for258 // directly finding out how many characters a ligature encompasses (the "attachment count").259 268 if (static_cast<int>(offset) > m_end) 260 269 offset = m_end; … … 275 284 unsigned g = ltr ? m_glyphInCurrentRun : glyphCount - 1 - m_glyphInCurrentRun; 276 285 while (m_glyphInCurrentRun < glyphCount) { 277 if (complexTextRun.indexAt(g) + complexTextRun.stringLocation() >= m_currentCharacter) 286 unsigned glyphStartOffset = complexTextRun.indexAt(g); 287 unsigned glyphEndOffset; 288 if (ltr) 289 glyphEndOffset = max<unsigned>(glyphStartOffset, g + 1 < glyphCount ? complexTextRun.indexAt(g + 1) : complexTextRun.stringLength()); 290 else 291 glyphEndOffset = max<unsigned>(glyphStartOffset, g > 0 ? complexTextRun.indexAt(g - 1) : complexTextRun.stringLength()); 292 293 CGSize adjustedAdvance = m_adjustedAdvances[k]; 294 295 if (glyphStartOffset + complexTextRun.stringLocation() >= m_currentCharacter) 278 296 return; 279 CGSize adjustedAdvance = m_adjustedAdvances[k]; 280 if (glyphBuffer )297 298 if (glyphBuffer && !m_characterInCurrentGlyph) 281 299 glyphBuffer->add(m_adjustedGlyphs[k], complexTextRun.fontData(), adjustedAdvance); 282 m_runWidthSoFar += adjustedAdvance.width; 300 301 unsigned oldCharacterInCurrentGlyph = m_characterInCurrentGlyph; 302 m_characterInCurrentGlyph = min(m_currentCharacter - complexTextRun.stringLocation(), glyphEndOffset) - glyphStartOffset; 303 // FIXME: Instead of dividing the glyph's advance equially between the characters, this 304 // could use the glyph's "ligature carets". However, there is no Core Text API to get the 305 // ligature carets. 306 m_runWidthSoFar += adjustedAdvance.width * (m_characterInCurrentGlyph - oldCharacterInCurrentGlyph) / (glyphEndOffset - glyphStartOffset); 307 308 if (glyphEndOffset + complexTextRun.stringLocation() > m_currentCharacter) 309 return; 310 283 311 m_numGlyphsSoFar++; 284 312 m_glyphInCurrentRun++; 313 m_characterInCurrentGlyph = 0; 285 314 if (ltr) { 286 315 g++; -
trunk/WebCore/platform/graphics/mac/ComplexTextController.h
r50264 r50301 145 145 size_t m_currentRun; 146 146 unsigned m_glyphInCurrentRun; 147 unsigned m_characterInCurrentGlyph; 147 148 float m_finalRoundingWidth; 148 149 float m_padding;
Note:
See TracChangeset
for help on using the changeset viewer.