CSSSegmentedFontFace::~CSSSegmentedFontFace()
{
    pruneTable();
    unsigned size = m_fontFaces.size();
    for (unsigned i = 0; i < size; i++)
        m_fontFaces[i]->removedFromSegmentedFontFace(this);
}
Ejemplo n.º 2
0
void RemoteFontFaceSource::notifyFinished(Resource*) {
  m_histograms.maySetDataSource(m_font->response().wasCached()
                                    ? FontLoadHistograms::FromDiskCache
                                    : FontLoadHistograms::FromNetwork);
  m_histograms.recordRemoteFont(m_font.get(), m_isInterventionTriggered);
  m_histograms.fontLoaded(m_font->isCORSFailed(),
                          m_font->getStatus() == Resource::LoadError,
                          m_isInterventionTriggered);

  m_font->ensureCustomFontData();
  // FIXME: Provide more useful message such as OTS rejection reason.
  // See crbug.com/97467
  if (m_font->getStatus() == Resource::DecodeError &&
      m_fontSelector->document()) {
    m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create(
        OtherMessageSource, WarningMessageLevel,
        "Failed to decode downloaded font: " + m_font->url().elidedString()));
    if (m_font->otsParsingMessage().length() > 1)
      m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create(
          OtherMessageSource, WarningMessageLevel,
          "OTS parsing error: " + m_font->otsParsingMessage()));
  }

  pruneTable();
  if (m_face) {
    m_fontSelector->fontFaceInvalidated();
    m_face->fontLoaded(this);
  }
}
Ejemplo n.º 3
0
CSSSegmentedFontFace::~CSSSegmentedFontFace()
{
    pruneTable();
    unsigned size = m_fontFaces.size();
    for (unsigned i = 0; i < size; i++)
        m_fontFaces[i]->clearSegmentedFontFace();
}
Ejemplo n.º 4
0
/*
 * Recursively builds the decision tree based on
 * the data that it is passed and tha table info.
 */
