Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Motorola Mobility Inc. All rights reserved. | 2 * Copyright (C) 2012 Motorola Mobility Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above | 10 * 2. Redistributions in binary form must reproduce the above |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "core/css/DOMWindowCSS.h" | 30 #include "core/css/DOMWindowCSS.h" |
| 31 | 31 |
| 32 #include "core/css/CSSMarkup.h" | 32 #include "core/css/CSSMarkup.h" |
| 33 #include "core/css/CSSPropertyMetadata.h" | 33 #include "core/css/CSSPropertyMetadata.h" |
| 34 #include "core/css/StylePropertySet.h" | 34 #include "core/css/StylePropertySet.h" |
| 35 #include "core/css/parser/CSSParser.h" | 35 #include "core/css/parser/CSSParser.h" |
| 36 #include "core/css/parser/CSSVariableParser.h" | |
| 37 #include "wtf/text/StringBuilder.h" | 36 #include "wtf/text/StringBuilder.h" |
| 38 #include "wtf/text/WTFString.h" | 37 #include "wtf/text/WTFString.h" |
| 39 | 38 |
| 40 namespace blink { | 39 namespace blink { |
| 41 | 40 |
| 42 bool DOMWindowCSS::supports(const String& property, const String& value) | 41 bool DOMWindowCSS::supports(const String& property, const String& value) |
| 43 { | 42 { |
| 44 CSSPropertyID unresolvedProperty = unresolvedCSSPropertyID(property); | 43 CSSPropertyID unresolvedProperty = unresolvedCSSPropertyID(property); |
| 45 if (unresolvedProperty == CSSPropertyInvalid) { | 44 if (unresolvedProperty == CSSPropertyInvalid) |
| 46 if (CSSVariableParser::isValidVariableName(property)) { | |
| 47 MutableStylePropertySet* dummyStyle = MutableStylePropertySet::creat e(HTMLStandardMode); | |
| 48 return CSSParser::parseValueForCustomProperty(dummyStyle, "--valid", value, false, 0); | |
| 49 } | |
| 50 return false; | 45 return false; |
| 46 if (unresolvedProperty == CSSPropertyVariable) { | |
| 47 MutableStylePropertySet* dummyStyle = MutableStylePropertySet::create(HT MLStandardMode); | |
| 48 return CSSParser::parseValueForCustomProperty(dummyStyle, "--valid", val ue, false, 0); | |
|
ikilpatrick
2016/08/29 16:30:59
I assume once we have everything hooked up this wi
Timothy Loh
2016/08/30 03:57:18
I'm not really sure why this is "--valid" (I guess
| |
| 51 } | 49 } |
| 52 | 50 |
| 53 ASSERT(CSSPropertyMetadata::isEnabledProperty(unresolvedProperty)); | 51 ASSERT(CSSPropertyMetadata::isEnabledProperty(unresolvedProperty)); |
| 54 | 52 |
| 55 // This will return false when !important is present | 53 // This will return false when !important is present |
| 56 MutableStylePropertySet* dummyStyle = MutableStylePropertySet::create(HTMLSt andardMode); | 54 MutableStylePropertySet* dummyStyle = MutableStylePropertySet::create(HTMLSt andardMode); |
| 57 return CSSParser::parseValue(dummyStyle, unresolvedProperty, value, false, 0 ); | 55 return CSSParser::parseValue(dummyStyle, unresolvedProperty, value, false, 0 ); |
| 58 } | 56 } |
| 59 | 57 |
| 60 bool DOMWindowCSS::supports(const String& conditionText) | 58 bool DOMWindowCSS::supports(const String& conditionText) |
| 61 { | 59 { |
| 62 return CSSParser::parseSupportsCondition(conditionText); | 60 return CSSParser::parseSupportsCondition(conditionText); |
| 63 } | 61 } |
| 64 | 62 |
| 65 String DOMWindowCSS::escape(const String& ident) | 63 String DOMWindowCSS::escape(const String& ident) |
| 66 { | 64 { |
| 67 StringBuilder builder; | 65 StringBuilder builder; |
| 68 serializeIdentifier(ident, builder); | 66 serializeIdentifier(ident, builder); |
| 69 return builder.toString(); | 67 return builder.toString(); |
| 70 } | 68 } |
| 71 | 69 |
| 72 } // namespace blink | 70 } // namespace blink |
| OLD | NEW |