CompactHTMLToken::CompactHTMLToken(const HTMLToken* token, const TextPosition& textPosition) : m_type(token->type()) , m_isAll8BitData(false) , m_textPosition(textPosition) { switch (m_type) { case HTMLToken::Uninitialized: ASSERT_NOT_REACHED(); break; case HTMLToken::EndOfFile: break; case HTMLToken::StartTag: m_attributes.reserveInitialCapacity(token->attributes().size()); for (Vector<HTMLToken::Attribute>::const_iterator it = token->attributes().begin(); it != token->attributes().end(); ++it) m_attributes.append(Attribute(attemptStaticStringCreation(it->name, Likely8Bit), StringImpl::create8BitIfPossible(it->value))); // Fall through! case HTMLToken::EndTag: m_selfClosing = token->selfClosing(); // Fall through! case HTMLToken::Character: { m_isAll8BitData = token->isAll8BitData(); m_data = attemptStaticStringCreation(token->data(), token->isAll8BitData() ? Force8Bit : Force16Bit); break; } default: ASSERT_NOT_REACHED(); break; } }
CompactHTMLToken::CompactHTMLToken(const HTMLToken* token, const TextPosition& textPosition) : m_type(token->type()) , m_isAll8BitData(false) , m_doctypeForcesQuirks(false) , m_textPosition(textPosition) { switch (m_type) { case HTMLToken::Uninitialized: ASSERT_NOT_REACHED(); break; case HTMLToken::DOCTYPE: { m_data = attemptStaticStringCreation(token->name(), Likely8Bit); // There is only 1 DOCTYPE token per document, so to avoid increasing the // size of CompactHTMLToken, we just use the m_attributes vector. m_attributes.append(Attribute(attemptStaticStringCreation(token->publicIdentifier(), Likely8Bit), String(token->systemIdentifier()))); m_doctypeForcesQuirks = token->forceQuirks(); break; } case HTMLToken::EndOfFile: break; case HTMLToken::StartTag: m_attributes.reserveInitialCapacity(token->attributes().size()); for (const HTMLToken::Attribute& attribute : token->attributes()) m_attributes.append(Attribute(attemptStaticStringCreation(attribute.name, Likely8Bit), StringImpl::create8BitIfPossible(attribute.value))); // Fall through! case HTMLToken::EndTag: m_selfClosing = token->selfClosing(); // Fall through! case HTMLToken::Comment: case HTMLToken::Character: { m_isAll8BitData = token->isAll8BitData(); m_data = attemptStaticStringCreation(token->data(), token->isAll8BitData() ? Force8Bit : Force16Bit); break; } default: ASSERT_NOT_REACHED(); break; } }
MediaQuery::MediaQuery(Restrictor r, const String& mediaType, PassOwnPtrWillBeRawPtr<ExpressionHeapVector> expressions) : m_restrictor(r) , m_mediaType(attemptStaticStringCreation(mediaType.lower())) , m_expressions(expressions) { if (!m_expressions) { m_expressions = adoptPtrWillBeNoop(new ExpressionHeapVector); return; } nonCopyingSort(m_expressions->begin(), m_expressions->end(), expressionCompare); // Remove all duplicated expressions. MediaQueryExp* key = 0; for (int i = m_expressions->size() - 1; i >= 0; --i) { MediaQueryExp* exp = m_expressions->at(i).get(); if (key && *exp == *key) m_expressions->remove(i); else key = exp; } }