Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp

Issue 138553003: Break HarfBuzzShaper::collectHarfBuzzRuns apart (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 return false; 552 return false;
553 553
554 return true; 554 return true;
555 } 555 }
556 556
557 FloatPoint HarfBuzzShaper::adjustStartPoint(const FloatPoint& point) 557 FloatPoint HarfBuzzShaper::adjustStartPoint(const FloatPoint& point)
558 { 558 {
559 return point + m_startOffset; 559 return point + m_startOffset;
560 } 560 }
561 561
562 static inline int handleMultipleUChar(
563 UChar32 character,
564 unsigned clusterLength,
565 const SimpleFontData* currentFontData,
566 const UChar* currentCharacterPosition,
567 const UChar* markCharactersEnd,
568 const UChar* normalizedBufferEnd)
569 {
570 if (U_GET_GC_MASK(character) & U_GC_M_MASK) {
571 int markLength = clusterLength;
572 while (markCharactersEnd < normalizedBufferEnd) {
573 UChar32 nextCharacter;
574 int nextCharacterLength = 0;
575 U16_NEXT(markCharactersEnd, nextCharacterLength, normalizedBufferEnd - markCharactersEnd, nextCharacter);
576 if (!(U_GET_GC_MASK(nextCharacter) & U_GC_M_MASK))
577 break;
578 markLength += nextCharacterLength;
579 markCharactersEnd += nextCharacterLength;
580 }
581
582 if (currentFontData->canRenderCombiningCharacterSequence(currentCharacte rPosition, markCharactersEnd - currentCharacterPosition)) {
583 return markLength;
584 }
585 }
586 return 0;
587 }
588
562 bool HarfBuzzShaper::collectHarfBuzzRuns() 589 bool HarfBuzzShaper::collectHarfBuzzRuns()
563 { 590 {
564 const UChar* normalizedBufferEnd = m_normalizedBuffer.get() + m_normalizedBu fferLength; 591 const UChar* normalizedBufferEnd = m_normalizedBuffer.get() + m_normalizedBu fferLength;
565 SurrogatePairAwareTextIterator iterator(m_normalizedBuffer.get(), 0, m_norma lizedBufferLength, m_normalizedBufferLength); 592 SurrogatePairAwareTextIterator iterator(m_normalizedBuffer.get(), 0, m_norma lizedBufferLength, m_normalizedBufferLength);
566 UChar32 character; 593 UChar32 character;
567 unsigned clusterLength = 0; 594 unsigned clusterLength = 0;
568 unsigned startIndexOfCurrentRun = 0; 595 unsigned startIndexOfCurrentRun = 0;
569 if (!iterator.consume(character, clusterLength)) 596 if (!iterator.consume(character, clusterLength))
570 return false; 597 return false;
571 598
572 const SimpleFontData* nextFontData = m_font->glyphDataForCharacter(character , false).fontData; 599 const SimpleFontData* nextFontData = m_font->glyphDataForCharacter(character , false).fontData;
573 UErrorCode errorCode = U_ZERO_ERROR; 600 UErrorCode errorCode = U_ZERO_ERROR;
574 UScriptCode nextScript = uscript_getScript(character, &errorCode); 601 UScriptCode nextScript = uscript_getScript(character, &errorCode);
575 if (U_FAILURE(errorCode)) 602 if (U_FAILURE(errorCode))
576 return false; 603 return false;
577 604
578 do { 605 do {
579 const UChar* currentCharacterPosition = iterator.characters(); 606 const UChar* currentCharacterPosition = iterator.characters();
580 const SimpleFontData* currentFontData = nextFontData; 607 const SimpleFontData* currentFontData = nextFontData;
581 UScriptCode currentScript = nextScript; 608 UScriptCode currentScript = nextScript;
582 609
583 for (iterator.advance(clusterLength); iterator.consume(character, cluste rLength); iterator.advance(clusterLength)) { 610 for (iterator.advance(clusterLength); iterator.consume(character, cluste rLength); iterator.advance(clusterLength)) {
584 if (Font::treatAsZeroWidthSpace(character)) 611 if (Font::treatAsZeroWidthSpace(character))
585 continue; 612 continue;
586 613
587 if (U_GET_GC_MASK(character) & U_GC_M_MASK) { 614 int length = handleMultipleUChar(character, clusterLength, currentFo ntData, currentCharacterPosition, iterator.characters() + clusterLength, normali zedBufferEnd);
588 int markLength = clusterLength; 615 if (length) {
589 const UChar* markCharactersEnd = iterator.characters() + cluster Length; 616 clusterLength = length;
590 while (markCharactersEnd < normalizedBufferEnd) { 617 continue;
591 UChar32 nextCharacter;
592 int nextCharacterLength = 0;
593 U16_NEXT(markCharactersEnd, nextCharacterLength, normalizedB ufferEnd - markCharactersEnd, nextCharacter);
594 if (!(U_GET_GC_MASK(nextCharacter) & U_GC_M_MASK))
595 break;
596 markLength += nextCharacterLength;
597 markCharactersEnd += nextCharacterLength;
598 }
599
600 if (currentFontData->canRenderCombiningCharacterSequence(current CharacterPosition, markCharactersEnd - currentCharacterPosition)) {
601 clusterLength = markLength;
602 continue;
603 }
604 } 618 }
605 619
606 nextFontData = m_font->glyphDataForCharacter(character, false).fontD ata; 620 nextFontData = m_font->glyphDataForCharacter(character, false).fontD ata;
607 nextScript = uscript_getScript(character, &errorCode); 621 nextScript = uscript_getScript(character, &errorCode);
608 if (U_FAILURE(errorCode)) 622 if (U_FAILURE(errorCode))
609 return false; 623 return false;
610 if ((nextFontData != currentFontData) || ((currentScript != nextScri pt) && (nextScript != USCRIPT_INHERITED) && (!uscript_hasScript(character, curre ntScript)))) 624 if ((nextFontData != currentFontData) || ((currentScript != nextScri pt) && (nextScript != USCRIPT_INHERITED) && (!uscript_hasScript(character, curre ntScript))))
611 break; 625 break;
612 if (nextScript == USCRIPT_INHERITED) 626 if (nextScript == USCRIPT_INHERITED)
613 nextScript = currentScript; 627 nextScript = currentScript;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 if (!foundToX) 894 if (!foundToX)
881 toX = m_run.rtl() ? 0 : m_totalWidth; 895 toX = m_run.rtl() ? 0 : m_totalWidth;
882 896
883 // Using floorf() and roundf() as the same as mac port. 897 // Using floorf() and roundf() as the same as mac port.
884 if (fromX < toX) 898 if (fromX < toX)
885 return FloatRect(floorf(point.x() + fromX), point.y(), roundf(toX - from X), height); 899 return FloatRect(floorf(point.x() + fromX), point.y(), roundf(toX - from X), height);
886 return FloatRect(floorf(point.x() + toX), point.y(), roundf(fromX - toX), he ight); 900 return FloatRect(floorf(point.x() + toX), point.y(), roundf(fromX - toX), he ight);
887 } 901 }
888 902
889 } // namespace WebCore 903 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698