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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.cpp

Issue 2066253002: Fix Refcount in FontDataCache for objects from FontFallbackIterator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 // TODO: Check whether this treatAsZerowidthspace from the previous script 575 // TODO: Check whether this treatAsZerowidthspace from the previous script
576 // segmentation plays a role here, does the new scriptRuniterator handle tha t correctly? 576 // segmentation plays a role here, does the new scriptRuniterator handle tha t correctly?
577 while (runSegmenter.consume(&segmentRange)) { 577 while (runSegmenter.consume(&segmentRange)) {
578 RefPtr<FontFallbackIterator> fallbackIterator = 578 RefPtr<FontFallbackIterator> fallbackIterator =
579 m_font->createFontFallbackIterator( 579 m_font->createFontFallbackIterator(
580 segmentRange.fontFallbackPriority); 580 segmentRange.fontFallbackPriority);
581 581
582 appendToHolesQueue(HolesQueueNextFont, 0, 0); 582 appendToHolesQueue(HolesQueueNextFont, 0, 0);
583 appendToHolesQueue(HolesQueueRange, segmentRange.start, segmentRange.end - segmentRange.start); 583 appendToHolesQueue(HolesQueueRange, segmentRange.start, segmentRange.end - segmentRange.start);
584 584
585 const SimpleFontData* currentFont = nullptr; 585 RefPtr<FontDataForRangeSet> currentFontDataForRangeSet;
586 RefPtr<UnicodeRangeSet> currentFontRangeSet;
587 586
588 bool fontCycleQueued = false; 587 bool fontCycleQueued = false;
589 while (m_holesQueue.size()) { 588 while (m_holesQueue.size()) {
590 HolesQueueItem currentQueueItem = m_holesQueue.takeFirst(); 589 HolesQueueItem currentQueueItem = m_holesQueue.takeFirst();
591 590
592 if (currentQueueItem.m_action == HolesQueueNextFont) { 591 if (currentQueueItem.m_action == HolesQueueNextFont) {
593 // For now, we're building a character list with which we probe 592 // For now, we're building a character list with which we probe
594 // for needed fonts depending on the declared unicode-range of a 593 // for needed fonts depending on the declared unicode-range of a
595 // segmented CSS font. Alternatively, we can build a fake font 594 // segmented CSS font. Alternatively, we can build a fake font
596 // for the shaper and check whether any glyphs were found, or 595 // for the shaper and check whether any glyphs were found, or
597 // define a new API on the shaper which will give us coverage 596 // define a new API on the shaper which will give us coverage
598 // information? 597 // information?
599 if (!collectFallbackHintChars(fallbackCharsHint, fallbackIterato r->needsHintList())) { 598 if (!collectFallbackHintChars(fallbackCharsHint, fallbackIterato r->needsHintList())) {
600 // Give up shaping since we cannot retrieve a font fallback 599 // Give up shaping since we cannot retrieve a font fallback
601 // font without a hintlist. 600 // font without a hintlist.
602 m_holesQueue.clear(); 601 m_holesQueue.clear();
603 break; 602 break;
604 } 603 }
605 604
606 FontDataForRangeSet nextFontDataForRangeSet = fallbackIterator-> next(fallbackCharsHint); 605 currentFontDataForRangeSet = fallbackIterator->next(fallbackChar sHint);
607 currentFont = nextFontDataForRangeSet.fontData();
608 currentFontRangeSet = nextFontDataForRangeSet.ranges();
609 606
610 if (!currentFont) { 607 if (!currentFontDataForRangeSet->fontData()) {
611 ASSERT(!m_holesQueue.size()); 608 ASSERT(!m_holesQueue.size());
612 break; 609 break;
613 } 610 }
614 fontCycleQueued = false; 611 fontCycleQueued = false;
615 continue; 612 continue;
616 } 613 }
617 614
618 SmallCapsIterator::SmallCapsBehavior smallCapsBehavior = SmallCapsIt erator::SmallCapsSameCase; 615 SmallCapsIterator::SmallCapsBehavior smallCapsBehavior = SmallCapsIt erator::SmallCapsSameCase;
619 if (needsCapsHandling) { 616 if (needsCapsHandling) {
620 capsSupport = OpenTypeCapsSupport(currentFont->platformData().ha rfBuzzFace(), 617 capsSupport = OpenTypeCapsSupport(
618 currentFontDataForRangeSet->fontData()->platformData().harfB uzzFace(),
621 fontDescription.variantCaps(), 619 fontDescription.variantCaps(),
622 ICUScriptToHBScript(segmentRange.script)); 620 ICUScriptToHBScript(segmentRange.script));
623 if (capsSupport.needsRunCaseSplitting()) 621 if (capsSupport.needsRunCaseSplitting())
624 splitUntilNextCaseChange(currentQueueItem, smallCapsBehavior ); 622 splitUntilNextCaseChange(currentQueueItem, smallCapsBehavior );
625 } 623 }
626 624
627 ASSERT(currentQueueItem.m_numCharacters); 625 ASSERT(currentQueueItem.m_numCharacters);
628 626
629 const SimpleFontData* smallcapsAdjustedFont = needsCapsHandling 627 const SimpleFontData* smallcapsAdjustedFont = needsCapsHandling
630 && capsSupport.needsSyntheticFont(smallCapsBehavior) 628 && capsSupport.needsSyntheticFont(smallCapsBehavior)
631 ? currentFont->smallCapsFontData(fontDescription).get() 629 ? currentFontDataForRangeSet->fontData()->smallCapsFontData(font Description).get()
632 : currentFont; 630 : currentFontDataForRangeSet->fontData();
633 631
634 // Compatibility with SimpleFontData approach of keeping a flag for overriding drawing direction. 632 // Compatibility with SimpleFontData approach of keeping a flag for overriding drawing direction.
635 // TODO: crbug.com/506224 This should go away in favor of storing th at information elsewhere, for example in 633 // TODO: crbug.com/506224 This should go away in favor of storing th at information elsewhere, for example in
636 // ShapeResult. 634 // ShapeResult.
637 const SimpleFontData* directionAndSmallCapsAdjustedFont = fontDataAd justedForOrientation(smallcapsAdjustedFont, 635 const SimpleFontData* directionAndSmallCapsAdjustedFont = fontDataAd justedForOrientation(smallcapsAdjustedFont,
638 m_font->getFontDescription().orientation(), 636 m_font->getFontDescription().orientation(),
639 segmentRange.renderOrientation); 637 segmentRange.renderOrientation);
640 638
641 CaseMapIntend caseMapIntend = CaseMapIntend::KeepSameCase; 639 CaseMapIntend caseMapIntend = CaseMapIntend::KeepSameCase;
642 if (needsCapsHandling) { 640 if (needsCapsHandling) {
643 caseMapIntend = capsSupport.needsCaseChange(smallCapsBehavior); 641 caseMapIntend = capsSupport.needsCaseChange(smallCapsBehavior);
644 } 642 }
645 643
646 CaseMappingHarfBuzzBufferFiller( 644 CaseMappingHarfBuzzBufferFiller(
647 caseMapIntend, 645 caseMapIntend,
648 harfBuzzBuffer.get(), 646 harfBuzzBuffer.get(),
649 m_normalizedBuffer.get(), 647 m_normalizedBuffer.get(),
650 m_normalizedBufferLength, 648 m_normalizedBufferLength,
651 currentQueueItem.m_startIndex, 649 currentQueueItem.m_startIndex,
652 currentQueueItem.m_numCharacters); 650 currentQueueItem.m_numCharacters);
653 651
654 CapsFeatureSettingsScopedOverlay capsOverlay(m_features, capsSupport .fontFeatureToUse(smallCapsBehavior)); 652 CapsFeatureSettingsScopedOverlay capsOverlay(m_features, capsSupport .fontFeatureToUse(smallCapsBehavior));
655 653
656 if (!shapeRange(harfBuzzBuffer.get(), 654 if (!shapeRange(harfBuzzBuffer.get(),
657 currentQueueItem.m_startIndex, 655 currentQueueItem.m_startIndex,
658 currentQueueItem.m_numCharacters, 656 currentQueueItem.m_numCharacters,
659 directionAndSmallCapsAdjustedFont, 657 directionAndSmallCapsAdjustedFont,
660 currentFontRangeSet, 658 currentFontDataForRangeSet->ranges(),
661 segmentRange.script, 659 segmentRange.script,
662 language)) 660 language))
663 DLOG(ERROR) << "Shaping range failed."; 661 DLOG(ERROR) << "Shaping range failed.";
664 662
665 if (!extractShapeResults(harfBuzzBuffer.get(), 663 if (!extractShapeResults(harfBuzzBuffer.get(),
666 result.get(), 664 result.get(),
667 fontCycleQueued, 665 fontCycleQueued,
668 currentQueueItem, 666 currentQueueItem,
669 directionAndSmallCapsAdjustedFont, 667 directionAndSmallCapsAdjustedFont,
670 segmentRange.script, 668 segmentRange.script,
(...skipping 28 matching lines...) Expand all
699 result->m_width = run->m_width; 697 result->m_width = run->m_width;
700 result->m_numGlyphs = count; 698 result->m_numGlyphs = count;
701 ASSERT(result->m_numGlyphs == count); // no overflow 699 ASSERT(result->m_numGlyphs == count); // no overflow
702 result->m_hasVerticalOffsets = fontData->platformData().isVerticalAnyUpright (); 700 result->m_hasVerticalOffsets = fontData->platformData().isVerticalAnyUpright ();
703 result->m_runs.append(std::move(run)); 701 result->m_runs.append(std::move(run));
704 return result.release(); 702 return result.release();
705 } 703 }
706 704
707 705
708 } // namespace blink 706 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698