OLD | NEW |
1 /* | 1 /* |
2 * CSS Media Query | 2 * CSS Media Query |
3 * | 3 * |
4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. | 4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. |
5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
6 * Copyright (C) 2013 Apple Inc. All rights reserved. | 6 * Copyright (C) 2013 Apple Inc. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 || m_mediaFeature == MediaFeatureNames::maxWidthMediaFeature | 188 || m_mediaFeature == MediaFeatureNames::maxWidthMediaFeature |
189 || m_mediaFeature == MediaFeatureNames::maxHeightMediaFeature | 189 || m_mediaFeature == MediaFeatureNames::maxHeightMediaFeature |
190 || m_mediaFeature == MediaFeatureNames::orientationMediaFeature | 190 || m_mediaFeature == MediaFeatureNames::orientationMediaFeature |
191 || m_mediaFeature == MediaFeatureNames::aspectRatioMediaFeature | 191 || m_mediaFeature == MediaFeatureNames::aspectRatioMediaFeature |
192 || m_mediaFeature == MediaFeatureNames::minAspectRatioMediaFeature | 192 || m_mediaFeature == MediaFeatureNames::minAspectRatioMediaFeature |
193 || m_mediaFeature == MediaFeatureNames::devicePixelRatioMediaFeature | 193 || m_mediaFeature == MediaFeatureNames::devicePixelRatioMediaFeature |
194 || m_mediaFeature == MediaFeatureNames::resolutionMediaFeature | 194 || m_mediaFeature == MediaFeatureNames::resolutionMediaFeature |
195 || m_mediaFeature == MediaFeatureNames::maxAspectRatioMediaFeature; | 195 || m_mediaFeature == MediaFeatureNames::maxAspectRatioMediaFeature; |
196 } | 196 } |
197 | 197 |
| 198 MediaQueryExp::MediaQueryExp(const MediaQueryExp& other) |
| 199 : m_mediaFeature(other.mediaFeature()) |
| 200 , m_value(other.value()) |
| 201 { |
| 202 } |
| 203 |
198 MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, PassRefPtrWillBeR
awPtr<CSSValue> value) | 204 MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, PassRefPtrWillBeR
awPtr<CSSValue> value) |
199 : m_mediaFeature(mediaFeature) | 205 : m_mediaFeature(mediaFeature) |
200 , m_value(value) | 206 , m_value(value) |
201 { | 207 { |
202 } | 208 } |
203 | 209 |
204 PassOwnPtr<MediaQueryExp> MediaQueryExp::create(const AtomicString& mediaFeature
, CSSParserValueList* valueList) | 210 PassOwnPtrWillBeRawPtr<MediaQueryExp> MediaQueryExp::create(const AtomicString&
mediaFeature, CSSParserValueList* valueList) |
205 { | 211 { |
206 RefPtrWillBeRawPtr<CSSValue> cssValue; | 212 RefPtrWillBeRawPtr<CSSValue> cssValue; |
207 bool isValid = false; | 213 bool isValid = false; |
208 | 214 |
209 // Create value for media query expression that must have 1 or more values. | 215 // Create value for media query expression that must have 1 or more values. |
210 if (valueList) { | 216 if (valueList) { |
211 if (valueList->size() == 1) { | 217 if (valueList->size() == 1) { |
212 CSSParserValue* value = valueList->current(); | 218 CSSParserValue* value = valueList->current(); |
213 | 219 |
214 if (featureWithCSSValueID(mediaFeature, value)) { | 220 if (featureWithCSSValueID(mediaFeature, value)) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 if (isValid) | 267 if (isValid) |
262 cssValue = CSSAspectRatioValue::create(numeratorValue, denominat
orValue); | 268 cssValue = CSSAspectRatioValue::create(numeratorValue, denominat
orValue); |
263 } | 269 } |
264 } else if (featureWithoutValue(mediaFeature)) { | 270 } else if (featureWithoutValue(mediaFeature)) { |
265 isValid = true; | 271 isValid = true; |
266 } | 272 } |
267 | 273 |
268 if (!isValid) | 274 if (!isValid) |
269 return nullptr; | 275 return nullptr; |
270 | 276 |
271 return adoptPtr(new MediaQueryExp(mediaFeature, cssValue)); | 277 return adoptPtrWillBeNoop(new MediaQueryExp(mediaFeature, cssValue)); |
272 } | 278 } |
273 | 279 |
274 MediaQueryExp::~MediaQueryExp() | 280 MediaQueryExp::~MediaQueryExp() |
275 { | 281 { |
276 } | 282 } |
277 | 283 |
278 String MediaQueryExp::serialize() const | 284 String MediaQueryExp::serialize() const |
279 { | 285 { |
280 StringBuilder result; | 286 StringBuilder result; |
281 result.append("("); | 287 result.append("("); |
282 result.append(m_mediaFeature.lower()); | 288 result.append(m_mediaFeature.lower()); |
283 if (m_value) { | 289 if (m_value) { |
284 result.append(": "); | 290 result.append(": "); |
285 result.append(m_value->cssText()); | 291 result.append(m_value->cssText()); |
286 } | 292 } |
287 result.append(")"); | 293 result.append(")"); |
288 | 294 |
289 return result.toString(); | 295 return result.toString(); |
290 } | 296 } |
291 | 297 |
292 } // namespace | 298 } // namespace |
OLD | NEW |