void CSSFontSelector::clearDocument() { if (!m_document) { ASSERT(!m_beginLoadingTimer.isActive()); ASSERT(m_fontsToBeginLoading.isEmpty()); return; } m_beginLoadingTimer.stop(); ResourceFetcher* fetcher = m_document->fetcher(); for (size_t i = 0; i < m_fontsToBeginLoading.size(); ++i) { // Balances incrementRequestCount() in beginLoadingFontSoon(). fetcher->decrementRequestCount(m_fontsToBeginLoading[i].get()); } m_fontsToBeginLoading.clear(); m_document = 0; }
void CSSFontSelector::beginLoadTimerFired(Timer<WebCore::CSSFontSelector>*) { Vector<ResourcePtr<FontResource> > fontsToBeginLoading; fontsToBeginLoading.swap(m_fontsToBeginLoading); // CSSFontSelector could get deleted via beginLoadIfNeeded() or loadDone() unless protected. RefPtr<CSSFontSelector> protect(this); ResourceFetcher* fetcher = m_document->fetcher(); for (size_t i = 0; i < fontsToBeginLoading.size(); ++i) { fontsToBeginLoading[i]->beginLoadIfNeeded(fetcher); // Balances incrementRequestCount() in beginLoadingFontSoon(). fetcher->decrementRequestCount(fontsToBeginLoading[i].get()); } // Ensure that if the request count reaches zero, the frame loader will know about it. fetcher->didLoadResource(0); // New font loads may be triggered by layout after the document load is complete but before we have dispatched // didFinishLoading for the frame. Make sure the delegate is always dispatched by checking explicitly. if (m_document && m_document->frame()) m_document->frame()->loader()->checkLoadComplete(); }