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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSCustomIdentValue.h

Issue 1373433002: Split out CSSPrimitiveValue's PropertyID into CSSCustomIdentValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split_string
Patch Set: Rebase Created 5 years, 2 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 #ifndef CSSCustomIdentValue_h 5 #ifndef CSSCustomIdentValue_h
6 #define CSSCustomIdentValue_h 6 #define CSSCustomIdentValue_h
7 7
8 #include "core/CSSPropertyNames.h"
8 #include "core/css/CSSValue.h" 9 #include "core/css/CSSValue.h"
9 #include "wtf/PassRefPtr.h" 10 #include "wtf/PassRefPtr.h"
10 #include "wtf/RefCounted.h" 11 #include "wtf/RefCounted.h"
11 12
12 namespace blink { 13 namespace blink {
13 14
14 class CSSCustomIdentValue : public CSSValue { 15 class CSSCustomIdentValue : public CSSValue {
15 public: 16 public:
16 static PassRefPtrWillBeRawPtr<CSSCustomIdentValue> create(const String& str) 17 static PassRefPtrWillBeRawPtr<CSSCustomIdentValue> create(const String& str)
17 { 18 {
18 return adoptRefWillBeNoop(new CSSCustomIdentValue(str)); 19 return adoptRefWillBeNoop(new CSSCustomIdentValue(str));
19 } 20 }
20 21
21 String value() const { return m_string; } 22 // TODO(sashab, timloh): Remove this and lazily parse the CSSPropertyID in i sKnownPropertyID().
23 static PassRefPtrWillBeRawPtr<CSSCustomIdentValue> create(CSSPropertyID id)
24 {
25 return adoptRefWillBeNoop(new CSSCustomIdentValue(id));
26 }
27
28 String value() const { ASSERT(!isKnownPropertyID()); return m_string; }
29 bool isKnownPropertyID() const { return m_propertyId != CSSPropertyInvalid; }
30 CSSPropertyID valueAsPropertyID() const { ASSERT(isKnownPropertyID()); retur n m_propertyId; }
22 31
23 String customCSSText() const; 32 String customCSSText() const;
24 33
25 bool equals(const CSSCustomIdentValue& other) const 34 bool equals(const CSSCustomIdentValue& other) const
26 { 35 {
27 return m_string == other.m_string; 36 return isKnownPropertyID() ? m_propertyId == other.m_propertyId : m_stri ng == other.m_string;
28 } 37 }
29 38
30 DECLARE_TRACE_AFTER_DISPATCH(); 39 DECLARE_TRACE_AFTER_DISPATCH();
31 40
32 private: 41 private:
33 CSSCustomIdentValue(const String&); 42 CSSCustomIdentValue(const String&);
43 CSSCustomIdentValue(CSSPropertyID);
34 44
45 // TODO(sashab): Change this to an AtomicString.
35 String m_string; 46 String m_string;
47 CSSPropertyID m_propertyId;
36 }; 48 };
37 49
38 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCustomIdentValue, isCustomIdentValue()); 50 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCustomIdentValue, isCustomIdentValue());
39 51
40 } // namespace blink 52 } // namespace blink
41 53
42 #endif // CSSCustomIdentValue_h 54 #endif // CSSCustomIdentValue_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSCalculationValue.cpp ('k') | third_party/WebKit/Source/core/css/CSSCustomIdentValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698