This source file includes following definitions.
- m_textPosition
- getAttributeItem
- isSafeToSendToAnotherThread
#include "config.h"
#include "core/html/parser/CompactHTMLToken.h"
#include "core/dom/QualifiedName.h"
#include "core/html/parser/HTMLParserIdioms.h"
namespace WebCore {
struct SameSizeAsCompactHTMLToken {
unsigned bitfields;
String data;
Vector<Attribute> vector;
TextPosition textPosition;
};
COMPILE_ASSERT(sizeof(CompactHTMLToken) == sizeof(SameSizeAsCompactHTMLToken), CompactHTMLToken_should_stay_small);
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);
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 (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)));
case HTMLToken::EndTag:
m_selfClosing = token->selfClosing();
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;
}
}
const CompactHTMLToken::Attribute* CompactHTMLToken::getAttributeItem(const QualifiedName& name) const
{
for (unsigned i = 0; i < m_attributes.size(); ++i) {
if (threadSafeMatch(m_attributes.at(i).name, name))
return &m_attributes.at(i);
}
return 0;
}
bool CompactHTMLToken::isSafeToSendToAnotherThread() const
{
for (Vector<Attribute>::const_iterator it = m_attributes.begin(); it != m_attributes.end(); ++it) {
if (!it->name.isSafeToSendToAnotherThread())
return false;
if (!it->value.isSafeToSendToAnotherThread())
return false;
}
return m_data.isSafeToSendToAnotherThread();
}
}