Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: third_party/WebKit/Source/core/css/CSSKeyframesRule.cpp

Issue 1481383002: [Experimental] CSSSerializer Proof-of-concept Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: snapshot: top_25 sites ser/dser now works Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 11 matching lines...) Expand all
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "core/css/CSSKeyframesRule.h" 26 #include "core/css/CSSKeyframesRule.h"
27 27
28 #include "core/css/CSSKeyframeRule.h" 28 #include "core/css/CSSKeyframeRule.h"
29 #include "core/css/CSSRuleList.h" 29 #include "core/css/CSSRuleList.h"
30 #include "core/css/CSSStyleSheet.h" 30 #include "core/css/CSSStyleSheet.h"
31 #include "core/css/parser/CSSParser.h" 31 #include "core/css/parser/CSSParser.h"
32 #include "core/css/serializer/CSSDeserializeStream.h"
33 #include "core/css/serializer/CSSSerializeStream.h"
32 #include "core/frame/UseCounter.h" 34 #include "core/frame/UseCounter.h"
33 #include "wtf/text/StringBuilder.h" 35 #include "wtf/text/StringBuilder.h"
34 36
35 namespace blink { 37 namespace blink {
36 38
37 StyleRuleKeyframes::StyleRuleKeyframes() 39 StyleRuleKeyframes::StyleRuleKeyframes()
38 : StyleRuleBase(Keyframes) 40 : StyleRuleBase(Keyframes)
39 , m_version(0) 41 , m_version(0)
40 { 42 {
41 } 43 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 OwnPtr<Vector<double>> keys = CSSParser::parseKeyframeKeyList(key); 79 OwnPtr<Vector<double>> keys = CSSParser::parseKeyframeKeyList(key);
78 if (!keys) 80 if (!keys)
79 return -1; 81 return -1;
80 for (size_t i = m_keyframes.size(); i--; ) { 82 for (size_t i = m_keyframes.size(); i--; ) {
81 if (m_keyframes[i]->keys() == *keys) 83 if (m_keyframes[i]->keys() == *keys)
82 return i; 84 return i;
83 } 85 }
84 return -1; 86 return -1;
85 } 87 }
86 88
89 void StyleRuleKeyframes::serializeAfterDispatch(CSSSerializeStream* stream) cons t
90 {
91 stream->writeUnsigned(m_keyframes.size());
92 for (const RefPtrWillBeMember<StyleRuleKeyframe>& keyframe : m_keyframes)
93 keyframe->serialize(stream);
94
95 stream->writeAtomicString(m_name);
96 stream->writeUnsigned(m_version);
97 stream->writeBool(m_isPrefixed);
98 }
99
100 PassRefPtrWillBeRawPtr<StyleRuleKeyframes> StyleRuleKeyframes::deserializeAfterD ispatch(CSSDeserializeStream* stream)
101 {
102 RefPtrWillBeRawPtr<StyleRuleKeyframes> rule = adoptRefWillBeNoop(new StyleRu leKeyframes());
103
104 unsigned size = stream->readUnsigned();
105 rule->m_keyframes.reserveCapacity(size);
106 for (unsigned i = 0; i < size; ++ i) {
107 RefPtrWillBeRawPtr<StyleRuleBase> keyframeRule = StyleRuleBase::deserial ize(stream);
108 rule->m_keyframes.append(toStyleRuleKeyframe(keyframeRule.get()));
109 }
110
111 rule->m_name = stream->readAtomicString();
112 rule->m_version = stream->readUnsigned();
113 rule->m_isPrefixed = stream->readBool();
114
115 return rule.release();
116 }
117
87 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleKeyframes) 118 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleKeyframes)
88 { 119 {
89 visitor->trace(m_keyframes); 120 visitor->trace(m_keyframes);
90 StyleRuleBase::traceAfterDispatch(visitor); 121 StyleRuleBase::traceAfterDispatch(visitor);
91 } 122 }
92 123
93 CSSKeyframesRule::CSSKeyframesRule(StyleRuleKeyframes* keyframesRule, CSSStyleSh eet* parent) 124 CSSKeyframesRule::CSSKeyframesRule(StyleRuleKeyframes* keyframesRule, CSSStyleSh eet* parent)
94 : CSSRule(parent) 125 : CSSRule(parent)
95 , m_keyframesRule(keyframesRule) 126 , m_keyframesRule(keyframesRule)
96 , m_childRuleCSSOMWrappers(keyframesRule->keyframes().size()) 127 , m_childRuleCSSOMWrappers(keyframesRule->keyframes().size())
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 { 249 {
219 CSSRule::trace(visitor); 250 CSSRule::trace(visitor);
220 #if ENABLE(OILPAN) 251 #if ENABLE(OILPAN)
221 visitor->trace(m_childRuleCSSOMWrappers); 252 visitor->trace(m_childRuleCSSOMWrappers);
222 #endif 253 #endif
223 visitor->trace(m_keyframesRule); 254 visitor->trace(m_keyframesRule);
224 visitor->trace(m_ruleListCSSOMWrapper); 255 visitor->trace(m_ruleListCSSOMWrapper);
225 } 256 }
226 257
227 } // namespace blink 258 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSKeyframesRule.h ('k') | third_party/WebKit/Source/core/css/CSSPrimitiveValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698