15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* 2926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved. 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) Research In Motion Limited 2011. All rights reserved. 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * are met: 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 1. Redistributions of source code must retain the above copyright 1002772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch * notice, this list of conditions and the following disclaimer. 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer in the 1302772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch * documentation and/or other materials provided with the distribution. 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * its contributors may be used to endorse or promote products derived 1602772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch * from this software without specific prior written permission. 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */ 295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef GlyphPage_h 315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define GlyphPage_h 325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 33a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "platform/PlatformExport.h" 34f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu#include "platform/fonts/CustomFontData.h" 35f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)#include "platform/fonts/Glyph.h" 3653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include <string.h> 377757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch#include "wtf/PassRefPtr.h" 387757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch#include "wtf/RefCounted.h" 397757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch#include "wtf/RefPtr.h" 407757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch#include "wtf/unicode/Unicode.h" 415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 42c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class SimpleFontData; 455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class GlyphPageTreeNode; 465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Holds the glyph index and the corresponding SimpleFontData information for a given 485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// character. 495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)struct GlyphData { 505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) GlyphData(Glyph g = 0, const SimpleFontData* f = 0) 515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) : glyph(g) 525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) , fontData(f) 535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Glyph glyph; 565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const SimpleFontData* fontData; 575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}; 585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 59926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#if COMPILER(MSVC) 60926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#pragma warning(push) 61926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#pragma warning(disable: 4200) // Disable "zero-sized array in struct/union" warning 62926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#endif 63926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// A GlyphPage contains a fixed-size set of GlyphData mappings for a contiguous 655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// range of characters in the Unicode code space. GlyphPages are indexed 665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// starting from 0 and incrementing for each 256 glyphs. 675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// 685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// One page may actually include glyphs from other fonts if the characters are 695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// missing in the primary font. It is owned by exactly one GlyphPageTreeNode, 705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// although multiple nodes may reference it as their "page" if they are supposed 715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// to be overriding the parent's node, but provide no additional information. 72a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)class PLATFORM_EXPORT GlyphPage : public RefCounted<GlyphPage> { 735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public: 74926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) static PassRefPtr<GlyphPage> createForMixedFontData(GlyphPageTreeNode* owner) 75926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) { 76926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) void* slot = fastMalloc(sizeof(GlyphPage) + sizeof(SimpleFontData*) * GlyphPage::size); 77926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return adoptRef(new (slot) GlyphPage(owner)); 78926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 79926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 80926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) static PassRefPtr<GlyphPage> createForSingleFontData(GlyphPageTreeNode* owner, const SimpleFontData* fontData) 815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 82926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) ASSERT(fontData); 83926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return adoptRef(new GlyphPage(owner, fontData)); 845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 86926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) PassRefPtr<GlyphPage> createCopiedSystemFallbackPage(GlyphPageTreeNode* owner) const 87926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) { 88926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) RefPtr<GlyphPage> page = GlyphPage::createForMixedFontData(owner); 89926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) memcpy(page->m_glyphs, m_glyphs, sizeof(m_glyphs)); 90926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (hasPerGlyphFontData()) 91926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) memcpy(page->m_perGlyphFontData, m_perGlyphFontData, sizeof(SimpleFontData*) * GlyphPage::size); 92926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) else { 93926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) for (size_t i = 0; i < GlyphPage::size; ++i) { 94926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) page->m_perGlyphFontData[i] = m_glyphs[i] ? m_fontDataForAllGlyphs : 0; 95926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 96926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 97f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu page->m_customFontToLoad = m_customFontToLoad; 98926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return page.release(); 99926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 100926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 101926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) ~GlyphPage() { } 102926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 103a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch static const unsigned char sizeBits = 8; 104a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch static const size_t size = (1 << GlyphPage::sizeBits); // Covers Latin-1 in a single page. 105a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch static unsigned indexForCharacter(UChar32 c) { return c & 0xFF; } 1065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 107926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) ALWAYS_INLINE GlyphData glyphDataForCharacter(UChar32 c) const 1085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 109f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu unsigned index = indexForCharacter(c); 110f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu if (const CustomFontData* customData = customFontToLoadAt(index)) 111f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu customData->beginLoadIfNeeded(); 112f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu return glyphDataForIndex(index); 1135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 115926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) ALWAYS_INLINE GlyphData glyphDataForIndex(unsigned index) const 1165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 117926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) ASSERT_WITH_SECURITY_IMPLICATION(index < size); 118926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) Glyph glyph = m_glyphs[index]; 119926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (hasPerGlyphFontData()) 120926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return GlyphData(glyph, m_perGlyphFontData[index]); 121926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return GlyphData(glyph, glyph ? m_fontDataForAllGlyphs : 0); 1225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 124c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles) ALWAYS_INLINE Glyph glyphForCharacter(UChar32 c) const 125c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles) { 126c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles) return glyphAt(indexForCharacter(c)); 127c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles) } 128c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles) 129926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) ALWAYS_INLINE Glyph glyphAt(unsigned index) const 1305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 131926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) ASSERT_WITH_SECURITY_IMPLICATION(index < size); 1325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return m_glyphs[index]; 1335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void setGlyphDataForCharacter(UChar32 c, Glyph g, const SimpleFontData* f) 1365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 1375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setGlyphDataForIndex(indexForCharacter(c), g, f); 1385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 140926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) void setGlyphDataForIndex(unsigned index, Glyph glyph, const SimpleFontData* fontData) 1415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 142926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) ASSERT_WITH_SECURITY_IMPLICATION(index < size); 143926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) m_glyphs[index] = glyph; 144f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu setCustomFontToLoad(index, 0); 145926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 146926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (hasPerGlyphFontData()) { 147197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch m_perGlyphFontData[index] = fontData; 148197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } else { 149197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch // A single-font GlyphPage already assigned m_fontDataForAllGlyphs in the constructor. 150197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch ASSERT(!glyph || fontData == m_fontDataForAllGlyphs); 151926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 1525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void setGlyphDataForIndex(unsigned index, const GlyphData& glyphData) 1555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 1565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) setGlyphDataForIndex(index, glyphData.glyph, glyphData.fontData); 1575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 159f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu const CustomFontData* customFontToLoadAt(unsigned index) const 160f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu { 161f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu ASSERT_WITH_SECURITY_IMPLICATION(index < size); 162f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu return m_customFontToLoad ? m_customFontToLoad->at(index) : 0; 163f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu } 164f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu 165f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu void setCustomFontToLoad(unsigned index, const CustomFontData* customFontToLoad) 166f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu { 167f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu if (!m_customFontToLoad) { 168f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu if (!customFontToLoad) 169f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu return; 170f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu m_customFontToLoad = CustomDataPage::create(); 171f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu } 172f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu ASSERT_WITH_SECURITY_IMPLICATION(index < size); 173f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu m_customFontToLoad->set(index, customFontToLoad); 174f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu } 175f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu 176926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) void removeFontDataFromSystemFallbackPage(const SimpleFontData* fontData) 1775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 178926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) // This method should only be called on the system fallback page, which is never single-font. 179926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) ASSERT(hasPerGlyphFontData()); 1805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) for (size_t i = 0; i < size; ++i) { 181926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (m_perGlyphFontData[i] == fontData) { 1825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) m_glyphs[i] = 0; 183926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) m_perGlyphFontData[i] = 0; 1845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) GlyphPageTreeNode* owner() const { return m_owner; } 1895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)private: 191926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) explicit GlyphPage(GlyphPageTreeNode* owner, const SimpleFontData* fontDataForAllGlyphs = 0) 192926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) : m_fontDataForAllGlyphs(fontDataForAllGlyphs) 193926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) , m_owner(owner) 1945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 195926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) memset(m_glyphs, 0, sizeof(m_glyphs)); 196926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) if (hasPerGlyphFontData()) 197926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) memset(m_perGlyphFontData, 0, sizeof(SimpleFontData*) * GlyphPage::size); 1985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 200926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) bool hasPerGlyphFontData() const { return !m_fontDataForAllGlyphs; } 2015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 202f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu class CustomDataPage : public RefCounted<CustomDataPage> { 203f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu public: 204f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu static RefPtr<CustomDataPage> create() { return adoptRef(new CustomDataPage()); } 205f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu const CustomFontData* at(size_t index) const { return m_customData[index]; } 206f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu void set(size_t index, const CustomFontData* data) { m_customData[index] = data; } 207f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu private: 208f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu CustomDataPage() { memset(m_customData, 0, sizeof(m_customData)); } 209f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu const CustomFontData* m_customData[size]; 210f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu }; 211f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu 212926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) const SimpleFontData* m_fontDataForAllGlyphs; 2135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) GlyphPageTreeNode* m_owner; 214f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu RefPtr<CustomDataPage> m_customFontToLoad; 215926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) Glyph m_glyphs[size]; 216926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 217926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) // NOTE: This array has (GlyphPage::size) elements if m_fontDataForAllGlyphs is null. 218926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) const SimpleFontData* m_perGlyphFontData[0]; 2195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}; 2205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 221926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#if COMPILER(MSVC) 222926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#pragma warning(pop) 223926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#endif 224926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 225c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink 2265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 227926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#endif // GlyphPage_h 228