| Index: third_party/WebKit/Source/core/css/CSSSelector.cpp
|
| diff --git a/third_party/WebKit/Source/core/css/CSSSelector.cpp b/third_party/WebKit/Source/core/css/CSSSelector.cpp
|
| index 2910c45972c2fd945cbc0bc497337606b813006f..7f11b53521354ced81f1b41922d4b7be3c1c6bfc 100644
|
| --- a/third_party/WebKit/Source/core/css/CSSSelector.cpp
|
| +++ b/third_party/WebKit/Source/core/css/CSSSelector.cpp
|
| @@ -28,6 +28,8 @@
|
| #include "core/HTMLNames.h"
|
| #include "core/css/CSSMarkup.h"
|
| #include "core/css/CSSSelectorList.h"
|
| +#include "core/css/serializer/CSSDeserializeStream.h"
|
| +#include "core/css/serializer/CSSSerializeStream.h"
|
| #include "platform/RuntimeEnabledFeatures.h"
|
| #include "wtf/Assertions.h"
|
| #include "wtf/HashMap.h"
|
| @@ -50,6 +52,23 @@ struct SameSizeAsCSSSelector {
|
|
|
| static_assert(sizeof(CSSSelector) == sizeof(SameSizeAsCSSSelector), "CSSSelector should stay small");
|
|
|
| +CSSSelector::CSSSelector(CSSDeserializeStream* stream)
|
| +{
|
| + CSDEBUG("CSSSelector::ctor deserialize\n");
|
| + m_bitfields = stream->readUnsigned();
|
| + if (m_hasRareData) {
|
| + m_data.m_rareData = RareData::deserialize(stream).leakRef();
|
| + } else if (m_match == Tag) {
|
| + QualifiedName tagQName = stream->readQualifiedName();
|
| + m_data.m_tagQName = tagQName.impl();
|
| + m_data.m_tagQName->ref();
|
| + } else {
|
| + AtomicString value = stream->readAtomicString();
|
| + m_data.m_value = value.impl();
|
| + m_data.m_value->ref();
|
| + }
|
| +}
|
| +
|
| void CSSSelector::createRareData()
|
| {
|
| ASSERT(m_match != Tag);
|
| @@ -881,6 +900,19 @@ bool CSSSelector::matchNth(int count) const
|
| return m_data.m_rareData->matchNth(count);
|
| }
|
|
|
| +void CSSSelector::serialize(CSSSerializeStream* stream) const
|
| +{
|
| + CSDEBUG("CSSSelector::serialize "); CSSHOW(selectorText());
|
| + stream->writeUnsigned(m_bitfields);
|
| + if (m_hasRareData) {
|
| + m_data.m_rareData->serialize(stream);
|
| + } else if (m_match == Tag) {
|
| + stream->writeQualifiedName(tagQName());
|
| + } else {
|
| + stream->writeAtomicString(value());
|
| + }
|
| +}
|
| +
|
| CSSSelector::RareData::RareData(const AtomicString& value)
|
| : m_matchingValue(value)
|
| , m_serializingValue(value)
|
| @@ -894,6 +926,25 @@ CSSSelector::RareData::~RareData()
|
| {
|
| }
|
|
|
| +PassRefPtr<CSSSelector::RareData> CSSSelector::RareData::deserialize(CSSDeserializeStream* stream)
|
| +{
|
| + AtomicString matchingValue = stream->readAtomicString();
|
| + RefPtr<RareData> rareData = create(matchingValue);
|
| + rareData->m_serializingValue = stream->readAtomicString();;
|
| +
|
| + rareData->m_bits.m_nth.m_a = stream->readInt();
|
| + rareData->m_bits.m_nth.m_b = stream->readInt();
|
| + rareData->m_attribute = stream->readQualifiedName();
|
| + rareData->m_argument = stream->readAtomicString();
|
| + bool hasSelectorList = stream->readBool();
|
| + if (hasSelectorList) {
|
| + rareData->m_selectorList = adoptPtr(new CSSSelectorList());
|
| + *rareData->m_selectorList = CSSSelectorList::deserialize(stream);
|
| + }
|
| +
|
| + return rareData.release();
|
| +}
|
| +
|
| // a helper function for checking nth-arguments
|
| bool CSSSelector::RareData::matchNth(int count)
|
| {
|
| @@ -909,4 +960,20 @@ bool CSSSelector::RareData::matchNth(int count)
|
| return (nthBValue() - count) % (-nthAValue()) == 0;
|
| }
|
|
|
| +void CSSSelector::RareData::serialize(CSSSerializeStream* stream)
|
| +{
|
| + stream->writeAtomicString(m_matchingValue);
|
| + stream->writeAtomicString(m_serializingValue);
|
| + stream->writeInt(m_bits.m_nth.m_a);
|
| + stream->writeInt(m_bits.m_nth.m_b);
|
| + stream->writeQualifiedName(m_attribute);
|
| + stream->writeAtomicString(m_argument);
|
| + if (m_selectorList) {
|
| + stream->writeBool(true);
|
| + m_selectorList->serialize(stream);
|
| + } else {
|
| + stream->writeBool(false);
|
| + }
|
| +}
|
| +
|
| } // namespace blink
|
|
|