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

Unified Diff: Source/platform/fonts/GlyphPage.h

Issue 243453003: Proper unicode-range font loading behavior (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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: Source/platform/fonts/GlyphPage.h
diff --git a/Source/platform/fonts/GlyphPage.h b/Source/platform/fonts/GlyphPage.h
index 68d249a6bd7783d0a214e3b3e9ad80bb388316e3..c32bf148d5a9d0933f3e744013af547a08a4b7c4 100644
--- a/Source/platform/fonts/GlyphPage.h
+++ b/Source/platform/fonts/GlyphPage.h
@@ -31,6 +31,7 @@
#define GlyphPage_h
#include "platform/PlatformExport.h"
+#include "platform/fonts/CustomFontData.h"
#include "platform/fonts/Glyph.h"
#include <string.h>
#include "wtf/PassRefPtr.h"
@@ -93,6 +94,7 @@ public:
page->m_perGlyphFontData[i] = m_glyphs[i] ? m_fontDataForAllGlyphs : 0;
}
}
+ page->m_customFontToLoad = m_customFontToLoad;
return page.release();
}
@@ -104,7 +106,10 @@ public:
ALWAYS_INLINE GlyphData glyphDataForCharacter(UChar32 c) const
{
- return glyphDataForIndex(indexForCharacter(c));
+ unsigned index = indexForCharacter(c);
+ if (const CustomFontData* customData = customFontToLoadAt(index))
+ customData->beginLoadIfNeeded();
+ return glyphDataForIndex(index);
}
ALWAYS_INLINE GlyphData glyphDataForIndex(unsigned index) const
@@ -127,14 +132,6 @@ public:
return m_glyphs[index];
}
- ALWAYS_INLINE const SimpleFontData* fontDataForCharacter(UChar32 c) const
- {
- unsigned index = indexForCharacter(c);
- if (hasPerGlyphFontData())
- return m_perGlyphFontData[index];
- return m_glyphs[index] ? m_fontDataForAllGlyphs : 0;
- }
-
void setGlyphDataForCharacter(UChar32 c, Glyph g, const SimpleFontData* f)
{
setGlyphDataForIndex(indexForCharacter(c), g, f);
@@ -144,6 +141,7 @@ public:
{
ASSERT_WITH_SECURITY_IMPLICATION(index < size);
m_glyphs[index] = glyph;
+ setCustomFontToLoad(index, 0);
// GlyphPage getters will always return a null SimpleFontData* for glyph #0 if there's no per-glyph font array.
if (hasPerGlyphFontData()) {
@@ -160,6 +158,23 @@ public:
setGlyphDataForIndex(index, glyphData.glyph, glyphData.fontData);
}
+ const CustomFontData* customFontToLoadAt(unsigned index) const
+ {
+ ASSERT_WITH_SECURITY_IMPLICATION(index < size);
+ return m_customFontToLoad ? m_customFontToLoad->at(index) : 0;
+ }
+
+ void setCustomFontToLoad(unsigned index, const CustomFontData* customFontToLoad)
+ {
+ if (!m_customFontToLoad) {
+ if (!customFontToLoad)
+ return;
+ m_customFontToLoad = CustomDataPage::create();
+ }
+ ASSERT_WITH_SECURITY_IMPLICATION(index < size);
+ m_customFontToLoad->set(index, customFontToLoad);
+ }
+
void removeFontDataFromSystemFallbackPage(const SimpleFontData* fontData)
{
// This method should only be called on the system fallback page, which is never single-font.
@@ -186,8 +201,19 @@ private:
bool hasPerGlyphFontData() const { return !m_fontDataForAllGlyphs; }
+ class CustomDataPage : public RefCounted<CustomDataPage> {
+ public:
+ static RefPtr<CustomDataPage> create() { return adoptRef(new CustomDataPage()); }
+ const CustomFontData* at(size_t index) const { return m_customData[index]; }
+ void set(size_t index, const CustomFontData* data) { m_customData[index] = data; }
+ private:
+ CustomDataPage() { memset(m_customData, 0, sizeof(m_customData)); }
+ const CustomFontData* m_customData[size];
+ };
+
const SimpleFontData* m_fontDataForAllGlyphs;
GlyphPageTreeNode* m_owner;
+ RefPtr<CustomDataPage> m_customFontToLoad;
Glyph m_glyphs[size];
// NOTE: This array has (GlyphPage::size) elements if m_fontDataForAllGlyphs is null.

Powered by Google App Engine
This is Rietveld 408576698