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

Unified Diff: third_party/WebKit/Source/platform/fonts/FontFallbackIterator.cpp

Issue 1806653002: Shape unicode-range: font faces in only one iteration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update UnicodeRangeSetTests to RefPtrtr, rm copy constructor and test Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/fonts/FontFallbackIterator.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/FontFallbackIterator.cpp b/third_party/WebKit/Source/platform/fonts/FontFallbackIterator.cpp
index a80122f9b09f55bb59c237e207033e029cd8654c..7467c93d0d4a991559a1940033b54cec5031b1d7 100644
--- a/third_party/WebKit/Source/platform/fonts/FontFallbackIterator.cpp
+++ b/third_party/WebKit/Source/platform/fonts/FontFallbackIterator.cpp
@@ -28,7 +28,7 @@ FontFallbackIterator::FontFallbackIterator(const FontDescription& description,
: m_fontDescription(description)
, m_fontFallbackList(fallbackList)
, m_currentFontDataIndex(0)
- , m_segmentedIndex(0)
+ , m_segmentedFaceIndex(0)
, m_fallbackStage(FontGroupFonts)
, m_fontFallbackPriority(fontFallbackPriority)
{
@@ -46,17 +46,17 @@ bool FontFallbackIterator::needsHintList() const
bool FontFallbackIterator::alreadyLoadingRangeForHintChar(UChar32 hintChar)
{
- for (auto it = m_loadingCustomFontForRanges.begin(); it != m_loadingCustomFontForRanges.end(); ++it) {
+ for (auto it = m_trackedLoadingRangeSets.begin(); it != m_trackedLoadingRangeSets.end(); ++it) {
if (it->contains(hintChar))
return true;
}
return false;
}
-bool FontFallbackIterator::rangeContributesForHint(const Vector<UChar32> hintList, const FontDataRange& fontDataRange)
+bool FontFallbackIterator::rangeSetContributesForHint(const Vector<UChar32> hintList, const FontDataForRangeSet& segmentedFace)
{
for (auto it = hintList.begin(); it != hintList.end(); ++it) {
- if (*it >= fontDataRange.from() && *it <= fontDataRange.to()) {
+ if (segmentedFace.contains(*it)) {
if (!alreadyLoadingRangeForHintChar(*it))
return true;
}
@@ -64,25 +64,25 @@ bool FontFallbackIterator::rangeContributesForHint(const Vector<UChar32> hintLis
return false;
}
-void FontFallbackIterator::willUseRange(const AtomicString& family, const FontDataRange& range)
+void FontFallbackIterator::willUseRange(const AtomicString& family, const FontDataForRangeSet& rangeSet)
{
FontSelector* selector = m_fontFallbackList->getFontSelector();
if (!selector)
return;
- selector->willUseRange(m_fontDescription, family, range);
+ selector->willUseRange(m_fontDescription, family, rangeSet);
}
-const FontDataRange FontFallbackIterator::next(const Vector<UChar32>& hintList)
+const FontDataForRangeSet FontFallbackIterator::next(const Vector<UChar32>& hintList)
{
if (m_fallbackStage == OutOfLuck)
- return FontDataRange();
+ return FontDataForRangeSet();
if (m_fallbackStage == FallbackPriorityFonts) {
// Only try one fallback priority font,
// then proceed to regular system fallback.
m_fallbackStage = SystemFonts;
- FontDataRange fallbackPriorityFontRange(fallbackPriorityFont(hintList[0]));
+ FontDataForRangeSet fallbackPriorityFontRange(fallbackPriorityFont(hintList[0]));
if (fallbackPriorityFontRange.hasFontData())
return fallbackPriorityFontRange;
return next(hintList);
@@ -93,7 +93,7 @@ const FontDataRange FontFallbackIterator::next(const Vector<UChar32>& hintList)
ASSERT(hintList.size());
RefPtr<SimpleFontData> systemFont = uniqueSystemFontForHint(hintList[0]);
if (systemFont)
- return FontDataRange(systemFont);
+ return FontDataForRangeSet(systemFont);
// If we don't have options from the system fallback anymore or had
// previously returned them, we only have the last resort font left.
@@ -104,7 +104,7 @@ const FontDataRange FontFallbackIterator::next(const Vector<UChar32>& hintList)
m_fallbackStage = OutOfLuck;
RefPtr<SimpleFontData> lastResort = fontCache->getLastResortFallbackFont(m_fontDescription).get();
RELEASE_ASSERT(lastResort);
- return FontDataRange(lastResort);
+ return FontDataForRangeSet(lastResort);
}
ASSERT(m_fallbackStage == FontGroupFonts
@@ -129,7 +129,7 @@ const FontDataRange FontFallbackIterator::next(const Vector<UChar32>& hintList)
m_currentFontDataIndex++;
if (!fontData->isLoading()) {
RefPtr<SimpleFontData> nonSegmented = const_cast<SimpleFontData*>(toSimpleFontData(fontData));
- return FontDataRange(nonSegmented);
+ return FontDataForRangeSet(nonSegmented);
}
return next(hintList);
}
@@ -138,27 +138,27 @@ const FontDataRange FontFallbackIterator::next(const Vector<UChar32>& hintList)
const SegmentedFontData* segmented = toSegmentedFontData(fontData);
if (m_fallbackStage != SegmentedFace) {
- m_segmentedIndex = 0;
+ m_segmentedFaceIndex = 0;
m_fallbackStage = SegmentedFace;
}
- ASSERT(m_segmentedIndex < segmented->numRanges());
- FontDataRange currentRange = segmented->rangeAt(m_segmentedIndex);
- m_segmentedIndex++;
+ ASSERT(m_segmentedFaceIndex < segmented->numFaces());
+ FontDataForRangeSet currentSegmentedFace = segmented->faceAt(m_segmentedFaceIndex);
+ m_segmentedFaceIndex++;
- if (m_segmentedIndex == segmented->numRanges()) {
+ if (m_segmentedFaceIndex == segmented->numFaces()) {
// Switch from iterating over a segmented face to the next family from
// the font-family: group of fonts.
m_fallbackStage = FontGroupFonts;
m_currentFontDataIndex++;
}
- if (rangeContributesForHint(hintList, currentRange)) {
- if (currentRange.fontData()->customFontData())
- currentRange.fontData()->customFontData()->beginLoadIfNeeded();
- if (!currentRange.fontData()->isLoading())
- return currentRange;
- m_loadingCustomFontForRanges.append(currentRange);
+ if (rangeSetContributesForHint(hintList, currentSegmentedFace)) {
+ if (currentSegmentedFace.fontData()->customFontData())
+ currentSegmentedFace.fontData()->customFontData()->beginLoadIfNeeded();
+ if (!currentSegmentedFace.fontData()->isLoading())
+ return currentSegmentedFace;
+ m_trackedLoadingRangeSets.append(currentSegmentedFace);
}
return next(hintList);

Powered by Google App Engine
This is Rietveld 408576698