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, 2007, 2010 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved. |
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 11 matching lines...) Expand all Loading... |
22 #include "core/css/CSSValueList.h" | 22 #include "core/css/CSSValueList.h" |
23 | 23 |
24 #include "core/css/CSSPrimitiveValue.h" | 24 #include "core/css/CSSPrimitiveValue.h" |
25 #include "wtf/text/StringBuilder.h" | 25 #include "wtf/text/StringBuilder.h" |
26 | 26 |
27 namespace blink { | 27 namespace blink { |
28 | 28 |
29 CSSValueList::CSSValueList(ClassType classType, ValueListSeparator listSeparator
) | 29 CSSValueList::CSSValueList(ClassType classType, ValueListSeparator listSeparator
) |
30 : CSSValue(classType) | 30 : CSSValue(classType) |
31 { | 31 { |
32 m_valueListSeparator = listSeparator; | 32 setValueListSeparator(listSeparator); |
33 } | 33 } |
34 | 34 |
35 CSSValueList::CSSValueList(ValueListSeparator listSeparator) | 35 CSSValueList::CSSValueList(ValueListSeparator listSeparator) |
36 : CSSValue(ValueListClass) | 36 : CSSValue(ValueListClass) |
37 { | 37 { |
38 m_valueListSeparator = listSeparator; | 38 setValueListSeparator(listSeparator); |
39 } | 39 } |
40 | 40 |
41 bool CSSValueList::removeAll(CSSValue* val) | 41 bool CSSValueList::removeAll(CSSValue* val) |
42 { | 42 { |
43 bool found = false; | 43 bool found = false; |
44 for (int index = m_values.size() - 1; index >= 0; --index) { | 44 for (int index = m_values.size() - 1; index >= 0; --index) { |
45 RefPtrWillBeMember<CSSValue>& value = m_values.at(index); | 45 RefPtrWillBeMember<CSSValue>& value = m_values.at(index); |
46 if (value && val && value->equals(*val)) { | 46 if (value && val && value->equals(*val)) { |
47 m_values.remove(index); | 47 m_values.remove(index); |
48 found = true; | 48 found = true; |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 return found; | 52 return found; |
53 } | 53 } |
54 | 54 |
55 bool CSSValueList::hasValue(CSSValue* val) const | 55 bool CSSValueList::hasValue(CSSValue* val) const |
56 { | 56 { |
57 for (size_t index = 0; index < m_values.size(); index++) { | 57 for (size_t index = 0; index < m_values.size(); index++) { |
58 const RefPtrWillBeMember<CSSValue>& value = m_values.at(index); | 58 const RefPtrWillBeMember<CSSValue>& value = m_values.at(index); |
59 if (value && val && value->equals(*val)) | 59 if (value && val && value->equals(*val)) |
60 return true; | 60 return true; |
61 } | 61 } |
62 return false; | 62 return false; |
63 } | 63 } |
64 | 64 |
65 PassRefPtrWillBeRawPtr<CSSValueList> CSSValueList::copy() | 65 PassRefPtrWillBeRawPtr<CSSValueList> CSSValueList::copy() |
66 { | 66 { |
67 RefPtrWillBeRawPtr<CSSValueList> newList = nullptr; | 67 RefPtrWillBeRawPtr<CSSValueList> newList = nullptr; |
68 switch (m_valueListSeparator) { | 68 switch (valueListSeparator()) { |
69 case SpaceSeparator: | 69 case SpaceSeparator: |
70 newList = createSpaceSeparated(); | 70 newList = createSpaceSeparated(); |
71 break; | 71 break; |
72 case CommaSeparator: | 72 case CommaSeparator: |
73 newList = createCommaSeparated(); | 73 newList = createCommaSeparated(); |
74 break; | 74 break; |
75 case SlashSeparator: | 75 case SlashSeparator: |
76 newList = createSlashSeparated(); | 76 newList = createSlashSeparated(); |
77 break; | 77 break; |
78 default: | 78 default: |
79 ASSERT_NOT_REACHED(); | 79 ASSERT_NOT_REACHED(); |
80 } | 80 } |
81 for (size_t index = 0; index < m_values.size(); index++) | 81 for (size_t index = 0; index < m_values.size(); index++) |
82 newList->append(m_values[index]); | 82 newList->append(m_values[index]); |
83 return newList.release(); | 83 return newList.release(); |
84 } | 84 } |
85 | 85 |
86 String CSSValueList::customCSSText() const | 86 String CSSValueList::customCSSText() const |
87 { | 87 { |
88 StringBuilder result; | 88 StringBuilder result; |
89 String separator; | 89 String separator; |
90 switch (m_valueListSeparator) { | 90 switch (valueListSeparator()) { |
91 case SpaceSeparator: | 91 case SpaceSeparator: |
92 separator = " "; | 92 separator = " "; |
93 break; | 93 break; |
94 case CommaSeparator: | 94 case CommaSeparator: |
95 separator = ", "; | 95 separator = ", "; |
96 break; | 96 break; |
97 case SlashSeparator: | 97 case SlashSeparator: |
98 separator = " / "; | 98 separator = " / "; |
99 break; | 99 break; |
100 default: | 100 default: |
101 ASSERT_NOT_REACHED(); | 101 ASSERT_NOT_REACHED(); |
102 } | 102 } |
103 | 103 |
104 unsigned size = m_values.size(); | 104 unsigned size = m_values.size(); |
105 for (unsigned i = 0; i < size; i++) { | 105 for (unsigned i = 0; i < size; i++) { |
106 if (!result.isEmpty()) | 106 if (!result.isEmpty()) |
107 result.append(separator); | 107 result.append(separator); |
108 result.append(m_values[i]->cssText()); | 108 result.append(m_values[i]->cssText()); |
109 } | 109 } |
110 | 110 |
111 return result.toString(); | 111 return result.toString(); |
112 } | 112 } |
113 | 113 |
114 bool CSSValueList::equals(const CSSValueList& other) const | 114 bool CSSValueList::equals(const CSSValueList& other) const |
115 { | 115 { |
116 return m_valueListSeparator == other.m_valueListSeparator && compareCSSValue
Vector(m_values, other.m_values); | 116 return valueListSeparator() == other.valueListSeparator() && compareCSSValue
Vector(m_values, other.m_values); |
117 } | 117 } |
118 | 118 |
119 bool CSSValueList::hasFailedOrCanceledSubresources() const | 119 bool CSSValueList::hasFailedOrCanceledSubresources() const |
120 { | 120 { |
121 for (unsigned i = 0; i < m_values.size(); ++i) { | 121 for (unsigned i = 0; i < m_values.size(); ++i) { |
122 if (m_values[i]->hasFailedOrCanceledSubresources()) | 122 if (m_values[i]->hasFailedOrCanceledSubresources()) |
123 return true; | 123 return true; |
124 } | 124 } |
125 return false; | 125 return false; |
126 } | 126 } |
127 | 127 |
128 DEFINE_TRACE_AFTER_DISPATCH(CSSValueList) | 128 DEFINE_TRACE_AFTER_DISPATCH(CSSValueList) |
129 { | 129 { |
130 visitor->trace(m_values); | 130 visitor->trace(m_values); |
131 CSSValue::traceAfterDispatch(visitor); | 131 CSSValue::traceAfterDispatch(visitor); |
132 } | 132 } |
133 | 133 |
134 } // namespace blink | 134 } // namespace blink |
OLD | NEW |