| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/cssom/CSSKeywordValue.h" | 5 #include "core/css/cssom/CSSKeywordValue.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "core/css/CSSCustomIdentValue.h" | 8 #include "core/css/CSSCustomIdentValue.h" |
| 9 #include "core/css/CSSIdentifierValue.h" | 9 #include "core/css/CSSIdentifierValue.h" |
| 10 #include "core/css/CSSInheritedValue.h" |
| 11 #include "core/css/CSSInitialValue.h" |
| 12 #include "core/css/CSSUnsetValue.h" |
| 10 #include "core/css/parser/CSSPropertyParser.h" | 13 #include "core/css/parser/CSSPropertyParser.h" |
| 11 | 14 |
| 12 namespace blink { | 15 namespace blink { |
| 13 | 16 |
| 14 CSSKeywordValue* CSSKeywordValue::create(const AtomicString& keyword, | 17 CSSKeywordValue* CSSKeywordValue::create(const AtomicString& keyword, |
| 15 ExceptionState& exceptionState) { | 18 ExceptionState& exceptionState) { |
| 16 if (keyword.isEmpty()) { | 19 if (keyword.isEmpty()) { |
| 17 exceptionState.throwTypeError( | 20 exceptionState.throwTypeError( |
| 18 "CSSKeywordValue does not support empty strings"); | 21 "CSSKeywordValue does not support empty strings"); |
| 19 return nullptr; | 22 return nullptr; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 const AtomicString& CSSKeywordValue::keywordValue() const { | 56 const AtomicString& CSSKeywordValue::keywordValue() const { |
| 54 return m_keywordValue; | 57 return m_keywordValue; |
| 55 } | 58 } |
| 56 | 59 |
| 57 CSSValueID CSSKeywordValue::keywordValueID() const { | 60 CSSValueID CSSKeywordValue::keywordValueID() const { |
| 58 return cssValueKeywordID(m_keywordValue); | 61 return cssValueKeywordID(m_keywordValue); |
| 59 } | 62 } |
| 60 | 63 |
| 61 CSSValue* CSSKeywordValue::toCSSValue() const { | 64 CSSValue* CSSKeywordValue::toCSSValue() const { |
| 62 CSSValueID keywordID = keywordValueID(); | 65 CSSValueID keywordID = keywordValueID(); |
| 63 if (keywordID == CSSValueID::CSSValueInvalid) { | 66 switch (keywordID) { |
| 64 return CSSCustomIdentValue::create(m_keywordValue); | 67 case (CSSValueInherit): |
| 68 return CSSInheritedValue::create(); |
| 69 case (CSSValueInitial): |
| 70 return CSSInitialValue::create(); |
| 71 case (CSSValueUnset): |
| 72 return CSSUnsetValue::create(); |
| 73 case (CSSValueInvalid): |
| 74 return CSSCustomIdentValue::create(m_keywordValue); |
| 75 default: |
| 76 return CSSIdentifierValue::create(keywordID); |
| 65 } | 77 } |
| 66 return CSSIdentifierValue::create(keywordID); | |
| 67 } | 78 } |
| 68 | 79 |
| 69 } // namespace blink | 80 } // namespace blink |
| OLD | NEW |