| Index: third_party/WebKit/Source/core/css/StyleRule.cpp
|
| diff --git a/third_party/WebKit/Source/core/css/StyleRule.cpp b/third_party/WebKit/Source/core/css/StyleRule.cpp
|
| index 7ff3eff764fff8a1e13dffdda1ebad8bc0446605..965a628fde0501649cc2274ed264e444d8d7c828 100644
|
| --- a/third_party/WebKit/Source/core/css/StyleRule.cpp
|
| +++ b/third_party/WebKit/Source/core/css/StyleRule.cpp
|
| @@ -33,6 +33,8 @@
|
| #include "core/css/StyleRuleImport.h"
|
| #include "core/css/StyleRuleKeyframe.h"
|
| #include "core/css/StyleRuleNamespace.h"
|
| +#include "core/css/serializer/CSSDeserializeStream.h"
|
| +#include "core/css/serializer/CSSSerializeStream.h"
|
|
|
| namespace blink {
|
|
|
| @@ -52,6 +54,79 @@ PassRefPtrWillBeRawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* paren
|
| return createCSSOMWrapper(0, parentRule);
|
| }
|
|
|
| +PassRefPtrWillBeRawPtr<StyleRuleBase> StyleRuleBase::deserialize(CSSDeserializeStream* stream)
|
| +{
|
| + Type type = static_cast<Type>(stream->readUnsigned());
|
| +
|
| + switch (type) {
|
| + case Style:
|
| + return StyleRule::deserializeAfterDispatch(stream);
|
| + case Media:
|
| + return StyleRuleMedia::deserializeAfterDispatch(stream);
|
| + case Keyframes:
|
| + return StyleRuleKeyframes::deserializeAfterDispatch(stream);
|
| + case Keyframe:
|
| + return StyleRuleKeyframe::deserializeAfterDispatch(stream);
|
| + case FontFace:
|
| + return StyleRuleFontFace::deserializeAfterDispatch(stream);
|
| +
|
| + default:
|
| + ASSERT_NOT_REACHED();
|
| + return nullptr;
|
| + }
|
| +}
|
| +
|
| +void StyleRuleBase::serialize(CSSSerializeStream* stream) const
|
| +{
|
| + stream->writeUnsigned(type());
|
| + switch (type()) {
|
| + /*
|
| + case Charset:
|
| + toStyleRuleCharset(this)->serializeAfterDispatch(stream);
|
| + return;
|
| + */
|
| + case Style:
|
| + toStyleRule(this)->serializeAfterDispatch(stream);
|
| + return;
|
| + /*
|
| + case Page:
|
| + toStyleRulePage(this)->serializeAfterDispatch(stream);
|
| + return;
|
| + */
|
| + case FontFace:
|
| + toStyleRuleFontFace(this)->serializeAfterDispatch(stream);
|
| + return;
|
| + case Media:
|
| + toStyleRuleMedia(this)->serializeAfterDispatch(stream);
|
| + return;
|
| + /*
|
| + case Supports:
|
| + toStyleRuleSupports(this)->serializeAfterDispatch(stream);
|
| + return;
|
| + case Import:
|
| + toStyleRuleImport(this)->serializeAfterDispatch(stream);
|
| + return;
|
| + */
|
| + case Keyframes:
|
| + toStyleRuleKeyframes(this)->serializeAfterDispatch(stream);
|
| + return;
|
| + case Keyframe:
|
| + toStyleRuleKeyframe(this)->serializeAfterDispatch(stream);
|
| + return;
|
| + /*
|
| + case Namespace:
|
| + toStyleRuleNamespace(this)->serializeAfterDispatch(stream);
|
| + return;
|
| + case Viewport:
|
| + toStyleRuleViewport(this)->serializeAfterDispatch(stream);
|
| + return;
|
| + */
|
| + default:
|
| + break;
|
| + }
|
| + ASSERT_NOT_REACHED();
|
| +}
|
| +
|
| DEFINE_TRACE(StyleRuleBase)
|
| {
|
| switch (type()) {
|
| @@ -275,6 +350,20 @@ MutableStylePropertySet& StyleRule::mutableProperties()
|
| return *toMutableStylePropertySet(m_properties.get());
|
| }
|
|
|
| +PassRefPtrWillBeRawPtr<StyleRule> StyleRule::deserializeAfterDispatch(CSSDeserializeStream* stream)
|
| +{
|
| + RefPtrWillBeMember<StylePropertySet> properties = ImmutableStylePropertySet::deserialize(stream);
|
| + CSSSelectorList selectorList = CSSSelectorList::deserialize(stream);
|
| + return StyleRule::create(std::move(selectorList), properties);
|
| +}
|
| +
|
| +void StyleRule::serializeAfterDispatch(CSSSerializeStream* stream) const
|
| +{
|
| + CSDEBUG("StyleRule::serializeAfterDispatch()\n");
|
| + m_properties->serialize(stream);
|
| + m_selectorList.serialize(stream);
|
| +}
|
| +
|
| DEFINE_TRACE_AFTER_DISPATCH(StyleRule)
|
| {
|
| visitor->trace(m_properties);
|
| @@ -335,6 +424,19 @@ MutableStylePropertySet& StyleRuleFontFace::mutableProperties()
|
| return *toMutableStylePropertySet(m_properties);
|
| }
|
|
|
| +void StyleRuleFontFace::serializeAfterDispatch(CSSSerializeStream* stream) const
|
| +{
|
| + CSDEBUG("StyleRuleFontFace::serializeAfterDispatch()\n");
|
| + m_properties->serialize(stream);
|
| +}
|
| +
|
| +PassRefPtrWillBeRawPtr<StyleRuleFontFace> StyleRuleFontFace::deserializeAfterDispatch(CSSDeserializeStream* stream)
|
| +{
|
| + CSDEBUG("StyleRuleFontFace::deserializeAfterDispatch()\n");
|
| + RefPtrWillBeRawPtr<StylePropertySet> properties = ImmutableStylePropertySet::deserialize(stream);
|
| + return create(properties.release());
|
| +}
|
| +
|
| DEFINE_TRACE_AFTER_DISPATCH(StyleRuleFontFace)
|
| {
|
| visitor->trace(m_properties);
|
| @@ -355,6 +457,24 @@ StyleRuleGroup::StyleRuleGroup(const StyleRuleGroup& o)
|
| m_childRules[i] = o.m_childRules[i]->copy();
|
| }
|
|
|
| +void StyleRuleGroup::serializeAfterDispatch(CSSSerializeStream* stream) const
|
| +{
|
| + CSDEBUG("StyleRuleGroup::serializeAfterDispatch()\n");
|
| + stream->writeUnsigned(m_childRules.size());
|
| + for (const RefPtrWillBeMember<StyleRuleBase>& childRule : m_childRules)
|
| + childRule->serialize(stream);
|
| +}
|
| +
|
| +void StyleRuleGroup::deserializeAfterDispatch(CSSDeserializeStream* stream)
|
| +{
|
| + CSDEBUG("StyleRuleGroup::deserializeAfterDispatch()\n");
|
| + ASSERT(m_childRules.isEmpty());
|
| + unsigned size = stream->readUnsigned();
|
| + m_childRules.reserveCapacity(size);
|
| + for (unsigned i = 0; i < size; ++ i)
|
| + m_childRules.append(StyleRule::deserialize(stream));
|
| +}
|
| +
|
| void StyleRuleGroup::wrapperInsertRule(unsigned index, PassRefPtrWillBeRawPtr<StyleRuleBase> rule)
|
| {
|
| m_childRules.insert(index, rule);
|
| @@ -384,6 +504,21 @@ StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& o)
|
| m_mediaQueries = o.m_mediaQueries->copy();
|
| }
|
|
|
| +void StyleRuleMedia::serializeAfterDispatch(CSSSerializeStream* stream) const
|
| +{
|
| + CSDEBUG("StyleRuleMedia::serializeAfterDispatch()\n");
|
| + StyleRuleGroup::serializeAfterDispatch(stream);
|
| + m_mediaQueries->serialize(stream);
|
| +}
|
| +
|
| +PassRefPtrWillBeRawPtr<StyleRuleMedia> StyleRuleMedia::deserializeAfterDispatch(CSSDeserializeStream* stream)
|
| +{
|
| + RefPtrWillBeRawPtr<StyleRuleMedia> rule = adoptRefWillBeNoop(new StyleRuleMedia());
|
| + rule->StyleRuleGroup::deserializeAfterDispatch(stream);
|
| + rule->m_mediaQueries = MediaQuerySet::deserialize(stream);
|
| + return rule.release();
|
| +}
|
| +
|
| DEFINE_TRACE_AFTER_DISPATCH(StyleRuleMedia)
|
| {
|
| visitor->trace(m_mediaQueries);
|
|
|