OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. | 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "core/style/ComputedStyle.h" | 27 #include "core/style/ComputedStyle.h" |
28 #include "platform/Length.h" | 28 #include "platform/Length.h" |
29 #include "wtf/text/StringBuilder.h" | 29 #include "wtf/text/StringBuilder.h" |
30 | 30 |
31 namespace blink { | 31 namespace blink { |
32 | 32 |
33 class CORE_EXPORT CSSValuePair : public CSSValue { | 33 class CORE_EXPORT CSSValuePair : public CSSValue { |
34 public: | 34 public: |
35 enum IdenticalValuesPolicy { DropIdenticalValues, KeepIdenticalValues }; | 35 enum IdenticalValuesPolicy { DropIdenticalValues, KeepIdenticalValues }; |
36 | 36 |
37 static CSSValuePair* create(CSSValue* first, CSSValue* second, | 37 static CSSValuePair* create(const CSSValue* first, const CSSValue* second, |
38 IdenticalValuesPolicy identicalValuesPolicy) | 38 IdenticalValuesPolicy identicalValuesPolicy) |
39 { | 39 { |
40 return new CSSValuePair(first, second, identicalValuesPolicy); | 40 return new CSSValuePair(first, second, identicalValuesPolicy); |
41 } | 41 } |
42 | 42 |
43 static CSSValuePair* create(const LengthSize& lengthSize, const ComputedStyl
e& style) | 43 static CSSValuePair* create(const LengthSize& lengthSize, const ComputedStyl
e& style) |
44 { | 44 { |
45 return new CSSValuePair(CSSPrimitiveValue::create(lengthSize.width(), st
yle.effectiveZoom()), CSSPrimitiveValue::create(lengthSize.height(), style.effec
tiveZoom()), KeepIdenticalValues); | 45 return new CSSValuePair(CSSPrimitiveValue::create(lengthSize.width(), st
yle.effectiveZoom()), CSSPrimitiveValue::create(lengthSize.height(), style.effec
tiveZoom()), KeepIdenticalValues); |
46 } | 46 } |
47 | 47 |
48 // TODO(sashab): Remove these non-const versions. | |
49 CSSValue& first() { return *m_first; } | |
50 CSSValue& second() { return *m_second; } | |
51 const CSSValue& first() const { return *m_first; } | 48 const CSSValue& first() const { return *m_first; } |
52 const CSSValue& second() const { return *m_second; } | 49 const CSSValue& second() const { return *m_second; } |
53 | 50 |
54 String customCSSText() const | 51 String customCSSText() const |
55 { | 52 { |
56 String first = m_first->cssText(); | 53 String first = m_first->cssText(); |
57 String second = m_second->cssText(); | 54 String second = m_second->cssText(); |
58 if (m_identicalValuesPolicy == DropIdenticalValues && first == second) | 55 if (m_identicalValuesPolicy == DropIdenticalValues && first == second) |
59 return first; | 56 return first; |
60 return first + ' ' + second; | 57 return first + ' ' + second; |
61 } | 58 } |
62 | 59 |
63 bool equals(const CSSValuePair& other) const | 60 bool equals(const CSSValuePair& other) const |
64 { | 61 { |
65 ASSERT(m_identicalValuesPolicy == other.m_identicalValuesPolicy); | 62 ASSERT(m_identicalValuesPolicy == other.m_identicalValuesPolicy); |
66 return compareCSSValuePtr(m_first, other.m_first) | 63 return compareCSSValuePtr(m_first, other.m_first) |
67 && compareCSSValuePtr(m_second, other.m_second); | 64 && compareCSSValuePtr(m_second, other.m_second); |
68 } | 65 } |
69 | 66 |
70 DECLARE_TRACE_AFTER_DISPATCH(); | 67 DECLARE_TRACE_AFTER_DISPATCH(); |
71 | 68 |
72 private: | 69 private: |
73 CSSValuePair(CSSValue* first, CSSValue* second, IdenticalValuesPolicy identi
calValuesPolicy) | 70 CSSValuePair(const CSSValue* first, const CSSValue* second, IdenticalValuesP
olicy identicalValuesPolicy) |
74 : CSSValue(ValuePairClass) | 71 : CSSValue(ValuePairClass) |
75 , m_first(first) | 72 , m_first(first) |
76 , m_second(second) | 73 , m_second(second) |
77 , m_identicalValuesPolicy(identicalValuesPolicy) | 74 , m_identicalValuesPolicy(identicalValuesPolicy) |
78 { | 75 { |
79 ASSERT(m_first); | 76 ASSERT(m_first); |
80 ASSERT(m_second); | 77 ASSERT(m_second); |
81 } | 78 } |
82 | 79 |
83 Member<CSSValue> m_first; | 80 Member<const CSSValue> m_first; |
84 Member<CSSValue> m_second; | 81 Member<const CSSValue> m_second; |
85 IdenticalValuesPolicy m_identicalValuesPolicy; | 82 IdenticalValuesPolicy m_identicalValuesPolicy; |
86 }; | 83 }; |
87 | 84 |
88 DEFINE_CSS_VALUE_TYPE_CASTS(CSSValuePair, isValuePair()); | 85 DEFINE_CSS_VALUE_TYPE_CASTS(CSSValuePair, isValuePair()); |
89 | 86 |
90 } // namespace blink | 87 } // namespace blink |
91 | 88 |
92 #endif // CSSValuePair_h | 89 #endif // CSSValuePair_h |
OLD | NEW |