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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSCounterValue.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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/CSSCounterValue.h" 5 #include "core/css/CSSCounterValue.h"
6 6
7 #include "core/css/CSSMarkup.h" 7 #include "core/css/CSSMarkup.h"
8 #include "core/css/serializer/CSSDeserializeStream.h"
9 #include "core/css/serializer/CSSSerializeStream.h"
8 #include "wtf/text/StringBuilder.h" 10 #include "wtf/text/StringBuilder.h"
9 11
10 namespace blink { 12 namespace blink {
11 13
14 PassRefPtrWillBeRawPtr<CSSCounterValue> CSSCounterValue::deserializeAfterDispatc h(CSSDeserializeStream* stream)
15 {
16 RefPtrWillBeRawPtr<CSSValue> identifier = stream->readNullableRef<CSSValue>( );
17 RefPtrWillBeRawPtr<CSSValue> listStyle = stream->readNullableRef<CSSValue>() ;
18 RefPtrWillBeRawPtr<CSSValue> separator = stream->readNullableRef<CSSValue>() ;
19
20 return create(
21 toCSSCustomIdentValue(identifier.get()),
22 toCSSPrimitiveValue(listStyle.get()),
23 toCSSCustomIdentValue(separator.get()));
24 }
25
12 String CSSCounterValue::customCSSText() const 26 String CSSCounterValue::customCSSText() const
13 { 27 {
14 StringBuilder result; 28 StringBuilder result;
15 if (separator().isEmpty()) 29 if (separator().isEmpty())
16 result.appendLiteral("counter("); 30 result.appendLiteral("counter(");
17 else 31 else
18 result.appendLiteral("counters("); 32 result.appendLiteral("counters(");
19 33
20 result.append(identifier()); 34 result.append(identifier());
21 if (!separator().isEmpty()) { 35 if (!separator().isEmpty()) {
22 result.appendLiteral(", "); 36 result.appendLiteral(", ");
23 result.append(serializeString(separator())); 37 result.append(serializeString(separator()));
24 } 38 }
25 bool isDefaultListStyle = listStyle() == CSSValueDecimal; 39 bool isDefaultListStyle = listStyle() == CSSValueDecimal;
26 if (!isDefaultListStyle) { 40 if (!isDefaultListStyle) {
27 result.appendLiteral(", "); 41 result.appendLiteral(", ");
28 result.append(m_listStyle->cssText()); 42 result.append(m_listStyle->cssText());
29 } 43 }
30 result.append(')'); 44 result.append(')');
31 45
32 return result.toString(); 46 return result.toString();
33 } 47 }
34 48
49 void CSSCounterValue::serializeAfterDispatch(CSSSerializeStream* stream) const
50 {
51 stream->serializeNullable(m_identifier);
52 stream->serializeNullable(m_listStyle);
53 stream->serializeNullable(m_separator);
54 }
55
35 DEFINE_TRACE_AFTER_DISPATCH(CSSCounterValue) 56 DEFINE_TRACE_AFTER_DISPATCH(CSSCounterValue)
36 { 57 {
37 visitor->trace(m_identifier); 58 visitor->trace(m_identifier);
38 visitor->trace(m_listStyle); 59 visitor->trace(m_listStyle);
39 visitor->trace(m_separator); 60 visitor->trace(m_separator);
40 CSSValue::traceAfterDispatch(visitor); 61 CSSValue::traceAfterDispatch(visitor);
41 } 62 }
42 63
43 } 64 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSCounterValue.h ('k') | third_party/WebKit/Source/core/css/CSSCustomIdentValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698