のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

CSSFontSelector

    157 void FontResource::checkNotify()
    158 {
    159     ResourceClientWalker<FontResourceClient> w(m_clients);
    160     while (FontResourceClient* c = w.next())
    161         c->fontLoaded(this);
    162 }
   529 void FontCache::invalidate()
    530 {
    531     if (!gClients) {
    532         ASSERT(!gFontPlatformDataCache);
    533         return;
    534     }
    535 
    536     if (gFontPlatformDataCache) {
    537         deleteAllValues(*gFontPlatformDataCache);
    538         delete gFontPlatformDataCache;
    539         gFontPlatformDataCache = new FontPlatformDataCache;
    540     }
    541 
    542     gGeneration++;
    543 
    544     Vector<RefPtr<FontSelector> > clients;
    545     size_t numClients = gClients->size();
    546     clients.reserveInitialCapacity(numClients);
    547     HashSet<FontSelector*>::iterator end = gClients->end();
    548     for (HashSet<FontSelector*>::iterator it = gClients->begin(); it != end; ++it)
    549         clients.append(*it);
    550 
    551     ASSERT(numClients == clients.size());
    552     for (size_t i = 0; i < numClients; ++i)
    553         clients[i]->fontCacheInvalidated(); <=====
    554 
    555     purgeInactiveFontData();
    556 }

=========================================================================================================

    344 void CSSFontSelector::fontLoaded()
    345 {
    346     dispatchInvalidationCallbacks();
    347 }
    348 
    349 void CSSFontSelector::fontCacheInvalidated()
    350 {
    351     dispatchInvalidationCallbacks();
    352 }
    327 void CSSFontSelector::dispatchInvalidationCallbacks()
    328 {
    329     Vector<FontSelectorClient*> clients;
    330     copyToVector(m_clients, clients);
    331     for (size_t i = 0; i < clients.size(); ++i)
    332         clients[i]->fontsNeedUpdate(this);
    333 
    334     // FIXME: Make Document a FontSelectorClient so that it can simply register for invalidation callbacks.
    335     if (!m_document)
    336         return;
    337     if (StyleResolver* styleResolver = m_document->styleResolverIfExists())
    338         styleResolver->invalidateMatchedPropertiesCache();
    339     if (!m_document->renderer())
    340         return;
    341     m_document->setNeedsStyleRecalc();
    342 }
   236 void CanvasRenderingContext2D::State::fontsNeedUpdate(FontSelector* fontSelector)
    237 {
    238     ASSERT_ARG(fontSelector, fontSelector == m_font.fontSelector());
    239     ASSERT(m_realizedFont);
    240 
    241     m_font.update(fontSelector);
    242 }
    165 void Font::update(PassRefPtr<FontSelector> fontSelector) const
    166 {
    167     // FIXME: It is pretty crazy that we are willing to just poke into a RefPtr, but it ends up
    168     // being reasonably safe (because inherited fonts in the render tree pick up the new
    169     // style anyway. Other copies are transient, e.g., the state in the GraphicsContext, and
    170     // won't stick around long enough to get you in trouble). Still, this is pretty disgusting,
    171     // and could eventually be rectified by using RefPtrs for Fonts themselves.
    172     if (!m_fontFallbackList)
    173         m_fontFallbackList = FontFallbackList::create();
    174     m_fontFallbackList->invalidate(fontSelector);
    175     m_typesettingFeatures = computeTypesettingFeatures();
    176 }
     49 void FontFallbackList::invalidate(PassRefPtr<FontSelector> fontSelector)
     50 {
     51     releaseFontData();
     52     m_fontList.clear();
     53     m_pageZero = 0;
     54     m_pages.clear();
     55     m_cachedPrimarySimpleFontData = 0;
     56     m_familyIndex = 0;
     57     m_pitch = UnknownPitch;
     58     m_loadingCustomFonts = false;
     59     m_fontSelector = fontSelector;
     60     m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0;
     61     m_generation = fontCache()->generation();
     62     m_widthCache.clear();
     63 }