node* buildDecisionTree(vvs &table, node* nodePtr, vvs &tableInfo)
{
	if (tableIsEmpty(table)) {
		return NULL;
	}
	if (isHomogeneous(table)) {
		nodePtr->isLeaf = true;
		nodePtr->label = table[1][table[1].size()-1];
		return nodePtr;
	} else {
		string splittingCol = decideSplittingColumn(table);
		nodePtr->splitOn = splittingCol;
		int colIndex = returnColumnIndex(splittingCol, tableInfo);
		int iii;
		for (iii = 1; iii < tableInfo[colIndex].size(); iii++) {
			node* newNode = (node*) new node;
			newNode->label = tableInfo[colIndex][iii];
			nodePtr->childrenValues.push_back(tableInfo[colIndex][iii]);
			newNode->isLeaf = false;
			newNode->splitOn = splittingCol;
			vvs auxTable = pruneTable(table, splittingCol, tableInfo[colIndex][iii]);
			nodePtr->children.push_back(buildDecisionTree(auxTable, newNode, tableInfo));
		}
	}
	return nodePtr;
}
Ejemplo n.º 5
0
void RemoteFontFaceSource::fontLoaded(FontResource*)
{
    m_histograms.recordRemoteFont(m_font.get());

    pruneTable();
    if (m_face)
        m_face->fontLoaded(this);
}
CSSSegmentedFontFace::~CSSSegmentedFontFace()
{
    pruneTable();
#if !ENABLE(OILPAN)
    for (const auto& fontFace : m_fontFaces)
        fontFace->cssFontFace()->clearSegmentedFontFace();
#endif
}
Ejemplo n.º 7
0
void RemoteFontFaceSource::fontLoadWaitLimitExceeded(FontResource*)
{
    pruneTable();
    if (m_face)
        m_face->fontLoadWaitLimitExceeded(this);

    m_histograms.recordFallbackTime(m_font.get());
}
Ejemplo n.º 8
0
CSSSegmentedFontFace::~CSSSegmentedFontFace()
{
    pruneTable();
#if !ENABLE(OILPAN)
    for (FontFaceList::iterator it = m_fontFaces.begin(); it != m_fontFaces.end(); ++it)
        (*it)->cssFontFace()->clearSegmentedFontFace();
#endif
}
Ejemplo n.º 9
0
void CSSFontFaceSource::fontLoaded(FontResource*)
{
    if (!m_fontDataTable.isEmpty())
        m_histograms.recordRemoteFont(m_font.get());

    pruneTable();
    if (m_face)
        m_face->fontLoaded(this);
}
Ejemplo n.º 10
0
void CSSSegmentedFontFace::removeFontFace(PassRefPtr<CSSFontFace> fontFace)
{
    size_t index = m_fontFaces.find(fontFace);
    if (index != kNotFound) {
        pruneTable();
        m_fontFaces.remove(index);
        fontFace->clearSegmentedFontFace();
    }
}
Ejemplo n.º 11
0
void RemoteFontFaceSource::switchToSwapPeriod() {
  ASSERT(m_period == BlockPeriod);
  m_period = SwapPeriod;

  pruneTable();
  if (m_face) {
    m_fontSelector->fontFaceInvalidated();
    m_face->didBecomeVisibleFallback(this);
  }

  m_histograms.recordFallbackTime(m_font.get());
}
Ejemplo n.º 12
0
void RemoteFontFaceSource::fontLoaded(FontResource*)
{
    m_histograms.recordRemoteFont(m_font.get());

    m_font->ensureCustomFontData();
    if (m_font->status() == Resource::DecodeError)
        m_fontLoader->didFailToDecode(m_font.get());

    pruneTable();
    if (m_face) {
        m_fontLoader->fontFaceInvalidated();
        m_face->fontLoaded(this);
    }
}
void CSSSegmentedFontFace::addFontFace(RawPtr<FontFace> prpFontFace, bool cssConnected)
{
    RawPtr<FontFace> fontFace = prpFontFace;
    pruneTable();
    fontFace->cssFontFace()->setSegmentedFontFace(this);
    if (cssConnected) {
        m_fontFaces.insertBefore(m_firstNonCssConnectedFace, fontFace);
    } else {
        // This is the only place in Blink that is using addReturnIterator.
        FontFaceList::iterator iterator = m_fontFaces.addReturnIterator(fontFace);
        if (m_firstNonCssConnectedFace == m_fontFaces.end())
            m_firstNonCssConnectedFace = iterator;
    }
}
void CSSSegmentedFontFace::removeFontFace(RawPtr<FontFace> prpFontFace)
{
    RawPtr<FontFace> fontFace = prpFontFace;
    FontFaceList::iterator it = m_fontFaces.find(fontFace);
    if (it == m_fontFaces.end())
        return;

    if (it == m_firstNonCssConnectedFace)
        ++m_firstNonCssConnectedFace;
    m_fontFaces.remove(it);

    pruneTable();
    fontFace->cssFontFace()->clearSegmentedFontFace();
}
Ejemplo n.º 15
0
void CSSSegmentedFontFace::fontLoaded(CSSFontFace*)
{
    pruneTable();

    if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && !isLoading()) {
        Vector<RefPtr<LoadFontCallback> > callbacks;
        m_callbacks.swap(callbacks);
        for (size_t index = 0; index < callbacks.size(); ++index) {
            if (isLoaded())
                callbacks[index]->notifyLoaded(this);
            else
                callbacks[index]->notifyError(this);
        }
    }
}
Ejemplo n.º 16
0
/*
* Decides which column to split on
* based on entropy. Returns the column
* with the least entropy.
*/
string decideSplittingColumn(vvs &table)
{
	int column, iii;
	double minEntropy = DBL_MAX;
	int splittingColumn = 0;
	vi entropies;
#pragma omp parallel
	{
#pragma omp for
		for (column = 0; column < table[0].size() - 1; column++) {
			string colName = table[0][column];
			msi tempMap;
			vi counts = countDistinct(table, column);
			vd attributeEntropy;
			double columnEntropy = 0.0;

			for (iii = 1; iii < table.size() - 1; iii++) {
				double entropy = 0.0;
				if (tempMap.find(table[iii][column]) != tempMap.end()) { 	// IF ATTRIBUTE IS ALREADY FOUND IN A COLUMN, UPDATE IT'S FREQUENCY
					tempMap[table[iii][column]]++;
				}
				else { 							// IF ATTRIBUTE IS FOUND FOR THE FIRST TIME IN A COLUMN, THEN PROCESS IT AND CALCULATE IT'S ENTROPY
					tempMap[table[iii][column]] = 1;
					vvs tempTable = pruneTable(table, colName, table[iii][column]);
					vi classCounts = countDistinct(tempTable, tempTable[0].size() - 1);
					int jjj, kkk;
					for (jjj = 0; jjj < classCounts.size(); jjj++) {
						double temp = (double)classCounts[jjj];
						entropy -= (temp / classCounts[classCounts.size() - 1])*(log(temp / classCounts[classCounts.size() - 1]) / log(2));
					}
					attributeEntropy.push_back(entropy);
					entropy = 0.0;
				}
			}
			//for (iii = 0; iii < counts.size() - 1 && ((attributeEntropy.size() - 1) == (counts.size() - 1)); iii++) {
			for (iii = 0; iii < counts.size() - 1; iii++) {
				columnEntropy += ((double)counts[iii] * (double)attributeEntropy[iii]);
			}
			columnEntropy = columnEntropy / ((double)counts[counts.size() - 1]);
			if (columnEntropy <= minEntropy) {
				minEntropy = columnEntropy;
				splittingColumn = column;
			}
		}
	}
	return table[0][splittingColumn];
}
Ejemplo n.º 17
0
void CSSSegmentedFontFace::fontLoaded(CSSFontFace*)
{
    pruneTable();

#if ENABLE(FONT_LOAD_EVENTS)
    if (RuntimeEnabledFeatures::sharedFeatures().fontLoadEventsEnabled() && !isLoading()) {
        Vector<RefPtr<LoadFontCallback>> callbacks;
        m_callbacks.swap(callbacks);
        for (size_t index = 0; index < callbacks.size(); ++index) {
            if (checkFont())
                callbacks[index]->notifyLoaded();
            else
                callbacks[index]->notifyError();
        }
    }
#endif
}
Ejemplo n.º 18
0
void RemoteFontFaceSource::corsFailed(FontResource*)
{
    if (m_face) {
        m_histograms.corsFailed();
        Document* document = m_face->fontSelector() ? m_face->fontSelector()->document() : 0;
        if (document) {
            FetchRequest request(ResourceRequest(m_font->url()), FetchInitiatorTypeNames::css);
            ResourcePtr<FontResource> newFontResource = document->fetcher()->fetchFont(request);
            if (newFontResource) {
                m_font->removeClient(this);
                m_font = newFontResource;
                m_font->addClient(this);
                m_face->fontSelector()->beginLoadingFontSoon(m_font.get());
                return;
            } else {
                pruneTable();
            }
        }
        m_face->fontLoaded(this);
    }
}
void CSSSegmentedFontFace::appendFontFace(PassRefPtr<CSSFontFace> fontFace)
{
    pruneTable();
    fontFace->addedToSegmentedFontFace(this);
    m_fontFaces.append(fontFace);
}
void CSSSegmentedFontFace::fontLoaded(CSSFontFace*)
{
    pruneTable();
}
Ejemplo n.º 21
0
CSSSegmentedFontFace::~CSSSegmentedFontFace()
{
    pruneTable();
    for (FontFaceList::iterator it = m_fontFaces.begin(); it != m_fontFaces.end(); ++it)
        (*it)->cssFontFace()->clearSegmentedFontFace();
}
Ejemplo n.º 22
0
void CSSFontFaceSource::fontLoaded(CachedFont*)
{
    pruneTable();
    if (m_face)
        m_face->fontLoaded(this);
}
Ejemplo n.º 23
0
CSSFontFaceSource::~CSSFontFaceSource()
{
    if (m_font)
        m_font->removeClient(this);
    pruneTable();
}
Ejemplo n.º 24
0
void CSSSegmentedFontFace::fontLoadWaitLimitExceeded(CSSFontFace*)
{
    pruneTable();
}
Ejemplo n.º 25
0
void RemoteFontFaceSource::dispose() {
  m_font->removeClient(this);
  m_font = nullptr;
  pruneTable();
}
void CSSSegmentedFontFace::fontFaceInvalidated()
{
    pruneTable();
}
Ejemplo n.º 27
0
RemoteFontFaceSource::~RemoteFontFaceSource()
{
    m_font->removeClient(this);
    pruneTable();
}