Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. | 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 stringFor8BitRun = String::make16BitFrom8BitSource(run.characters8(), ru n.length()); | 356 stringFor8BitRun = String::make16BitFrom8BitSource(run.characters8(), ru n.length()); |
| 357 source = stringFor8BitRun.characters16(); | 357 source = stringFor8BitRun.characters16(); |
| 358 } else { | 358 } else { |
| 359 source = run.characters16(); | 359 source = run.characters16(); |
| 360 } | 360 } |
| 361 | 361 |
| 362 *destinationLength = 0; | 362 *destinationLength = 0; |
| 363 while (position < length) { | 363 while (position < length) { |
| 364 UChar32 character; | 364 UChar32 character; |
| 365 U16_NEXT(source, position, length, character); | 365 U16_NEXT(source, position, length, character); |
| 366 // Don't normalize tabs as they are not treated as spaces for word-end. | 366 // Don't normalize tabs as they are not treated as characterSpaces for w ord-end. |
| 367 if (run.normalizeSpace() && Character::isNormalizedCanvasSpaceCharacter( character)) | 367 if (run.normalizeSpace() && Character::isNormalizedCanvasSpaceCharacter( character)) |
| 368 character = space; | 368 character = characterSpace; |
| 369 else if (Character::treatAsSpace(character) && character != characterTab ulation) | 369 else if (Character::treatAsSpace(character) && character != characterTab ulation) |
| 370 character = space; | 370 character = characterSpace; |
| 371 else if (Character::treatAsZeroWidthSpaceInComplexScript(character)) | 371 else if (Character::treatAsZeroWidthSpaceInComplexScript(character)) |
| 372 character = zeroWidthSpace; | 372 character = characterZeroWidthSpace; |
| 373 | 373 |
| 374 U16_APPEND(destination, *destinationLength, length, character, error); | 374 U16_APPEND(destination, *destinationLength, length, character, error); |
| 375 ASSERT_UNUSED(error, !error); | 375 ASSERT_UNUSED(error, !error); |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 | 378 |
| 379 HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run, const Glyph Data* emphasisData, | 379 HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run, const Glyph Data* emphasisData, |
| 380 HashSet<const SimpleFontData*>* fallbackFonts, FloatRect* bounds) | 380 HashSet<const SimpleFontData*>* fallbackFonts, FloatRect* bounds) |
| 381 : Shaper(font, run, emphasisData, fallbackFonts, bounds) | 381 : Shaper(font, run, emphasisData, fallbackFonts, bounds) |
| 382 , m_normalizedBufferLength(0) | 382 , m_normalizedBufferLength(0) |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 if ((U_GET_GC_MASK(character) & U_GC_M_MASK) | 587 if ((U_GET_GC_MASK(character) & U_GC_M_MASK) |
| 588 && currentFontData->canRenderCombiningCharacterSequence( | 588 && currentFontData->canRenderCombiningCharacterSequence( |
| 589 currentCharacterPosition, | 589 currentCharacterPosition, |
| 590 iterator.glyphEnd() - currentCharacterPosition)) | 590 iterator.glyphEnd() - currentCharacterPosition)) |
| 591 continue; | 591 continue; |
| 592 | 592 |
| 593 nextFontData = font->glyphDataForCharacter(character, false, isSpace Normalize).fontData; | 593 nextFontData = font->glyphDataForCharacter(character, false, isSpace Normalize).fontData; |
| 594 nextScript = uscript_getScript(character, &errorCode); | 594 nextScript = uscript_getScript(character, &errorCode); |
| 595 if (U_FAILURE(errorCode)) | 595 if (U_FAILURE(errorCode)) |
| 596 return false; | 596 return false; |
| 597 if (lastCharacter == zeroWidthJoiner) | 597 if (lastCharacter == characterZeroWidthJoiner) |
| 598 currentFontData = nextFontData; | 598 currentFontData = nextFontData; |
| 599 if ((nextFontData != currentFontData) || ((currentScript != nextScri pt) && (nextScript != USCRIPT_INHERITED) && (!uscript_hasScript(character, curre ntScript)))) | 599 if ((nextFontData != currentFontData) || ((currentScript != nextScri pt) && (nextScript != USCRIPT_INHERITED) && (!uscript_hasScript(character, curre ntScript)))) |
| 600 break; | 600 break; |
| 601 currentCharacterPosition = iterator.characters(); | 601 currentCharacterPosition = iterator.characters(); |
| 602 lastCharacter = character; | 602 lastCharacter = character; |
| 603 } | 603 } |
| 604 | 604 |
| 605 CandidateRun run = { character, startIndexOfCurrentRun, static_cast<unsi gned>(iterator.offset()), currentFontData, currentScript }; | 605 CandidateRun run = { character, startIndexOfCurrentRun, static_cast<unsi gned>(iterator.offset()), currentFontData, currentScript }; |
| 606 runs->append(run); | 606 runs->append(run); |
| 607 | 607 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 845 setGlyphPositionsForHarfBuzzRun(currentRun, | 845 setGlyphPositionsForHarfBuzzRun(currentRun, |
| 846 cachedResults->buffer, previousRun); | 846 cachedResults->buffer, previousRun); |
| 847 hb_buffer_clear_contents(harfBuzzBuffer.get()); | 847 hb_buffer_clear_contents(harfBuzzBuffer.get()); |
| 848 runCache.moveToBack(cachedResults); | 848 runCache.moveToBack(cachedResults); |
| 849 previousRun = currentRun; | 849 previousRun = currentRun; |
| 850 continue; | 850 continue; |
| 851 } | 851 } |
| 852 runCache.remove(cachedResults); | 852 runCache.remove(cachedResults); |
| 853 } | 853 } |
| 854 | 854 |
| 855 // Add a space as pre-context to the buffer. This prevents showing dotte d-circle | 855 // Add a characterSpace as pre-context to the buffer. This prevents show ing dotted-circle |
|
jsbell
2015/05/05 17:29:53
While technically correct, I would not make this c
h.joshi
2015/05/11 07:06:32
Done.
| |
| 856 // for combining marks at the beginning of runs. | 856 // for combining marks at the beginning of runs. |
| 857 static const uint16_t preContext = space; | 857 static const uint16_t preContext = characterSpace; |
| 858 hb_buffer_add_utf16(harfBuzzBuffer.get(), &preContext, 1, 1, 0); | 858 hb_buffer_add_utf16(harfBuzzBuffer.get(), &preContext, 1, 1, 0); |
| 859 | 859 |
| 860 addToHarfBuzzBufferInternal(harfBuzzBuffer.get(), | 860 addToHarfBuzzBufferInternal(harfBuzzBuffer.get(), |
| 861 fontDescription, m_normalizedBuffer.get(), currentRun->startIndex(), | 861 fontDescription, m_normalizedBuffer.get(), currentRun->startIndex(), |
| 862 currentRun->numCharacters()); | 862 currentRun->numCharacters()); |
| 863 | 863 |
| 864 if (fontDescription.isVerticalAnyUpright()) | 864 if (fontDescription.isVerticalAnyUpright()) |
| 865 face->setScriptForVerticalGlyphSubstitution(harfBuzzBuffer.get()); | 865 face->setScriptForVerticalGlyphSubstitution(harfBuzzBuffer.get()); |
| 866 | 866 |
| 867 HarfBuzzScopedPtr<hb_font_t> harfBuzzFont(face->createFont(), hb_font_de stroy); | 867 HarfBuzzScopedPtr<hb_font_t> harfBuzzFont(face->createFont(), hb_font_de stroy); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 clusterEnd = currentCharacterIndex; | 1090 clusterEnd = currentCharacterIndex; |
| 1091 else | 1091 else |
| 1092 clusterEnd = isRunEnd ? currentRun->startIndex() + currentRun->n umCharacters() : currentRun->startIndex() + glyphToCharacterIndexes[i + 1]; | 1092 clusterEnd = isRunEnd ? currentRun->startIndex() + currentRun->n umCharacters() : currentRun->startIndex() + glyphToCharacterIndexes[i + 1]; |
| 1093 | 1093 |
| 1094 graphemesInCluster = countGraphemesInCluster(m_normalizedBuffer.get( ), m_normalizedBufferLength, clusterStart, clusterEnd); | 1094 graphemesInCluster = countGraphemesInCluster(m_normalizedBuffer.get( ), m_normalizedBufferLength, clusterStart, clusterEnd); |
| 1095 if (!graphemesInCluster || !clusterAdvance) | 1095 if (!graphemesInCluster || !clusterAdvance) |
| 1096 continue; | 1096 continue; |
| 1097 | 1097 |
| 1098 float glyphAdvanceX = clusterAdvance / graphemesInCluster; | 1098 float glyphAdvanceX = clusterAdvance / graphemesInCluster; |
| 1099 for (unsigned j = 0; j < graphemesInCluster; ++j) { | 1099 for (unsigned j = 0; j < graphemesInCluster; ++j) { |
| 1100 // Do not put emphasis marks on space, separator, and control ch aracters. | 1100 // Do not put emphasis marks on characterSpace, separator, and c ontrol characters. |
|
jsbell
2015/05/05 17:29:53
This comment change is incorrect.
h.joshi
2015/05/11 07:06:32
Done.
| |
| 1101 if (Character::canReceiveTextEmphasis(m_run[currentCharacterInde x])) | 1101 if (Character::canReceiveTextEmphasis(m_run[currentCharacterInde x])) |
| 1102 addEmphasisMark(glyphBuffer, advanceSoFar + glyphAdvanceX / 2); | 1102 addEmphasisMark(glyphBuffer, advanceSoFar + glyphAdvanceX / 2); |
| 1103 | 1103 |
| 1104 advanceSoFar += glyphAdvanceX; | 1104 advanceSoFar += glyphAdvanceX; |
| 1105 } | 1105 } |
| 1106 clusterStart = clusterEnd; | 1106 clusterStart = clusterEnd; |
| 1107 clusterAdvance = 0; | 1107 clusterAdvance = 0; |
| 1108 } | 1108 } |
| 1109 } | 1109 } |
| 1110 | 1110 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1206 // possibly invalid from, to arguments. | 1206 // possibly invalid from, to arguments. |
| 1207 if (!foundToX && !foundFromX) | 1207 if (!foundToX && !foundFromX) |
| 1208 fromX = toX = 0; | 1208 fromX = toX = 0; |
| 1209 | 1209 |
| 1210 if (fromX < toX) | 1210 if (fromX < toX) |
| 1211 return FloatRect(point.x() + fromX, point.y(), toX - fromX, height); | 1211 return FloatRect(point.x() + fromX, point.y(), toX - fromX, height); |
| 1212 return FloatRect(point.x() + toX, point.y(), fromX - toX, height); | 1212 return FloatRect(point.x() + toX, point.y(), fromX - toX, height); |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 } // namespace blink | 1215 } // namespace blink |
| OLD | NEW |