Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 31 #include "core/css/MediaQueryExp.h" | 31 #include "core/css/MediaQueryExp.h" |
| 32 | 32 |
| 33 #include "CSSValueKeywords.h" | 33 #include "CSSValueKeywords.h" |
| 34 #include "core/css/CSSAspectRatioValue.h" | 34 #include "core/css/CSSAspectRatioValue.h" |
| 35 #include "core/css/parser/BisonCSSParser.h" | 35 #include "core/css/parser/BisonCSSParser.h" |
| 36 #include "core/css/CSSPrimitiveValue.h" | 36 #include "core/css/CSSPrimitiveValue.h" |
| 37 #include "wtf/text/StringBuilder.h" | 37 #include "wtf/text/StringBuilder.h" |
| 38 | 38 |
| 39 namespace WebCore { | 39 namespace WebCore { |
| 40 | 40 |
| 41 DEFINE_GC_INFO(MediaQueryExp); | |
| 42 | |
| 41 static inline bool featureWithCSSValueID(const AtomicString& mediaFeature, const CSSParserValue* value) | 43 static inline bool featureWithCSSValueID(const AtomicString& mediaFeature, const CSSParserValue* value) |
| 42 { | 44 { |
| 43 if (!value->id) | 45 if (!value->id) |
| 44 return false; | 46 return false; |
| 45 | 47 |
| 46 return mediaFeature == MediaFeatureNames::orientationMediaFeature | 48 return mediaFeature == MediaFeatureNames::orientationMediaFeature |
| 47 || mediaFeature == MediaFeatureNames::viewModeMediaFeature | 49 || mediaFeature == MediaFeatureNames::viewModeMediaFeature |
| 48 || mediaFeature == MediaFeatureNames::pointerMediaFeature | 50 || mediaFeature == MediaFeatureNames::pointerMediaFeature |
| 49 || mediaFeature == MediaFeatureNames::scanMediaFeature; | 51 || mediaFeature == MediaFeatureNames::scanMediaFeature; |
| 50 } | 52 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 || m_mediaFeature == MediaFeatureNames::maxWidthMediaFeature | 190 || m_mediaFeature == MediaFeatureNames::maxWidthMediaFeature |
| 189 || m_mediaFeature == MediaFeatureNames::maxHeightMediaFeature | 191 || m_mediaFeature == MediaFeatureNames::maxHeightMediaFeature |
| 190 || m_mediaFeature == MediaFeatureNames::orientationMediaFeature | 192 || m_mediaFeature == MediaFeatureNames::orientationMediaFeature |
| 191 || m_mediaFeature == MediaFeatureNames::aspectRatioMediaFeature | 193 || m_mediaFeature == MediaFeatureNames::aspectRatioMediaFeature |
| 192 || m_mediaFeature == MediaFeatureNames::minAspectRatioMediaFeature | 194 || m_mediaFeature == MediaFeatureNames::minAspectRatioMediaFeature |
| 193 || m_mediaFeature == MediaFeatureNames::devicePixelRatioMediaFeature | 195 || m_mediaFeature == MediaFeatureNames::devicePixelRatioMediaFeature |
| 194 || m_mediaFeature == MediaFeatureNames::resolutionMediaFeature | 196 || m_mediaFeature == MediaFeatureNames::resolutionMediaFeature |
| 195 || m_mediaFeature == MediaFeatureNames::maxAspectRatioMediaFeature; | 197 || m_mediaFeature == MediaFeatureNames::maxAspectRatioMediaFeature; |
| 196 } | 198 } |
| 197 | 199 |
| 200 MediaQueryExp::MediaQueryExp(const MediaQueryExp& other) | |
|
haraken
2014/02/21 01:02:36
I'm just curious: Why do you need to add the copy
wibling-chromium
2014/02/21 08:43:08
Because of the copy method in the .h file. It call
| |
| 201 : m_mediaFeature(other.mediaFeature()) | |
| 202 , m_value(other.value()) | |
| 203 { | |
| 204 } | |
| 205 | |
| 198 MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, PassRefPtrWillBeR awPtr<CSSValue> value) | 206 MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, PassRefPtrWillBeR awPtr<CSSValue> value) |
| 199 : m_mediaFeature(mediaFeature) | 207 : m_mediaFeature(mediaFeature) |
| 200 , m_value(value) | 208 , m_value(value) |
| 201 { | 209 { |
| 202 } | 210 } |
| 203 | 211 |
| 204 PassOwnPtr<MediaQueryExp> MediaQueryExp::create(const AtomicString& mediaFeature , CSSParserValueList* valueList) | 212 PassOwnPtrWillBeRawPtr<MediaQueryExp> MediaQueryExp::create(const AtomicString& mediaFeature, CSSParserValueList* valueList) |
| 205 { | 213 { |
| 206 RefPtrWillBeRawPtr<CSSValue> cssValue; | 214 RefPtrWillBeRawPtr<CSSValue> cssValue; |
| 207 bool isValid = false; | 215 bool isValid = false; |
| 208 | 216 |
| 209 // Create value for media query expression that must have 1 or more values. | 217 // Create value for media query expression that must have 1 or more values. |
| 210 if (valueList) { | 218 if (valueList) { |
| 211 if (valueList->size() == 1) { | 219 if (valueList->size() == 1) { |
| 212 CSSParserValue* value = valueList->current(); | 220 CSSParserValue* value = valueList->current(); |
| 213 | 221 |
| 214 if (featureWithCSSValueID(mediaFeature, value)) { | 222 if (featureWithCSSValueID(mediaFeature, value)) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 if (isValid) | 269 if (isValid) |
| 262 cssValue = CSSAspectRatioValue::create(numeratorValue, denominat orValue); | 270 cssValue = CSSAspectRatioValue::create(numeratorValue, denominat orValue); |
| 263 } | 271 } |
| 264 } else if (featureWithoutValue(mediaFeature)) { | 272 } else if (featureWithoutValue(mediaFeature)) { |
| 265 isValid = true; | 273 isValid = true; |
| 266 } | 274 } |
| 267 | 275 |
| 268 if (!isValid) | 276 if (!isValid) |
| 269 return nullptr; | 277 return nullptr; |
| 270 | 278 |
| 271 return adoptPtr(new MediaQueryExp(mediaFeature, cssValue)); | 279 return adoptPtrWillBeNoop(new MediaQueryExp(mediaFeature, cssValue)); |
| 272 } | 280 } |
| 273 | 281 |
| 274 MediaQueryExp::~MediaQueryExp() | 282 MediaQueryExp::~MediaQueryExp() |
| 275 { | 283 { |
| 276 } | 284 } |
| 277 | 285 |
| 278 String MediaQueryExp::serialize() const | 286 String MediaQueryExp::serialize() const |
| 279 { | 287 { |
| 280 StringBuilder result; | 288 StringBuilder result; |
| 281 result.append("("); | 289 result.append("("); |
| 282 result.append(m_mediaFeature.lower()); | 290 result.append(m_mediaFeature.lower()); |
| 283 if (m_value) { | 291 if (m_value) { |
| 284 result.append(": "); | 292 result.append(": "); |
| 285 result.append(m_value->cssText()); | 293 result.append(m_value->cssText()); |
| 286 } | 294 } |
| 287 result.append(")"); | 295 result.append(")"); |
| 288 | 296 |
| 289 return result.toString(); | 297 return result.toString(); |
| 290 } | 298 } |
| 291 | 299 |
| 292 } // namespace | 300 } // namespace |
| OLD | NEW |