| 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/KeywordValue.h" | 5 #include "core/css/cssom/KeywordValue.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/parser/CSSParserString.h" | 9 #include "core/css/parser/CSSParserString.h" |
| 10 #include "core/css/parser/CSSPropertyParser.h" | 10 #include "core/css/parser/CSSPropertyParser.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 KeywordValue* KeywordValue::create(const String& keyword, ExceptionState& except
ionState) | 14 KeywordValue* KeywordValue::create(const String& keyword, ExceptionState& except
ionState) |
| 15 { | 15 { |
| 16 if (keyword.isEmpty()) { | 16 if (keyword.isEmpty()) { |
| 17 exceptionState.throwTypeError("KeywordValue does not support empty strin
gs"); | 17 exceptionState.throwTypeError("KeywordValue does not support empty strin
gs"); |
| 18 return nullptr; | 18 return nullptr; |
| 19 } | 19 } |
| 20 return new KeywordValue(keyword); | 20 return new KeywordValue(keyword); |
| 21 } | 21 } |
| 22 | 22 |
| 23 const String& KeywordValue::keywordValue() const | 23 const String& KeywordValue::keywordValue() const |
| 24 { | 24 { |
| 25 return m_keywordValue; | 25 return m_keywordValue; |
| 26 } | 26 } |
| 27 | 27 |
| 28 PassRefPtrWillBeRawPtr<CSSValue> KeywordValue::toCSSValue() const | 28 RawPtr<CSSValue> KeywordValue::toCSSValue() const |
| 29 { | 29 { |
| 30 CSSParserString cssKeywordString; | 30 CSSParserString cssKeywordString; |
| 31 cssKeywordString.init(m_keywordValue); | 31 cssKeywordString.init(m_keywordValue); |
| 32 CSSValueID keywordID = cssValueKeywordID(cssKeywordString); | 32 CSSValueID keywordID = cssValueKeywordID(cssKeywordString); |
| 33 if (keywordID == CSSValueID::CSSValueInvalid) { | 33 if (keywordID == CSSValueID::CSSValueInvalid) { |
| 34 return CSSCustomIdentValue::create(m_keywordValue); | 34 return CSSCustomIdentValue::create(m_keywordValue); |
| 35 } | 35 } |
| 36 return cssValuePool().createIdentifierValue(keywordID); | 36 return cssValuePool().createIdentifierValue(keywordID); |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace blink | 39 } // namespace blink |
| OLD | NEW |